0

When calculating values for sin and the corresponding value 180° greater using the python math library the values are slightly different in this example there is a difference of 1.1102230246251565e-16

a=math.sin(math.radians(45))
print(a)
>>>0.7071067811865476
b=math.sin(math.radians(225))
print(b)
>>>-0.7071067811865475
a+b
>>>1.1102230246251565e-16

What I would like to get is the same value for both with the value for one being negative, so that the sum of the two would be equal.

I would appreciate any advice, Thank you.

Camo8315
  • 11
  • 2
  • 1
    Does this answer your question? [Is floating point math broken?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) – Keldorn May 04 '20 at 20:04
  • I don't think it's possible. Floating-point math is inherently imprecise – ForceBru May 04 '20 at 20:04
  • One part in 10**16 is essentially zero. It is roughly the same as the width of one carbon atom compared to the width of Texas. – James May 04 '20 at 20:12

0 Answers0