Technically speaking, there is a preliminary discussion on this: precision is different than accuracy. Accuracy is a measurement of how close your calculation is to the true value, whatever it is; precision is a measurement of how close are many calculations to each other. You understand better if you think in terms of probability distribution of a set of calculation results. Therefore, you could have poor accuracy with high precision, for example. The title of your post is about accuracy, but in the body you mention precision.
I guess you meant accuracy.
That said, there is no general answer.
There are many methods you could use, actually infinite algorithms could fit your needs.
You need:
- a library like GMP, as already suggested
- paper and pencil to evaluate the accuracy of your algorithm
Why this? You need to evaluate your sin(x)
with higher accuracy than the two results you want to compare. And algorithms for transcendental functions are series. So you have to estimate how the algorithm error - and in some cases, still the representation errors - influence you calculation. At that point, implement the method of your choice, and evaluate the distance between your result and the other two, being sure that the total error affecting your result is however smaller than some controllable constant.
As an example, evaluating exp(10)
can be done using the usual exponential Taylor expansion around zero, and using many terms; but if you use the same method for exp(-10)
, you may fail, as its expansion has alternating sign terms. This means that you may have cancellation effects that could accumulate. You do not want this, otherwise you may be precise, but biased, inaccurate in your calculation.
Usually GMP is used because it is designed for this.
So, for example, you may discover that Scilab is best in calculating exp(-10)
, and C++ in exp(10)
, just because they could use different implementations.
In summary: use GMP, and look for an accurate algorithm. This may work, or be the only solution, if you need an accurate result of some particular Fourier summation, or a series in which other transcendental terms have to be evaluated, for example.
But if you just need this answer for simple sin
and exp
, you should look for tables, and that's it.