Exposing the Mathematical Wizard:

Approximating Trigonometric and Other Transcendental Functions

One of the more memorable scenes in the Wizard of Oz is when Toto draws back the curtain to expose the Wizard of Oz and Frank Morgan admits that “I am really a very good man, but just a poor wizard”. In a sense, this is reminiscent of Arthur C. Clarke’s famous Third Law [1] that “any sufficiently advanced technology is indistinguishable from magic”. For almost all of our students, the things that happen when they push the buttons on their calculators are essentially magic and the techniques employed are seemingly pure wizardry.

In this article, we will draw back the curtains to expose some of the mathematics behind the computational wizardry that turns out to be both fundamental and yet highly accessible to students at the precalculus level. At the same time, some of these mathematical ideas are truly inspirational for many students and really turn them on to the subject. And, in the process, we will show how these ideas provide a wonderful opportunity to make connections between seemingly disparate mathematical threads (such as the behavior of polynomials, the behavior of the sine and cosine, and the use of trigonometric identities and data analysis) to link them in precalculus courses. Simultaneously, we will demonstrate how these ideas provide teachers with new ways to reinforce important concepts and methods.

Actually, since all that a calculator or computer can do is to add and subtract numbers, every other operation, such as multiplication, taking the square root, and so on, necessarily involves some very clever kind of numerical scheme. So, perhaps a better image for this article might be Mickey Mouse in the Sorcerer’s Apprentice section of Disney’s Fantasia in which the naïve apprentice uses a magical spell that sets thousands of wizardly creations into action. However, we focus on just one such mathematical wizard here; several future articles may expose some of the others lurking behind other curtains on a calculator.

In particular, we will consider the notion of how one approximates a function, typically a transcendental function such as the sine or the cosine, with a simpler function, usually a polynomial, to allow us to calculate values of the original function. Consider the function y = sin x. In reality, there are only a miniscule number of values for x for which one can calculate values exactly – in fact, only for integer multiples of 30 and 45 and, if one is willing to apply the half-angle identity, for 30/2n and for 45/2n, for any positive integer n. However, if you are asked to calculate the value for sin 29 instead of sin 30, it is not possible to do exactly. The only game in town is to approximate this value. For instance, you might argue that since the sine function is increasing in the neighborhood of 29, the value must be somewhat less than sin 30 = 0.5, say something like 0.48 or 0.49 as an educated guess. Alternatively, you could use a calculator to find that sin 29 0.4848096202, but this is only an approximation that is accurate to 10 decimal places. And, if your students ever think about it, the techniques used to get this approximation are, as Clarke said, indistinguishable from magic.

Throughout this article, unless specifically mentioned, we work with radian measure. The methods developed do not apply directly in degree measurement without making some appropriate adjustments involving the fact that π radians = 180.

Approximating the Sine Function

We begin by looking at the sine function and, in particular, its behavior very close to the origin, as shown in Figure 1, where we have zoomed in repeatedly. This portion of the graph looks remarkably like a straight line rather than a part of a sine curve. In fact, if you zoom in sufficiently on any smooth curve, it will eventually look like a straight line.

Let's find the equation of this seeming"line". Because it passes through the origin, the vertical intercept must be 0. To find the slope, we either trace along the sine curve very close to the origin or use the Value option on a TI-84 graphing calculator, for instance, to find that (0.001, 0.0009999998) is a point on the curve. The slope of the line through this point and the origin is 0.9999998  1 and so y = x is a line that very closely hugs the sine curve near x = 0. We show the graph of this line, along with the sine curve, in Figure 2. Clearly, when x is very close to 0, the graphs of y = sin x and y = x are virtually indistinguishable. This is true from about x = -0.5 to x = 0.5. That is,

sin x ≈ x, when x is very close to 0.

For instance, if x = 0.001234, which is quite close to the origin, then we would approximate the value of sin(0.001234), which is 0.0012339997, with

sin(0.001234)  0.001234.

