# Re: Computing exp(z)

In article <d6htql\$rbq\$1@xxxxxxxxxxxxxxxxxx>,
"gh14tq5@xxxxxxxxx" <gh14tq5@xxxxxxxxx> wrote:

> Are there any disadvantages/pitfalls to computing exp(z) as
>
> exp(z) = exp(real(z))*(cos(aimag(z)),sin(aimag(z)))

One possible disadvantage is that this is not the correct equation.
At least it isn't the one that I've always used. Did you compare
results to see if your equation was correct? What you want, I
think, is something like:

r = abs(z)
theta = atan2(real(z),aimag(z))
expz = exp(r) * complx( cos(theta), sin(theta) )

Of course, you need to test for r=0.0 and so on, but you get the
point. I doubt that the intrinsic exp(z) is slower than this.

\$.02 -Ron Shepard
.

## Relevant Pages

• Re: Computing exp(z)
... Ron Shepard wrote: ... >> Are there any disadvantages/pitfalls to computing expas ... > One possible disadvantage is that this is not the correct equation. ...
(comp.lang.fortran)
• Re: Computing exp(z)
... > Are there any disadvantages/pitfalls to computing expas ... > computation time in my program, and was able to shave a few percentages ... but it shouldn't be visible in single precision. ...
(comp.lang.fortran)
• Computing exp(z)
... Are there any disadvantages/pitfalls to computing expas ... I've noticed that computing exptakes a noticeable portion of ... computation time in my program, and was able to shave a few percentages ...
(comp.lang.fortran)