From the trigonometric identities we have that:
sin^2(x) + cos^2(x) = 1
However when running the following code:
from math import sin, cos, pi
for i in range(1, 15):
x = pi/i
r = sin(x)**2 + cos(x)**2
print (r)
the output is not 1 as expected:
1.0
1.0
1.0
1.0000000000000002
1.0
1.0
1.0
1.0
1.0
0.9999999999999999
0.9999999999999999
1.0
0.9999999999999999
1.0
What's the reason for this irregularity?