The following are notes from my program Extra Precision Floating-Point Calculator XPCalc:

Transcendental Function Evaluation -

All transcendental functions, Sin(x), Cos(x), Tan(x), Cot(x), Sec(x), Csc(x), ASin(x), ACos(x), ATan(x), ATan2(y, x), ACot(x), ASec(x), ACsc(x), Exp(x), ExpL(x), Pow(x, y), Ln(x), LnL(x), LogB(b, x), Log(x), Sinh(x), Cosh(x), Tanh(x), Coth(x), Sech(x), Csch(x), ASinh(x), ACosh(x), ATanh(x), ACoth(x), ASech(x), and ACsch(x), when they are evaluated, ends up using one of the four basic transcendental functions, Sin(x), ATan(x), ExpL(x), and LnL(x). The methods used by these four functions are quite similar: 1) For F(x), reduce the given argument x to a related argument f. 2) Further reduce f, NN times in a recursive loop to produce an argument g much smaller than f. 3) Evaluate the Taylor series for the argument g. 4) Reconstruct F(f) from F(g) by a recursive process executed NN times. 5) Reconstruct the desired function value F(x) from F(f).

The number NN in steps 2) and 4) is computed by a heuristic equation of the form NN = a + b * SqRt(M) where a and b are constants and M is the current max decimal digits in a mantissa. The best value of NN is the value that produces the smallest total execution time. After step 4) a best value of NN is computed and output by estimating a value of NN that would have made the running time of step 3) equal the sum of the running time of steps 2) and 4). Best NN = NN * SqRt(T3 / (T2 + T4)). Where Tn is the time to execute step n). This equation is based on T2 and T4 being proportional to NN and T3 being inversely proportional to NN.

If the operator wants to control the value on NN, he can enter a value on the list for item MSinNN, MATanNN, MExpLNN, MLnLNN to control the value used for NN in the Sin(x), ATan(x), ExpL(x), and LnL(x) functions respectively.

The recursive method used to reduce the argument for Sin(x) is based on the equation: Sin(x) = Sin(x/3) * (3 - 4 * Sq(Sin(x/3))). In step 2) f is divided by 3, NN times to produce g. In step 4) the recursion: S = S * (3 - 4 * Sq(S)), is performed NN times, where S is initially the value of Sin(g) produced in step 3) and the final value is Sin(f).

The recursive method used to reduce the argument for ATan(x) is based on the equation: Tan(x/2) = Tan(x) / (1 + SqRt(1+Sq(Tan(x))). In step 2) the recursion: T = T / (1 + SqRt(1 + Sq(T))), is performed NN times, where T is initially the value of f from step 1) and the final value of T is the value of g for step 3). In step 4) the angle value, A = ATan(g), produced in step 3) is multiplied by 2, NN times to produce ATan(f).

The recursive method used to reduce the argument for ExpL(x) is based on the equation: Exp(x) = Sq(Exp(x/2). In step 2) f is divided by 2, NN times to produce g. In step 4) the recursion: a = a * (2 + a), is performed NN times, where a is initially the value of ExpL(g) produced in step 3) and the final value is ExpL(f). The recursion a = a * (2 + a) is equivalent to, but more accurate than, the recursion e = Sq(e), where e = a + 1; The recursive method used to reduce the argument for LnL(y) is based on the equation: Ln(x) = 2 * Ln(SqRt(x)). In step 2) the recursion: y = y / (1 + SqRt(1 + y)), is performed NN times, where y is initially the value of f from step 1) and the final value of y is the value of g for step 3). In step 4) the log value L = LnL(g) produced in step 3) is multiplied by 2, NN times to produce LnL(f). The recursion y = y / (1 + SqRt(1 + y)) is equivalent to, but more accurate than, the recursion x = SqRt(x), where y = x - 1;

If the diagnostic mode is on, the values computed for NN in the four subroutines MSin, MATan, MExpL, and MLnL are displayed, for example, as:

In this example the MExpL subroutine estimated NN to be 22.299. A value of NN = 21 was actually used (this is not 22 because the number being worked on was less than 3, the base number used to generate the heuristic equation). Based on the actual timing of the run, the best value for NN is computed to be 21.935. Due to the uncertainty of the timing, the Best NN could be off by + or - 1.633.

The Taylor series used for Sin(x) is:

The Taylor series used for ATan(x) is:

The Taylor series used for ExpL(x) is:

The Taylor series used for LnL(y) is:

Other equations used to produce the transcendental functions:

Return to Number Theory, Algorithms, and Real Functions

Return to Harry's Home Page

This page accessed times since Feb 16, 2006.

Page created by: hjsmithh@sbcglobal.net

Changes last made on Monday, 06-Aug-07 20:47:34 PDT