1 /* $OpenBSD: s_casinf.c,v 1.3 2011/07/20 19:28:33 martynas Exp $ */
3 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * Complex circular arc sine
35 * Inverse complex sine:
38 * w = -i clog( iz + csqrt( 1 - z ) ).
44 * arithmetic domain # trials peak rms
45 * IEEE -10,+10 30000 1.1e-5 1.5e-6
46 * Larger relative error can be observed for z near zero.
54 casinf(float complex z
)
58 float complex ca
, ct
, zz
, z2
;
61 static float a, b, s, t, u, v, y2;
70 w
= (float)M_PI_2
+ 0.0f
* I
;
71 /*mtherr( "casinf", DOMAIN );*/
74 w
= asinf (x
) + 0.0f
* I
;
79 /* Power series expansion */
83 z2.r = (x - y) * (x + y);
93 ct.r = z2.r * ca.r - z2.i * ca.i;
94 ct.i = z2.r * ca.i + z2.i * ca.r;
108 b = fabsf(ct.r) + fabsf(ct.i);
119 ct
= ca
* I
; /* iz */
121 /* cmul( &ca, &ca, &zz ) */
123 zz
= (x
- y
) * (x
+ y
) + (2.0f
* x
* y
) * I
;
124 zz
= 1.0f
- crealf(zz
) - cimagf(zz
) * I
;
129 /* multiply by 1/i = -i */
130 w
= zz
* (-1.0f
* I
);