Files
amath/doc/man/man3/cbrt.c.3
T
2017-01-24 22:03:15 +01:00

170 lines
3.8 KiB
Plaintext

.TH "lib/real/cbrt.c" 3 "Tue Jan 24 2017" "Version 1.6.2" "amath" \" -*- nroff -*-
.ad l
.nh
.SH NAME
lib/real/cbrt.c \-
.SH SYNOPSIS
.br
.PP
\fC#include 'prim\&.h'\fP
.br
.SS "Functions"
.in +1c
.ti -1c
.RI "double \fBcbrt\fP (double x)"
.br
.RI "\fICube root function\&. \fP"
.in -1c
.SS "Variables"
.in +1c
.ti -1c
.RI "static const unsigned \fBB1\fP = 715094163"
.br
.ti -1c
.RI "static const unsigned \fBB2\fP = 696219795"
.br
.ti -1c
.RI "static const double \fBC\fP = 5\&.42857142857142815906e\-01"
.br
.ti -1c
.RI "static const double \fBD\fP = \-7\&.05306122448979611050e\-01"
.br
.ti -1c
.RI "static const double \fBE\fP = 1\&.41428571428571436819e+00"
.br
.ti -1c
.RI "static const double \fBF\fP = 1\&.60714285714285720630e+00"
.br
.ti -1c
.RI "static const double \fBG\fP = 3\&.57142857142857150787e\-01"
.br
.in -1c
.SH "Function Documentation"
.PP
.SS "double cbrt (double x)"
.PP
Cube root function\&.
.PP
\fBVersion:\fP
.RS 4
1\&.3
.RE
.PP
\fBDate:\fP
.RS 4
95/01/18
.RE
.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 67 of file cbrt\&.c\&.
.PP
References B1, B2, C, D, E, F, and G\&.
.PP
.nf
68 {
69 sword hx, lx, ht;
70 double r,s,t=0\&.0,w;
71 uword sign;
72
73 GET_HIGH_WORD(hx,x); /* high word of x */
74 sign=hx&0x80000000; /* sign= sign(x) */
75 hx ^=sign;
76 if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
77 GET_LOW_WORD(lx, x);
78 if((hx|lx)==0)
79 return(x); /* cbrt(0) is itself */
80
81 SET_HIGH_WORD(x,hx); /* x <- |x| */
82 /* rough cbrt to 5 bits */
83 if(hx<0x00100000) /* subnormal number */
84 {
85 SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */
86 t*=x;
87 GET_HIGH_WORD(ht,t);
88 SET_HIGH_WORD(t,ht/3+B2);
89 }
90 else
91 SET_HIGH_WORD(t,hx/3+B1);
92
93 /* new cbrt to 23 bits, may be implemented in single precision */
94 r=t*t/x;
95 s=C+r*t;
96 t*=G+F/(s+E+D/s);
97
98 /* chopped to 20 bits and make it larger than cbrt(x) */
99 SET_LOW_WORD(t,0);
100 GET_HIGH_WORD(ht,t);
101 SET_HIGH_WORD(t,ht + 0x00000001);
102
103 /* one step newton iteration to 53 bits with error less than 0\&.667 ulps */
104 s=t*t; /* t*t is exact */
105 r=x/s;
106 w=t+t;
107 r=(r-t)/(w+r); /* r-s is exact */
108 t=t+t*r;
109
110 /* retore the sign bit */
111 GET_HIGH_WORD(ht,t);
112 SET_HIGH_WORD(t,ht|sign);
113
114 return(t);
115 }
.fi
.SH "Variable Documentation"
.PP
.SS "const unsigned B1 = 715094163\fC [static]\fP"
.PP
Definition at line 47 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SS "const unsigned B2 = 696219795\fC [static]\fP"
.PP
Definition at line 48 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SS "const double C = 5\&.42857142857142815906e\-01\fC [static]\fP"
.PP
Definition at line 51 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SS "const double D = \-7\&.05306122448979611050e\-01\fC [static]\fP"
.PP
Definition at line 52 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SS "const double E = 1\&.41428571428571436819e+00\fC [static]\fP"
.PP
Definition at line 53 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SS "const double F = 1\&.60714285714285720630e+00\fC [static]\fP"
.PP
Definition at line 54 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SS "const double G = 3\&.57142857142857150787e\-01\fC [static]\fP"
.PP
Definition at line 55 of file cbrt\&.c\&.
.PP
Referenced by cbrt()\&.
.SH "Author"
.PP
Generated automatically by Doxygen for amath from the source code\&.