109 107 bytes
is a fairly straight-forward calculation. I use a nested form of the sum of inverse factorials, which not only increases the convergence rate, but also allows for exponentiation at the same time:
is slightly more complicated. All convergent series seem to work for or , but not both (Newton's iteration does not have this limitation, but requires the calculation of each step). This isn't really a problem, though, given the log identity:
This means that if, for example, the iteration you're using only works on and , you can use the multiplicative inverse of and negate the result. Because I was using a nested identity for , I also chose to use a nested identity for :
Or equivalently, as demonstrated by Paul Walls' implementation:
I define the case as (which is necessarily negative), using the absolute value for the inner product, and then allowing a bare value in the fraction to correct the sign.
$ echo 2 | php exp_ln.php
$ echo 0.25 | php exp_ln.php
$ echo 2.718281828 | php exp_ln.php
$ echo -0.1 | php exp_ln.php
95 93 bytes
Nearly identical to the PHP solution above with a few negated terms, to allow iteration from
Both 2 byte improvements due to Paul Walls.