Question

I ask for a brief explanation, pointing out the various acceleration methods involved. This is just for mere curiosity.

For example the mpmath website tells that the exponential function formula is used for operations in the complex plane, but for now I'd like to keep it to the operations used over plain real numbers.

Optionally, it would be nice to have a link to the source code sections where the actual calculations are performed in mpmath, I had no luck searching the downloadable sources.

Was it helpful?

Solution

Up to a precision of 1000 decimal digits elementary functions are normally calculated by Taylor series which converge quite good. If you specifically know what precision do you need, Chebyshev polynomials get the best quality with the least effort.

For extraordinary precision you are using the Arithmetic-geometric mean, which converges quadratically to the solution and allows you to calculate ln(x) fast. The inverse function exp(x) is calculated by a a Newton-Raphson iteration. From that on there are some algorithms which are able to calculate arctan,tan,sin,cos...

For your leisure about the algorithms, please refer to Elementary Functions: Algorithms and Implementation from Jean-Michel Muller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top