[issue46444] Wrong value of pi for larger values using math.cos() function

Darshan Kanade report at bugs.python.org
Thu Jan 20 01:25:26 EST 2022


New submission from Darshan Kanade <kanadedarshan at gmail.com>:

I was solving this problem to find the approximate value of pi using the Archimedes method using two different logics -

1) The first one used the formula pi = k*cos(90-180/k) but when I gave very large input, say k=2**62 sides of polygon, then it gives the value of pi as 282.3843260569851... for comparatively smaller k=1000000 it is around 3.14

2)Because the first one was giving wrong answer for larger values, I googled for solution and came across this other logic using the formula pi = k * sin(180/k). 
In this method, we get values of pi around 3.14 no matter how large the input is, even if it is k=2**62!

----------
messages: 411005
nosy: Darshan
priority: normal
severity: normal
status: open
title: Wrong value of pi for larger values using math.cos() function
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46444>
_______________________________________


More information about the Python-bugs-list mailing list