public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* Wrong formulae for complex elementary functions
@ 2010-11-26  8:57 Richard B. Kreckel
       [not found] ` <4CEF7677.30500-HEL5OUoDxoc@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Richard B. Kreckel @ 2010-11-26  8:57 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-man-u79uwXL29TY76Z2rM5mHXA, Andreas Enge, Bill Allombert,
	Karim Belabas

Hi!

The man pages for cacos, cacosf, cacosl, catan, catanf, catanl, cacosh, 
cacoshf, cacoshl, catanh, catanhf, and catanhl contain wrong maths.

cacos, cacosf, cacosl:
   The formula given in the man page
     cacos(z) = -i clog(z + csqrt(z * z - 1))
   gives wrong results in second and fourth quadrant of complex plain.
   The formula
     cacos(z) = -i clog(z + I*csqrt(1 - z * z))
   gives correct results.

catan, catanf, catanl:
   The formula given in the man page
     catan(z) = 1 / 2i clog((1 + iz) / (1 - iz))
   gives wrong results on the negative imaginary axis beginning at -I
   (along one of the two branch cuts). Besides, the formula is written
   in an ambiguous way.
   The formula
     catan(z) = (clog(1 + iz) - clog(1 - iz)) / 2i
   gives correct results.

cacosh, cacoshf, cacoshl:
   The formula given in the man page
     cacosh(z) = (0.5) * clog((1 + z) / (1 - z))
   gives wrong results everywhere in the complex plain. (The formula
   seems to be copied from the one for catanh, where it is sometimes
   correct.)
   The formula
     cacosh(z) = 2 * clog(csqrt((z + 1)/2) + csqrt((z - 1)/2))
   gives correct results.

catanh, catanhf, catanhl:
   The formula given in the man page
     catanh(z) = 0.5 * clog((1 + z) / (1 - z))
   gives wrong results on the positive real axis beginning at 1 (along
   one of the two branch cuts).
   The formula
     catanh(z) = 0.5 * (clog(1 + z) - clog(1 - z))
   gives correct results.

I've also checked casin, casinf, casinl, casinh, casinhf, and casinhl 
and the formulae given there
     casin(z) = -i clog(iz + csqrt(1 - z * z))
     casinh(z) = clog(z + csqrt(z * z + 1))
are actually correct.

I suspect that some of these errors are due to somebody trying to 
"simplify" these formulae. Since this can ruin the behavior, I recommend 
to add a comment to the upstream sources that warns against attempt of 
simplification.

For the sake of reference, I am looking at manpages-dev 3.25-1 on 
Debian/squeeze.

Bye!
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-09-16  9:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26  8:57 Wrong formulae for complex elementary functions Richard B. Kreckel
     [not found] ` <4CEF7677.30500-HEL5OUoDxoc@public.gmane.org>
2010-11-27  7:37   ` Michael Kerrisk
     [not found]     ` <AANLkTinAUyVTdjxY9KVgnOerWxhXtnvmHeTQ-Gb0-TxC-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-05 21:34       ` Richard B. Kreckel
     [not found]         ` <4E3C61FE.1010107-HEL5OUoDxoc@public.gmane.org>
2011-09-15  4:31           ` Michael Kerrisk
     [not found]             ` <CAKgNAkjamtuK95ouh6+zsCS1dHiZO0-1q72GpN0CSaFk9XxWqg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-15  8:34               ` Richard B. Kreckel
2011-09-15 18:38               ` Michael Kerrisk
     [not found]                 ` <CAKgNAkiv7-FL95p2D_80EaRTxhbwDOTun7N_uSsPr2e71Cz8EA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-15 21:42                   ` Richard B. Kreckel
     [not found]                     ` <4E727152.2060503-HEL5OUoDxoc@public.gmane.org>
2011-09-16  6:05                       ` Michael Kerrisk
     [not found]                         ` <CAKgNAkgHrLgk+QBs0jnWXavj5PLBPhaLO=33tgQxAwTUyFhzwg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-16  9:45                           ` D. Barbier
2011-09-15 16:24           ` Andries E. Brouwer
2011-09-15 18:36             ` Michael Kerrisk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox