I want to calculate the sine of a big integer, e.g., Sin[10^50], but found that N[Sin[10^50]], N[Sin[10^50],10], and N[Sin[10^50],20] give different results:
N[Sin[10^50]]
-0.4805
N[Sin[10^50], 10]
-0.7896724934
N[Sin[10^50], 20]
-0.78967249342931008271
It seems that N[Sin[10^50]] did not give a correct result as N[Sin[10^50], 20] uses higher precision and is more likely to give a correct one. But I was curious why N[Sin[10^50], 10] can give a result close to N[Sin[10^50], 20] with a lower precision than the machine precision while N[Sin[10^50]] cannot?
I did some further research by calculating the remainder of 10^50/(2 Pi), in the following way:
remainder := 10^50 - 2 Pi (10^50/(2 Pi) // Floor);
N[remainder]
2.07692*10^34
N[remainder, 10]
4.051867659
N[remainder, 20]
4.0518676593164822448
It is obvious that N[remainder] has a very large error, while N[remainder,10] and N[remainder,20] seem to give the correct result.
I also tried the built-in Mod function, and the results are similar.
So I was curious why the function N with the default machine precision can have such a large error while N with a specified precision even lower than the machine precision can give a good result?
Can anyone tell the reason? Thanks.
Sin
. $\endgroup$