13
$\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.)

$\endgroup$
4
  • 1
    $\begingroup$ 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. $\endgroup$ Sep 25, 2010 at 6:01
  • 1
    $\begingroup$ 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) $\endgroup$
    – Aryabhata
    Sep 25, 2010 at 13:41
  • $\begingroup$ There is a spigot algorithm for $e$, but I don't see how it generalizes to $\exp(x)$. $\endgroup$ Sep 25, 2010 at 23:32
  • 1
    $\begingroup$ @J.M., it generalises to convergent hypergeometrics. See math.stackexchange.com/questions/18445/… for code $\endgroup$ Jan 21, 2011 at 18:18

1 Answer 1

4
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .