If you have an arbitrary precision decimal library, but it doesn't come with any basic (e.g. the exponential function, the sine function), or special (e.g. the error function, the logarithmic integral) mathematical functions, what is the best way to implement them?
Obviously, as the value of most of these functions is irrational, it only makes sense to give the answer to a specified precision. So supposing I want to calculate erf(x) (for instance) to 50 decimal places, what is the best way to do it?
The best answer I have is mapping the argument to some suitable range, and then using the Taylor series of the function to get an answer that converges (hopefully) reasonably quickly. We can use something like Taylor's theorem to bound the error term, but usually, this involves comparing factorials to powers of 10 (for example, see the example under "Taylor's theorem in one real variable" on the Wiki page for Taylor's Theorem), which, whilst doable, seems long-winded.
Also, whilst implementing these functions seems feasible, how would one handle the precision when dealing with the composition of such functions? For instance, if we wanted to calculate 1000*exp(sqrt(2)) to n decimal places, it's not immediately obvious to what level of precision we should calculate the intermediate results to get an accurate final answer.
Does anyone know where I might begin with this problem?