complex.h math functions

Steve Kargl sgk at
Thu Sep 29 12:55:53 PDT 2005

Is it permissible to implement the complex.h math
functions in terms of functions in math.h.  For
example, if z = x + I * y, then

cos(z) = cos(x) * cosh(y) - I sin(x) * sinh(y)

This can be (naively?) implemented as

double complex
ccos(double complex z)
   double x, y;
   x = creal(z);
   y = cimag(y);
   return (cosh(y) * (cos(x) - I * sin(x) * tanh(y)));

I don't own a copy of C99, so I can't easily check
the wording of the standard.


More information about the freebsd-standards mailing list