2.5中'math'模块的问题? [英] problem with the 'math' module in 2.5?

查看:56
本文介绍了2.5中'math'模块的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>>来自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


余弦函数工作正常,但我正在为正弦得到奇怪的答案。

这是一个错误吗?我做错了吗?

解决方案



Chris写道:


>来自数学导入*
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


余弦函数工作正常,但我正在为正弦得到奇怪的答案。

这是一个错误吗?难道我做错了什么?



你认为2.4版本的答案是什么?


" Chris" < ch ********* @ gmail.comwrote:


> ;>>来自数学导入*
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


余弦函数工作正常,但我得到了奇怪的答案

正弦。这是一个错误吗?我做错了吗?


>来自交互式窗口中的帮助(数学):



描述

此模块始终可用。它提供了对C标准定义的

数学函数的访问。


所以你看到的是被暴露的C库的行为。 />
尝试sin(pi * 0.5)以查看与cos(pi)或cos(pi * 2)类似的行为。


sin (pi * 0.5)是我的预期,但我希望罪(pi)得到0。


Max Erickson写道:


" Chris" < ch ********* @ gmail.comwrote:


>>来自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)



$


余弦函数工作正常,但是我得到了奇怪的答案

正弦。这是一个错误吗?难道我做错了什么?


来自交互式窗口中的帮助(数学):




描述

此模块始终可用。它提供了对C标准定义的

数学函数的访问。


所以你看到的是被暴露的C库的行为。 />

尝试sin(pi * 0.5)以查看与cos(pi)或cos(pi * 2)类似的行为。


>>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?

解决方案


Chris 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?

What answer do you suppose you get in version 2.4?


"Chris" <ch*********@gmail.comwrote:

>>>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).


sin(pi*0.5) is what I expected, but I expected to get 0 for sin(pi).

Max Erickson wrote:

"Chris" <ch*********@gmail.comwrote:

>>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).


这篇关于2.5中'math'模块的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