Thus, this approximation is accurate to six decimal places. On the other hand, if we take x = 0.0789, then we would estimate that sin (0.0789)  0.0789 compared to the actual value of sin (0.0789) = 0.078818164, so this approximation is only accurate to three decimal places. Also, we asked above about the value of sin 29. This is actually quite close to sin ½ in radians (½ radian  28.648) and we will use sin ½ as a target throughout this article. The linear approximation then gives sin ½  0.5 compared to the calculator’s approximated value of 0.4794255, so it is fairly inaccurate.

x / sin x / Approximation / Difference
sin x - x
-0.50
-0.20
-0.10
-0.05
-0.01
0.00
0.01
0.05
0.10
0.20
0.50

The reason that the accuracy diminishes as the value of x gets farther from 0 can be seen from Figure 3 where x extends from x = -2 to x = 2 and you can obviously see the first pair of turning points on the sine curve while the line continues to extend in a linear pattern. Thus, the further that x is from 0, the more that the sine curve bends away from the line y = x. You can dramatize this important point with students by asking them to construct a table of sample values for x and the corresponding entries for sin x, the linear approximation sin xx, and the error in the approximation, which is the difference sin x – x between the actual value and the approximate value. We show the possible format for this activity in Table 1.

Before going on, a comment is in order. While the theme of this article is illustrating the mathematical techniques used to calculator values of the common transcendental functions, we do cite the results of a calculator as giving the “correct” value to the number of decimal places displayed, for the sine and the cosine. Clearly, these “correct” values are also approximations, but the key notion is to demonstrate where such approximations come from.

Using Linear RegressionWe presume that linear, as well as non-linear regression, has been treated in extensive detail both in previous courses and earlier in the precalculus course we are discussing in this article. In mathematics classrooms, linear regression is typically applied to find the line that is the best fit, in the least squares sense, to sets of real-world data. However, the technique can also be applied to find the line that best fits “mathematical data”. In particular, as illustrated in Figure 4, the regression line is the unique line that has the property that the sum of the squares of the vertical distances between the line and the data points is a minimum. Although the equation y = ax + b of this least squares line is usually proved based on techniques of multivariate calculus, it can also be derived [2] using only precalculus-level mathematics having to do with locating the vertex of a quadratic function, which leads to a system of two linear equations in the parameters a and b. (The authors believe that students should be exposed to such an argument, if not the full derivation, so that another piece of seeming mathematical wizardry is exposed to view to make mathematics a more transparent subject.)

We now use linear regression to create a linear function that approximates the sine function near x = 0. To do this, we selecta set of points that lie on the sine curve that are very close to the origin. One such set of values, rounded to 6 decimal places, is shown in Table 2, though the calculations were done using the calculator’s values for sin (-0.025), sin (-0.020), …rather than the values -0.024997, -0.019999, … cited in Table 2. The line that best fits these "data" is y = 0.999926xwith a correlation coefficient r = 1.000000000, which tells us that a line with slope of about 1 is a virtually perfect fit. So, once again, we find that

sin x  x,

when x is very close to the origin. The “catch”, of course, is the phrase “very close” and we will discuss this below.

x / -0.025 / -0.02 / -0.015 / -0.01 / -0.005 / 0 / 0.005 / 0.01 / 0.015 / 0.02 / 0.025
y = sin x / -0.024997 / -0.019999 / -0.014999 / -0.01000 / -0.005000 / 0 / 0.005000 / 0.01000 / 0.014999 / 0.019999 / 0.024997

We note that the results obtained from this kind of investigation are extremely sensitive to the choice of the values for x. If you take other values, particularly values that are further away from the origin, or a different number of points, the results may change quite dramatically. Moreover, both in this case and in others that will arise later in this article when we are interested in approximating the sine function over a wider interval centered at the origin, we focus on points that are very close to the origin. The approximation formulas we construct here are all “centered” at the origin and work well only if we stay sufficiently close to x = 0. Moreover, although we avoid calculus here, the best approximation formulas centered at the origin are the Taylor polynomial approximations, we aim to construct approximations that are close to, if not precisely the same, as the Taylor polynomials.

