Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2012 23:12:02 -0000
From:      Stephen Montgomery-Smith <stephen@missouri.edu>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        Diane Bruce <db@db.net>, John Baldwin <jhb@freebsd.org>, David Chisnall <theraven@freebsd.org>, Bruce Evans <bde@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, David Schultz <das@freebsd.org>, Peter Jeremy <peter@rulingia.com>, Warner Losh <imp@bsdimp.com>
Subject:   Re: Use of C99 extra long double math functions after r236148
Message-ID:  <500C563D.9000605@missouri.edu>
Resent-Message-ID: <20120812231154.GP20453@server.rulingia.com>
In-Reply-To: <20120722172119.GA83243@troutmask.apl.washington.edu>
References:  <20120720184114.B2790@besplex.bde.org> <50097128.6030405@missouri.edu> <20120721032448.X5744@besplex.bde.org> <5009BD6C.9050301@missouri.edu> <20120721123522.T877@besplex.bde.org> <500A2565.9090009@missouri.edu> <20120721181204.A1702@besplex.bde.org> <500B594D.1020305@missouri.edu> <20120722125300.P2246@besplex.bde.org> <500C1B1A.5070107@missouri.edu> <20120722172119.GA83243@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 07/22/2012 12:21 PM, Steve Kargl wrote:
> On Sun, Jul 22, 2012 at 10:24:10AM -0500, Stephen Montgomery-Smith wrote:
>>
>> mpfr is OK, but terribly cludgy.
>
> I almost chocked on my coffee reading this statement.
>
>> Having it compute clog is easy.  But
>> having it computing casinh is going to be very painful.  If I cannot use
>> pari, I will probably use C++ code based around a floating point package
>> called cln.  It is used in GiNaC, which is a rather cool way of
>> embedding symbolic expressions inside C++ code.  They are both available
>> in the ports.
>
> I you looked at MPC?  http://www.multiprecision.org/index.php?prog=mpc
>>From the MPC manual:
>
> 4.6 Branch Cuts And Special Values
>
> Some complex functions have branch cuts, across which the function is
> discontinous.  In GNU MPC, the branch cuts chosen are the same as those
> specified for the corresponding functions in the ISO C99 standard.
>
> Likewise, when evaluated at a point whose real or imaginary part is
> either infinite or a NaN or a signed zero, a function returns the same
> value as those specified for the corresponding function in the ISO C99
> standard.
>
> 5.9 Trigonometric Functions
>
> - Function: int mpc_asinh (mpc_t rop, mpc_t op, mpc_rnd_t rnd)
> - Function: int mpc_acosh (mpc_t rop, mpc_t op, mpc_rnd_t rnd)
> - Function: int mpc_atanh (mpc_t rop, mpc_t op, mpc_rnd_t rnd)
>
> Set rop to the inverse hyperbolic sine, inverse hyperbolic cosine, inverse
> hyperbolic tangent of op, rounded according to rnd with the precision of
> rop. The branch cut of mpc_acosh is (-\infty, 1).
>


Oops, my apologies.  Reading the manuals and the literature has always 
been my biggest weakness.  I have this unfortunate tendency to keep 
reinventing the wheel.  (It does slow you down, but you also understand 
things a lot better!)

I will try out these mpc_asinh, etc functions.

Incidentally, I did find a few edge cases when my program actually beat 
Mathematica!  (I know I was correct, and not Mathematica, by looking at 
power series expansions.)  It was things like I + 1e-200.  So if they 
disagree, I might check to see if it is mpc or my program that is correct.

The real difficulty with casinh and cacosh is not the computation of 
clog, but the calculation of z+csqrt(z*z+1)-1.  It is very hard when z 
is close to I or -I.  The paper by Hull et al really does an excellent 
job of handling the special cases.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?500C563D.9000605>