I’am trying to calcuate values of the sin-function to high precision. I want to get at least 1 million valid digits.
Using the following code I test the accuracy of BigFloat:
# Set precision to 7 million bits, so I expect about 2 million valid digits setprecision(7000000) # Get value of pi with high precision bigpi=BigFloat(pi) # Calculate difference of sin(pi/2)-1. Should be zero in exact arithmetic sin(bigpi/BigFloat(2))-1 # Calualate difference of sin(pi/6)-1/2. Should be zero in exact arithmetic sin(bigpi/BigFloat(6))-1/BigFloat(2)
For the first difference I get the value of zero. That means the result of sin(pi/2) is valid up to 2 million digits.
For the secons difference I get an value of about 4.76993…e-306923. That means sin(pi/6) is only calculated up to about 300’000 digits and not 2 million digits.
Did I make something wrong in the setup of this test, or are there limitations in the accuray of the sin-function.