amath
1.8.5
Simple command line calculator
|
Kernel tan function. More...
#include "prim.h"
Go to the source code of this file.
Macros | |
#define | one xxx[13] |
#define | pio4 xxx[14] |
#define | pio4lo xxx[15] |
#define | T xxx |
Functions | |
double | __kernel_tan (double x, double y, int iy) |
Kernel tan function. More... | |
Variables | |
static const double | xxx [] |
Kernel tan function.
Definition in file ktan.c.
double __kernel_tan | ( | double | x, |
double | y, | ||
int | iy | ||
) |
Kernel tan function.
Kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 Input x is assumed to be bounded by ~pi/4 in magnitude. Input y is the tail of x. Input k indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned.
Algorithm 1. Since tan(-x) = -tan(x), we need only to consider positive x. 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0. 3. tan(x) is approximated by a odd polynomial of degree 27 on [0,0.67434] 3 27 tan(x) ~ x + T1*x + ... + T13*x where|tan(x) 2 4 26 | -59.2 |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 | x |
Note: tan(x+y) = tan(x) + tan'(x)*y ~ tan(x) + (1+x*x)*y Therefore, for better accuracy in computing tan(x+y), let 3 2 2 2 2 r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) then 3 2 tan(x+y) = x + (T1*x + (x *(r+y)+y))
4. For x in [0.67434,pi/4], let y = pi/4 - x, then tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
Definition at line 108 of file ktan.c.
References fabs().
Referenced by tan().
|
static |