12
$\begingroup$

I'm working on a multiple-precision library. I'd like to make it possible for users to ask for higher precision answers for results already computed at a fixed precision. My $\mathrm{sqrt}(x)$ can pick up where it left off, even if $x$ changes a bit, because it uses Newton-Raphson. But $\exp(x)$ computed using a Maclaurin series or continued fraction has to be computed from scratch.

Is there an iterative refinement (i.e. Newton-Raphson, gradient descent) method for computing $\exp(x)$ that uses only arithmetic and integer roots?

(I know Newton-Raphson can solve $\log(y)-x=0$ to compute $\exp(x)$. I am specifically not asking for that. Newton-Raphson can also solve $\exp(y)-x=0$ to compute $\log(x)$. Note that each requires the other. I have neither right now as an arbitrary-precision function. I have arithmetic, integer roots, and equality/inequality tests.)

  • 1
    I don't believe there's a refinement scheme for $\exp(z)$. The best I've seen, assuming you're using scaling+squaring, is to have to redo series/CF computations on a version of $z\cdot2^{-n}$ with greater precision, and then square $n$ times.2010-09-25
  • 1
    Not sure if it helps, I know there is an algorithm to compute kth digit of pi (in base 16). Perhaps something like that exists for exp(x) in base 10/whatever base you are working in. Spigot algorithm is the name I believe. (not sure)2010-09-25
  • 0
    There is a spigot algorithm for $e$, but I don't see how it generalizes to $\exp(x)$.2010-09-25
  • 1
    @J.M., it generalises to convergent hypergeometrics. See http://math.stackexchange.com/questions/18445/fastest-way-to-calculate-ex-upto-arbitrary-number-of-decimals/18451#18451 for code2011-01-21

1 Answers 1

3

There is an algorithm for computing $\log_2(x)$ that might suit you. Combine that with the spigot algorithm for $e$, and you can get $\ln(x)$. From there, you can use Newton-Raphson to get $\exp(x)$.

I don't know if this roundabout way ends up doing any better than just recomputing.