Improving on the Linear Approximation to the Sine Unfortunately, the linear approximation sin x ≈x to the sine curve is only accurate if x is very close to the origin, roughly fromx = -0.5 to x = 0.5. Moreover, this interval is based on only a visual inspection, which in turn depends on the choice of the viewing window. We can also formalize the notion of how well one function matches another on an interval to something more analytic rather than graphical, but will not go into that here.

Let's see how we can improve on this linear approximation sin x ≈ x when x is somewhat farther from 0. In Figure 1, we zoomed in on the sine curve very close to the origin (from x = -0.3 to x = 0.3), so that the curve looked like a line. Now we zoom out a bit to see what happens for values of x from - 3.5 to 3.5, as shown in Figure 5. This portion of the sine curve has two turning points and one obvious inflection point (although there are two other inflection points at x = , but we will ignore them for now), so the overall shape suggests a cubic polynomial with a negative leading coefficient. This observation suggests that we try to approximate this portion of the sine curve with a cubic curve rather than a linear function. (Of course, if you zoom out a bit farther, more turning points appear and the cubic-like appearance disappears.) A discussion at the precalculus level of how calculators and software fit polynomials to sets of data, a process called polynomial regression, is presented in [3]; a somewhat more sophisticated discussion using calculus is in [5]. In general, the idea is to extend the least-squares notion to find the parabola or higher degree polynomial curve that comes closest to all of the data points, as illustrated in Figure 6.

We again use the data in Table 2 to fit a cubic polynomial instead and get

y = -0.1666601 x3 + 0 x2 + 0.999999999 x + 0.

Note that

(1) the constant term is 0, which assures us that the cubic passes through the origin;

(2) the coefficient of the linear term is essentially 1;

(3) the coefficient of the quadratic term is 0;

(4) the leading coefficient is negative, which is what we should expect because this portion of the sine curve ends up decreasing to the right; and

(5) the value of the leading coefficient, -0.1666601, is quite close to -1/6 = -0.16666667. Thus a cubic polynomial that can be used to approximate the sine function is

y = T3(x) = -x3/6 + x

so that

sin x  x – x3/6

when x is fairly close to 0. We use the notation T3(x) here to suggest that this is actually a Taylor polynomial of degree 3.

Figure 7 shows both the sine curve (dashed) and this cubic polynomial (solid) for x from -3.5 to 3.5. Note that the two curves are indistinguishable from about x = -1.2 to x = 1.2, which is a considerably larger interval than the one for the linear approximation, which is accurate only from about x = -0.5 to x = 0.5. So, the cubic polynomial provides a good approximation over a considerably wider interval centered at the origin.

To check the accuracy of this cubic approximation to sin x for values of x near 0, we consider, for example, x = 0.125, and find that

sin(0.125)  (0.125) - (0.125)3/6

= 0.124674479,

which agrees to six decimal places with the calculator’s value of sin(0.125) = 0.124674733. If we move farther from x = 0 and try our target x = ½ instead, we find that

sin(½)  (½) - (½)3/6 = 0.47916667,

compared to the actual value of sin(½) = 0.4794255. This is correct to three decimal places, so the approximation is still fairly accurate. However, we know that eventually the two curves will separate as the cubic shoots off to ±∞ and the sine function continues its oscillations. We suggest that you encourage your students to perform such investigations both graphically and numerically to drive home this key point. In particular, we would suggest asking the students to extend Table 1 to include columns for both this cubic approximation and the associated differences.

Can we improve on the approximation further so that we would be able to estimate values for sin x when x is still farther from the origin? Consider the graph of the sine curve from x = -6 to x = 6 shown in Figure 8. This portion of the curve has four turning points and three inflection points, which suggests a polynomial of degree 5 with a positive leading coefficient. Although graphing calculators don't fit a fifth degree polynomial to a set of data, that task can be accomplished by many software packages. Using a spreadsheet such as Excel (details on how to do this are shown in the Appendix), we find that a fifth degree polynomial that fits the data in Table 2 is

