2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
|
2011-09-15 10:43:05 +00:00
|
|
|
.\" and Copyright (C) 2011 Michael Kerrisk <mtk.manpages@gamil.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Distributed under GPL
|
|
|
|
.\"
|
cacos.3, cacosh.3, catan.3, catanh.3: Fix formula describing function
The man pages for cacos(), cacosh(), catan(), catanh()
contain incorrect formulae describing the functions.
As reported by Richard B. Kreckel:
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.
Reported-by: Richard B. Kreckel <kreckel@ginac.de>
Reviewed-by: Andries Brouwer <Andries.Brouwer@cwi.nl>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-09-15 10:35:56 +00:00
|
|
|
.TH CACOS 3 2011-09-15 "" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
cacos, cacosf, cacosl \- complex arc cosine
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <complex.h>
|
|
|
|
.sp
|
2007-04-12 22:42:49 +00:00
|
|
|
.BI "double complex cacos(double complex " z );
|
2004-11-11 17:28:42 +00:00
|
|
|
.br
|
2007-04-12 22:42:49 +00:00
|
|
|
.BI "float complex cacosf(float complex " z );
|
2004-11-11 17:28:42 +00:00
|
|
|
.br
|
2007-04-12 22:42:49 +00:00
|
|
|
.BI "long double complex cacosl(long double complex " z );
|
2004-11-03 13:51:07 +00:00
|
|
|
.sp
|
2007-07-21 05:25:03 +00:00
|
|
|
Link with \fI\-lm\fP.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
2007-04-12 22:42:49 +00:00
|
|
|
The
|
|
|
|
.BR cacos ()
|
2007-12-24 11:27:43 +00:00
|
|
|
function calculates the complex arc cosine of
|
|
|
|
.IR z .
|
|
|
|
If \fIy\ =\ cacos(z)\fP, then \fIz\ =\ ccos(y)\fP.
|
|
|
|
The real part of
|
|
|
|
.I y
|
|
|
|
is chosen in the interval [0,pi].
|
2004-11-03 13:51:07 +00:00
|
|
|
.LP
|
2007-12-24 11:27:43 +00:00
|
|
|
One has:
|
|
|
|
.nf
|
|
|
|
|
cacos.3, cacosh.3, catan.3, catanh.3: Fix formula describing function
The man pages for cacos(), cacosh(), catan(), catanh()
contain incorrect formulae describing the functions.
As reported by Richard B. Kreckel:
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.
Reported-by: Richard B. Kreckel <kreckel@ginac.de>
Reviewed-by: Andries Brouwer <Andries.Brouwer@cwi.nl>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-09-15 10:35:56 +00:00
|
|
|
cacos(z) = \-i * clog(z + i * csqrt(1 \- z * z))
|
2007-12-24 11:27:43 +00:00
|
|
|
.fi
|
2008-08-11 17:13:47 +00:00
|
|
|
.SH VERSIONS
|
|
|
|
These functions first appeared in glibc in version 2.1.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "CONFORMING TO"
|
2008-07-15 13:39:17 +00:00
|
|
|
C99.
|
2011-09-15 10:43:05 +00:00
|
|
|
.SH EXAMPLE
|
|
|
|
.nf
|
|
|
|
/* Link with "\-lm" */
|
|
|
|
|
|
|
|
#include <complex.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
double complex z, c, f;
|
|
|
|
double complex i = I;
|
|
|
|
|
|
|
|
if (argc != 3) {
|
|
|
|
fprintf(stderr, "Usage: %s <real> <imag>\\n", argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
z = atof(argv[1]) + atof(argv[2]) * I;
|
|
|
|
|
|
|
|
c = cacos(z);
|
|
|
|
|
|
|
|
printf("cacos() = %6.3f %6.3f*i\\n", creal(c), cimag(c));
|
|
|
|
|
|
|
|
f = \-i * clog(z + i * csqrt(1 \- z * z));
|
|
|
|
|
|
|
|
printf("formula = %6.3f %6.3f*i\\n", creal(f), cimag(f));
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
.fi
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR ccos (3),
|
|
|
|
.BR clog (3),
|
2006-04-21 01:24:06 +00:00
|
|
|
.BR complex (7)
|