1*05a0b428SJohn Marino /* $OpenBSD: s_cacos.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */
2*05a0b428SJohn Marino /*
3*05a0b428SJohn Marino * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
4*05a0b428SJohn Marino *
5*05a0b428SJohn Marino * Permission to use, copy, modify, and distribute this software for any
6*05a0b428SJohn Marino * purpose with or without fee is hereby granted, provided that the above
7*05a0b428SJohn Marino * copyright notice and this permission notice appear in all copies.
8*05a0b428SJohn Marino *
9*05a0b428SJohn Marino * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*05a0b428SJohn Marino * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*05a0b428SJohn Marino * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*05a0b428SJohn Marino * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*05a0b428SJohn Marino * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*05a0b428SJohn Marino * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*05a0b428SJohn Marino * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*05a0b428SJohn Marino */
17*05a0b428SJohn Marino
18*05a0b428SJohn Marino /* cacos()
19*05a0b428SJohn Marino *
20*05a0b428SJohn Marino * Complex circular arc cosine
21*05a0b428SJohn Marino *
22*05a0b428SJohn Marino *
23*05a0b428SJohn Marino *
24*05a0b428SJohn Marino * SYNOPSIS:
25*05a0b428SJohn Marino *
26*05a0b428SJohn Marino * double complex cacos();
27*05a0b428SJohn Marino * double complex z, w;
28*05a0b428SJohn Marino *
29*05a0b428SJohn Marino * w = cacos (z);
30*05a0b428SJohn Marino *
31*05a0b428SJohn Marino *
32*05a0b428SJohn Marino *
33*05a0b428SJohn Marino * DESCRIPTION:
34*05a0b428SJohn Marino *
35*05a0b428SJohn Marino *
36*05a0b428SJohn Marino * w = arccos z = PI/2 - arcsin z.
37*05a0b428SJohn Marino *
38*05a0b428SJohn Marino *
39*05a0b428SJohn Marino *
40*05a0b428SJohn Marino *
41*05a0b428SJohn Marino * ACCURACY:
42*05a0b428SJohn Marino *
43*05a0b428SJohn Marino * Relative error:
44*05a0b428SJohn Marino * arithmetic domain # trials peak rms
45*05a0b428SJohn Marino * DEC -10,+10 5200 1.6e-15 2.8e-16
46*05a0b428SJohn Marino * IEEE -10,+10 30000 1.8e-14 2.2e-15
47*05a0b428SJohn Marino */
48*05a0b428SJohn Marino
49*05a0b428SJohn Marino #include <complex.h>
50*05a0b428SJohn Marino #include <float.h>
51*05a0b428SJohn Marino #include <math.h>
52*05a0b428SJohn Marino
53*05a0b428SJohn Marino double complex
cacos(double complex z)54*05a0b428SJohn Marino cacos(double complex z)
55*05a0b428SJohn Marino {
56*05a0b428SJohn Marino double complex w;
57*05a0b428SJohn Marino
58*05a0b428SJohn Marino w = casin (z);
59*05a0b428SJohn Marino w = (M_PI_2 - creal (w)) - cimag (w) * I;
60*05a0b428SJohn Marino return (w);
61*05a0b428SJohn Marino }
62*05a0b428SJohn Marino
63*05a0b428SJohn Marino #if LDBL_MANT_DIG == DBL_MANT_DIG
64*05a0b428SJohn Marino __strong_alias(cacosl, cacos);
65*05a0b428SJohn Marino #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
66