Opened 5 years ago

Closed 5 years ago

#7291 closed Bugs (fixed)

complex atan is not the best it could be

Reported by: Stephen Montgomery-Smith <stephen@…> Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:


For complex atan, when x and y are non-negative, the following formula is rather foolproof:

atanh(z) = 0.25 * log1p(4*x / pow(|z-1|,2)) + 0.5 * I * atan2(2y, (1-x*x-y*y))

where z = x+I*y. Just handle the few special cases when you get overflow or underflow.

I have implemented a C version at

Also, email Tom Fairgrieve <tff@…>. He has an unpublished work by Hull, himself, and Tang, very similar to the work they did on the complex arcsine.

Attachments (1)

atanh-patch (5.8 KB) - added by Stephen Montgomery-Smith <stephen@…> 5 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by John Maddock

Component: Nonemath
Owner: set to John Maddock

comment:2 Changed 5 years ago by Stephen Montgomery-Smith <stephen@…>

Use this for the imaginary part: 0.5 * atan2(2y, (1-x)*(1+x)-y*y) Replacing 1-x*x by (1-x)(1+x) improves the error quite a bit when x is close to 1.

Changed 5 years ago by Stephen Montgomery-Smith <stephen@…>

Attachment: atanh-patch added

comment:3 Changed 5 years ago by Stephen Montgomery-Smith <stephen@…>

The patch I just uploaded is a diff to today's svn. It seems to work rather well.

comment:4 Changed 5 years ago by John Maddock

Resolution: fixed
Status: newclosed

(In [81624]) Lots of small patches. Update and regenerate docs. Fixes #7183. Fixes #7290. Fixes #7291. Fixes #7649. Refs #7492.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.