# C99 Complex Math Functions

Thu Aug 20 23:04:01 UTC 2009

```On Mon, Aug 17, 2009 at 04:13:19PM -0400, David Schultz wrote:
> On Sat, Aug 15, 2009, Peter Jeremy wrote:
> > Hi David,
> >
> > I've recently had a requirement for the C99 complex math functions.
> > I know you have been doing some work on implementing functions in
> > complex.h and wonder what (if any) plans you have for implementing
> > the rest of the C99 functions.
>
> Which ones do you need?
>
> They are on my todo list, but they're not a priority, and I'm
> swamped right now, so don't hold your breath!  Steve Kargle and
> Bruce Evans also have some interest in this.
>
> Many of the functions can be fudged with some simple formulas that
> you can look up.  The simple formulas work great in most cases,
> but often fail near asymptotes and for special cases (infinity,
> NaN, underflow, etc.)

In a private response to Peter, I directed him to NetBSD.  NetBSD
contains some/most(?)/all(?) of the simple formula implementations.
I sent Peter the guts of ccosh as implemented by NetBSD (the simple
formula) and the current version of ccosh that Bruce and I had written.
The netbsd version is 15 lines (excluding the license).  The bde+me
version is 91 lines (excluding license and initial comment).  To be
fair, a large portion of those 91 lines are comments of the form

/*
* cosh(+-Inf + I NaN)  = +Inf + I d(NaN).
*
* cosh(+-Inf +- I Inf) = +Inf + I dNaN.
* The sign of Inf in the result is unspecified.  Choice = always +.
* Raise the invalid floating-point exception.
*
* cosh(+-Inf + I y)   = +Inf cos(y) +- I Inf sin(y)
*/

To be more fair, most of the comments with the above form are due
to Bruce as well as the details of the implementation.

PS: yes, I'll get around to completing the commit bit stuff one of
these days.  But, for now, I need to return to a report that is
6 weeks late and 2 proposals.

--
Steve
```