mirror of
https://gitlab.com/rnger/amath
synced 2026-10-16 04:26:24 +00:00
267 lines
6.4 KiB
Plaintext
267 lines
6.4 KiB
Plaintext
.TH "lib/real/acos.c" 3 "Tue Jan 24 2017" "Version 1.6.2" "amath" \" -*- nroff -*-
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
lib/real/acos.c \-
|
|
.SH SYNOPSIS
|
|
.br
|
|
.PP
|
|
\fC#include 'prim\&.h'\fP
|
|
.br
|
|
\fC#include 'math\&.h'\fP
|
|
.br
|
|
|
|
.SS "Functions"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "double \fBacos\fP (double x)"
|
|
.br
|
|
.RI "\fIInverse trigonometric cosine function\&. \fP"
|
|
.in -1c
|
|
.SS "Variables"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "static const double \fBone\fP = 1\&.00000000000000000000e+00"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpi\fP = 3\&.14159265358979311600e+00"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpio2_hi\fP = 1\&.57079632679489655800e+00"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpio2_lo\fP = 6\&.12323399573676603587e\-17"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpS0\fP = 1\&.66666666666666657415e\-01"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpS1\fP = \-3\&.25565818622400915405e\-01"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpS2\fP = 2\&.01212532134862925881e\-01"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpS3\fP = \-4\&.00555345006794114027e\-02"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpS4\fP = 7\&.91534994289814532176e\-04"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBpS5\fP = 3\&.47933107596021167570e\-05"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBqS1\fP = \-2\&.40339491173441421878e+00"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBqS2\fP = 2\&.02094576023350569471e+00"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBqS3\fP = \-6\&.88283971605453293030e\-01"
|
|
.br
|
|
.ti -1c
|
|
.RI "static const double \fBqS4\fP = 7\&.70381505559019352791e\-02"
|
|
.br
|
|
.in -1c
|
|
.SH "Function Documentation"
|
|
.PP
|
|
.SS "double acos (double x)"
|
|
|
|
.PP
|
|
Inverse trigonometric cosine function\&.
|
|
.PP
|
|
\fBVersion:\fP
|
|
.RS 4
|
|
1\&.3
|
|
.RE
|
|
.PP
|
|
\fBDate:\fP
|
|
.RS 4
|
|
95/01/18
|
|
.RE
|
|
.PP
|
|
.PP
|
|
.nf
|
|
|
|
Method :
|
|
acos(x) = pi/2 - asin(x)
|
|
acos(-x) = pi/2 + asin(x)
|
|
For |x|<=0\&.5
|
|
acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see \fBasin\&.c\fP)
|
|
For x>0\&.5
|
|
acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
|
|
= 2asin(sqrt((1-x)/2))
|
|
= 2s + 2s*z*R(z) \&.\&.\&.z=(1-x)/2, s=sqrt(z)
|
|
= 2f + (2c + 2s*z*R(z))
|
|
where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
|
|
for f so that f+c ~ sqrt(z)\&.
|
|
For x<-0\&.5
|
|
acos(x) = pi - 2asin(sqrt((1-|x|)/2))
|
|
= pi - 0\&.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
Special cases:
|
|
if x is NaN, return x itself;
|
|
if |x|>1, return NaN with invalid signal\&.
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
Function needed: sqrt
|
|
.fi
|
|
.PP
|
|
|
|
.PP
|
|
\fBCopyright:\fP
|
|
.RS 4
|
|
Copyright (C) 1993 by Sun Microsystems, Inc\&. All rights reserved\&. Developed at SunSoft, a Sun Microsystems, Inc\&. business\&. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved\&.
|
|
.RE
|
|
.PP
|
|
|
|
.PP
|
|
Definition at line 96 of file acos\&.c\&.
|
|
.PP
|
|
References one, pi, pio2_hi, pio2_lo, pS0, pS1, pS2, pS3, pS4, pS5, qS1, qS2, qS3, qS4, and sqrt()\&.
|
|
.PP
|
|
Referenced by RealNumber::ArcCosine(), and RealNumber::ArcSecant()\&.
|
|
.PP
|
|
.nf
|
|
97 {
|
|
98 double z,p,q,r,w,s,c,df;
|
|
99 sword hx,ix;
|
|
100 GET_HIGH_WORD(hx,x);
|
|
101 ix = hx&0x7fffffff;
|
|
102 if(ix>=0x3ff00000) { /* |x| >= 1 */
|
|
103 sword lx;
|
|
104 GET_LOW_WORD(lx,x);
|
|
105 if(((ix-0x3ff00000)|lx)==0) { /* |x|==1 */
|
|
106 if(hx>0) return 0\&.0; /* acos(1) = 0 */
|
|
107 else return pi+2\&.0*pio2_lo; /* acos(-1)= pi */
|
|
108 }
|
|
109 return (x-x)/(x-x); /* acos(|x|>1) is NaN */
|
|
110 }
|
|
111 if(ix<0x3fe00000) { /* |x| < 0\&.5 */
|
|
112 if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
|
|
113 z = x*x;
|
|
114 p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
|
|
115 q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
|
|
116 r = p/q;
|
|
117 return pio2_hi - (x - (pio2_lo-x*r));
|
|
118 } else if (hx<0) { /* x < -0\&.5 */
|
|
119 z = (one+x)*0\&.5;
|
|
120 p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
|
|
121 q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
|
|
122 s = sqrt(z);
|
|
123 r = p/q;
|
|
124 w = r*s-pio2_lo;
|
|
125 return pi - 2\&.0*(s+w);
|
|
126 } else { /* x > 0\&.5 */
|
|
127 z = (one-x)*0\&.5;
|
|
128 s = sqrt(z);
|
|
129 df = s;
|
|
130 SET_LOW_WORD(df,0);
|
|
131 c = (z-df*df)/(s+df);
|
|
132 p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
|
|
133 q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
|
|
134 r = p/q;
|
|
135 w = r*s+c;
|
|
136 return 2\&.0*(df+w);
|
|
137 }
|
|
138 }
|
|
.fi
|
|
.SH "Variable Documentation"
|
|
.PP
|
|
.SS "const double one = 1\&.00000000000000000000e+00\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 48 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pi = 3\&.14159265358979311600e+00\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 49 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pio2_hi = 1\&.57079632679489655800e+00\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 50 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pio2_lo = 6\&.12323399573676603587e\-17\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 51 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pS0 = 1\&.66666666666666657415e\-01\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 52 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pS1 = \-3\&.25565818622400915405e\-01\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 53 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pS2 = 2\&.01212532134862925881e\-01\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 54 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pS3 = \-4\&.00555345006794114027e\-02\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 55 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pS4 = 7\&.91534994289814532176e\-04\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 56 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double pS5 = 3\&.47933107596021167570e\-05\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 57 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double qS1 = \-2\&.40339491173441421878e+00\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 58 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double qS2 = 2\&.02094576023350569471e+00\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 59 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double qS3 = \-6\&.88283971605453293030e\-01\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 60 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SS "const double qS4 = 7\&.70381505559019352791e\-02\fC [static]\fP"
|
|
|
|
.PP
|
|
Definition at line 61 of file acos\&.c\&.
|
|
.PP
|
|
Referenced by acos()\&.
|
|
.SH "Author"
|
|
.PP
|
|
Generated automatically by Doxygen for amath from the source code\&.
|