problem with the 'math' module in 2.5?
Max Erickson
maxerickson at gmail.com
Sat Oct 14 23:55:10 EDT 2006
"Chris" <chrispatton at gmail.com> wrote:
>>>> from math import *
>>>> sin(0)
> 0.0
>>>> sin(pi)
> 1.2246063538223773e-016
>>>> sin(2*pi)
> -2.4492127076447545e-016
>>>> cos(0)
> 1.0
>>>> cos(pi)
> -1.0
>>>> cos(2*pi)
> 1.0
>
> The cosine function works fine, but I'm getting weird answers for
> sine. Is this a bug? Am I doing something wrong?
>
>From help(math) in an interactive window:
DESCRIPTION
This module is always available. It provides access to the
mathematical functions defined by the C standard.
So what you are seeing is the behavior of the C library being exposed.
Try sin(pi*0.5) to see similar behavior to cos(pi) or cos(pi*2).
More information about the Python-list
mailing list