[New-bugs-announce] [issue46444] Wrong value of pi for larger values using math.cos() function
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!
title: Wrong value of pi for larger values using math.cos() function
versions: Python 3.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce