mirror of
https://gitlab.com/rnger/amath
synced 2026-10-15 12:06:03 +00:00
141 lines
2.9 KiB
Plaintext
141 lines
2.9 KiB
Plaintext
.TH "lib/real/cos.c" 3 "Tue Jan 24 2017" "Version 1.6.2" "amath" \" -*- nroff -*-
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
lib/real/cos.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 \fBcos\fP (double x)"
|
|
.br
|
|
.RI "\fITrigonometric cosine function\&. \fP"
|
|
.in -1c
|
|
.SH "Function Documentation"
|
|
.PP
|
|
.SS "double cos (double x)"
|
|
|
|
.PP
|
|
Trigonometric cosine function\&.
|
|
.PP
|
|
\fBVersion:\fP
|
|
.RS 4
|
|
1\&.3
|
|
.RE
|
|
.PP
|
|
\fBDate:\fP
|
|
.RS 4
|
|
95/01/18
|
|
.RE
|
|
.PP
|
|
.PP
|
|
.nf
|
|
|
|
Return cosine function of x\&.
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
kernel function:
|
|
__kernel_sin \&.\&.\&. sine function on [-pi/4,pi/4]
|
|
__kernel_cos \&.\&.\&. cosine function on [-pi/4,pi/4]
|
|
rem_pio2 \&.\&.\&. argument reduction routine
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
Method\&.
|
|
Let S,C and T denote the sin, cos and tan respectively on
|
|
[-PI/4, +PI/4]\&. Reduce the argument x to y1+y2 = x-k*pi/2
|
|
in [-pi/4 , +pi/4], and let n = k mod 4\&.
|
|
We have
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
n sin(x) cos(x) tan(x)
|
|
----------------------------------------------------------
|
|
0 S C T
|
|
1 C -S -1/T
|
|
2 -S -C T
|
|
3 -C S -1/T
|
|
----------------------------------------------------------
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
Special cases:
|
|
Let trig be any of sin, cos, or tan\&.
|
|
trig(+-INF) is NaN, with signals;
|
|
trig(NaN) is that NaN;
|
|
.fi
|
|
.PP
|
|
.PP
|
|
.PP
|
|
.nf
|
|
Accuracy:
|
|
TRIG(x) returns trig(x) nearly rounded
|
|
.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 87 of file cos\&.c\&.
|
|
.PP
|
|
References __kernel_cos(), __kernel_sin(), and rempio2()\&.
|
|
.PP
|
|
Referenced by cchc(), ccos(), ccosh(), ccot(), ccoth(), ccsc(), ccsch(), cexp(), RealNumber::Cosine(), cpow(), csec(), csech(), csin(), csinh(), ctan(), ctanh(), and RealNumber::Secant()\&.
|
|
.PP
|
|
.nf
|
|
88 {
|
|
89 double y[2],z=0\&.0;
|
|
90 sword n, ix;
|
|
91
|
|
92 /* High word of x\&. */
|
|
93 GET_HIGH_WORD(ix,x);
|
|
94
|
|
95 /* |x| ~< pi/4 */
|
|
96 ix &= 0x7fffffff;
|
|
97 if(ix <= 0x3fe921fb) return __kernel_cos(x,z);
|
|
98
|
|
99 /* cos(Inf or NaN) is NaN */
|
|
100 else if (ix>=0x7ff00000) return x-x;
|
|
101
|
|
102 /* argument reduction needed */
|
|
103 else {
|
|
104 n = rempio2(x,y);
|
|
105 switch(n&3) {
|
|
106 case 0:
|
|
107 return __kernel_cos(y[0],y[1]);
|
|
108 case 1:
|
|
109 return -__kernel_sin(y[0],y[1],1);
|
|
110 case 2:
|
|
111 return -__kernel_cos(y[0],y[1]);
|
|
112 default:
|
|
113 return __kernel_sin(y[0],y[1],1);
|
|
114 }
|
|
115 }
|
|
116 }
|
|
.fi
|
|
.SH "Author"
|
|
.PP
|
|
Generated automatically by Doxygen for amath from the source code\&.
|