






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Here we address the problem of evaluating a function for a given argument. Consider the function F(X) to be evaluated at the value X = X 0.
The first topic to cover is that of polynomial functions. By this, we mean a standard polynomial with a finite number of terms. A polynomial of degree N over the argument X is defined to be of the form F(X) = ANX N
Here we consider a subset of the non–linear functions that are not polynomials. The method to be discussed next applies to those real functions of real numbers that are both continuous and analytic in the mathematical sense. In general, none of these functions can be directly evaluated using only the primitive operations available on a stored–program computer. What are the basic mathematical operations available on a modern computer? There are only four: addition, subtraction, multiplication, and division. Some modern computers do not have direct implementations of division, but rather support an inverse function; Y/X = Y * (1/X). The functions that we now discuss can be represented as infinite series. Each term in the infinite series can be evaluated using only multiplication and division. The terms can be combined with addition and subtraction. The primary issue here is termination. How does the algorithm terminate? For polynomials, we just evaluate all of the terms. This is not an option here.
As examples, let us discuss the following functions Trigonometric functions: Sine and cosine Exponential functions: E X and E –X . Logarithmic functions: The natural logarithm. The methods used are based on series expansions obtained from calculus. Sin(X) = X – (X 3 /3!) + (X 5 /5!) – (X 7 /7!) + (X 9 /9!) – … = X – (X 3 /6) + (X 5 /120) – (X 7 /5040) + (X 9 /362,880) – … Cos(X) = 1 – (X 2 /2!) + (X 4 /4!) – (X 6 /6!) + (X 8 /8!) – … = 1 – (X 2 /2) + (X 4 /24) – (X 6 /720) + (X 8 /40320) – … Exp(X) = 1 + X + (X 2 /2!) + (X 3 /3!) + (X 4 /4!) + (X 5 /5!) + … Exp(–X) = 1 – X + (X 2 /2!) – (X 3 /3!) + (X 4 /4!) – (X 5 /5!) + … Ln(1 + X) = X – (X 2 / 2) + (X 3 / 3) – (X 4 / 4) + (X 5 / 5) – , –1 < X 1. But note that each series is infinite. How do we know how many terms to evaluate to get the precision we need?
Each term in the series expansion of sine, cosine, and exponential is of the form X N / N!. Let us first consider the trigonometric functions.
the series before the term (X N
N / N!
N
24 ). How many terms do we need?
N / N! < 2 N / N! < (1/ 24 ), which becomes 2 (N+24) < N!. I have to do this by inspection (trial and error) N = 20 2 44 1.756 10 13 20! = 2.433 10 18 N is too big. N = 12 2 36 6.872 10 10 12! = 4.790 10 8 N is too small N = 16 2 40 1.100 10 12 16! = 2.093 10 13 N is too big N = 14 2 38 2.749 10 11 14! = 8.718 10 10 N is too small N = 15 2 39 5.498 10 11 15! = 1.308 10 11 N is too small The choice is the 16 th power, it is the first value of N for which 2 (N+24) < N!.
As a result of the above calculations, we have concluded that the following series expansions suffice for the sine and cosine under the assumption of single precision. Sin(X) = X – (X 3 /3!) + (X 5 /5!) – (X 7 /7!)
24 ) 5.96 10