T5(x)= 0.0083 x5 + 0 x4- 0.1667 x3+ 0 x2 + 0.999999999x + 0,

or essentially,

T5(x)= 0.0083 x5 - x3/6+ x.

Because the leading coefficient 0.0083  1/120, we can write this polynomial as

T5(x)= x5/120 - x3/6 + x

or, if we reverse the order of the terms,

T5(x)= x - x3/6 + x5/120.

Note that this fifth degree polynomial has a positive leading coefficient, so it increases toward the right, as we want. It also has a 0 constant coefficient, so it passes through the origin. Note also that the only change from the cubic polynomial T3(x)= x - x3/6 to this fifth degree polynomial T5(x)= x - x3/6 + x5/120 is the fifth degree term – all other terms remain the same.

Using this polynomial, we can now write

sin x  x - x3/6 + x5/120.

We show the graphs of the sine function and this fifth degree polynomial approximation from x = -4 to x = 4 in Figure 9 and observe that they match very closely over a reasonably large interval. In fact, this fifth degree approximation to the sine function is better than the cubic approximation

sin x  x – x3/6

because we get more accurate estimates for the values of sin x over a considerably larger interval of x-valuescentered at 0. From Figure 9, we estimate that the two curves are indistinguishable from about x = -2 to x = 2, so we have achieved a considerable improvement over the cubic approximation, which was a good match for x between roughly x = -1.2 and x = 1.2. To illustrate this improvement, we again consider our target value of x = ½ and now estimate that

sin ½  ½ - (½)3/6 + (½)5/120 = 0.47942708

compared to the correct value of 0.47943554, so we now have four decimal place accuracy.

You can see the basic ideas most clearly in Figure 10, where we show the graph of the sine function along with the graphs of the three approximating polynomials (the linear, the cubic, and the 5th degree) we have created. As the degree of the approximating polynomial increases, it is evident that the successive polynomials hug the sine curve ever more closely over larger and larger intervals centered at the origin. Furthermore, if you look at the figure, it makes sense that, in order to improve on the fifth degree polynomial T5(x)that rises up from -∞ on the left and rises toward +∞ on the right, we would need a higher degree polynomial with a negative leading coefficient that would “pull” the fifth degree polynomial up toward the left and down toward the right. That is, we would need a 7thdegree polynomial where the additional term has a negative leading coefficient to adjust the 5th degree polynomial so as to hug the sine curve over a larger interval.

Moreover, we again suggest having students create a table similar to Table 1 that includes columns for both the fifth degree approximation and the associated differences. In the process of performing these investigations personally, the students should begin to grasp the following two fundamental facts about approximating functions with polynomials:

  1. For each approximation, the further you move from the “center” point, the poorer the approximation is.
  2. To compare successive approximations, the higher the degree of the polynomial, the more accurate the approximation is.

Patterns in the Approximation Formulas Consider the three approximation formulas we have developed so far:

sin x  x,

sin x  x - x3/6

sin x  x - x3/6 + x5/120.

There is a fairly recognizable pattern for the coefficients 1, 6 and 120 in these three formulas; they are simply 1!, 3!, and 5!, respectively, so we can rewrite the approximation formulas for the sine function as

sin x  x

sin x  x – x3/3!

sin x  x - x3/3! + x5/5!.

Notice the following facts about the above approximation formulas:

1. Each successive polynomial involves just one additional term, compared to the preceding polynomial.

2. Each polynomial involves only odd powers.

3. The signs of the successive coefficients alternate between positive and negative.

4. The coefficient of x2n+1 is 1/(2n+1)! for each positive integer value of n.

These observations allow us to construct still higher degree polynomial approximations to the sine function that give greater accuracy and that match the sine function well over larger intervals of values for x. For instance, you would likely expect that the next higher degree polynomial approximation will be