Computing exponentials and Trig functions

Paul Zimmermann Paul.Zimmermann at
Thu Dec 6 17:55:53 CET 2007

> Date: Thu, 06 Dec 2007 08:28:57 -0800
> From: mr.janus at
> Hello,
> I'm trying to write a program in C using GMP as matlab is unable to handle the precision i need for solving my coupled equations accurately. However, one of the many problems i'm having is how to speed up the calculation of trig functions.
> I often have to solve complex exponentials but the way i have coded it is painfully slow. I split the exponential into the real and imaginary parts and solve separately. I then solve using sin, cos, sinh, and cosh identities.
> However the slowdown problem arises from my calculation of the trigonometric functions, which i do by Taylor expansion. Obviously, as I push the precision the Taylor expansion takes longer and longer to converge to the required precision. How does everyone else do this?
> Many thanks
> Huw
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

Dear Huw,

one solution would be to use software tools that already implement the
exponential and trigonometric functions, for example mpfr ( for
real numbers, or mpc (
for complex numbers.

The page compares timings obtained
with several tools.

Paul Zimmermann

More information about the gmp-discuss mailing list