problem with the 'math' module in 2.5?
chrispatton at gmail.com
Sun Oct 15 06:13:06 CEST 2006
sin(pi*0.5) is what I expected, but I expected to get 0 for sin(pi).
Max Erickson wrote:
> "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:
> 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