Hello guys! I’d like to know how does Mathematica compute the sine and cosine function.
I need this to estimate the error Mathematica is propagating.
You can get an outer bonds pair by feeding in an Interval. For example, to get bounds on the Mathematica computation of Sin[1.] (which is a machine double value for the input), could do:
Sin[Interval[1.]]
(* Out[462]= Interval[{0.8414709848078963, 0.8414709848078967}] *)
This also works for arbitrary precision.
Sin[Interval[N[2, 20]]]
(* Out[463]= Interval[{0.90929742682568169537, 0.90929742682568169542}] *)
Under the hood, the Interval construct with a single numeric argument is subtracting and adding an ULP, and Sin understands Interval inputs, so this is computing bounds on the sine for the given interval.
I realize this does not answer the question that was asked. But it does get at the underlying need. Offhand I am not familiar with the details of how the argument to the trigs gets normalized (by subtracting e.g. multiples of Pi/2). Or what method is used from there, though I would guess it is based on a series expansion at the origin or perhaps Pi/2 or other convenient value. Or maybe there are better methods, I’m really not sure.