27 Polynomials for approximating functions
Almost all readers of this book will have studied mathematics previously. Those who reached secondary school very likely spent considerable time factoring polynomials, sometimes called “finding the roots.” Many students still remember the “quadratic formula” from high school, which will find applications later in this book.
Students and their instructors often struggle to explain what non-textbook problems are solved with factoring polynomials. There are uncountable numbers of posts on the internet addressing the question, many of which refer to the “beauty” of algebra, its benefits in learning logical thinking, and then kick the can down the road by saying that it is crucial to understanding calculus and other mathematical topics at the college level.
You have already seen in Chapter 12 how low-order polynomials provide a framework for arranging our intuitive understanding of real-world settings into quick mathematical models of those settings, for instance, in Application area 26.1 on modeling the speed of a bicycle as a function of steepness of the road and the gear selected for pedaling.
Calculus textbooks have for generations described using polynomials for better theoretical understanding of functions. This author, like many, was so extensively trained in the algebraic use of polynomials that it is practically impossible to ascertain the extent to which they are genuinely useful in developing understanding of the uses of math. It seems wise to follow tradition and include mention of classical textbook problems in this book. That’s one goal of this chapter. But it’s common for polynomials to be used for modeling problems for which they are poorly suited, and even to focus on aspects of functions such as higher-order derivatives, that get in the way of productive work.
27.1 Hundreds of years ago ….
Fifteen-hundred years ago, the Indian mathematician Brahmagupta (c. 598 – c. 668 CE) published what is credited as the first clear statement of the quadratic theorem. Clear perhaps to scholars of ancient mathematics and its unfamiliar notation, but not to the general modern reader.
Brahmagupta’s text also include the earliest known use of zero as a number in its own right, as opposed to being a placeholder in other numbers. He published rules for arithmetic with zero and negative numbers that will be familiar to most (perhaps all) readers of this book. However, his comments on division by zero, for instance that
Much earlier records from Babylonian clay tablets show that mathematicians were factoring quadratics as long ago as 2000-1600 BC.
In the 15th and 16th century CE, mathematicians such as Scipione del Ferro and Niccolò Tartaglia were stars of royal competitions in factoring polynomials. Such competitions were one way for mathematicians to secure support from wealthy patrons. The competitive environment encouraged mathematicians to keep their findings secret, a attitude which was common up until the late 1600s when Enlightenment scholars came to value the sort of open publication which is a defining element of science today. Young Isaac Newton was elected a fellow of the newly founded Royal Society—full name: the Royal Society of London for Improving Natural Knowledge—in 1672 and was president from 1703 until his death a quarter century later.
This is a long and proud history for polynomials, perhaps in itself justifying their placement near the center of the high-school curriculum. It’s easy to see the strong motivation mathematicians would have in the early years of calculus to apply their new tools to understanding polynomials and, later, functions. The importance of polynomials to mathematical culture is signaled by the distinguished name given to the proof that an nth-order polynomial has exactly n roots: the Fundamental theorem of algebra.
As for factoring polynomials, in the 1500s mathematicians found formulas for roots of third- and fourth-order polynomials. Today, they are mainly historical artifacts since the arithmetic involved is subject to catastrophic round-off error. By 1824, the formulas-for-factoring road came to a dead end when it was proved that fifth- and higher-order polynomials do not have general solutions written only using square roots or other radicals.
27.2 A warning for modelers
Later in this chapter, we’ll return to address classical mathematical problems using polynomials. This section is about the pitfalls of using third- and higher-order polynomials in constructing models of real-world settings. (As mentioned previously, low-order polynomials are a different matter. See Chapter 12.)
Building a reliable model with high-order polynomials requires a deep knowledge of mathematics and introduces serious potential pitfalls. Modern professional modelers learn the alternatives to high-order polynomials (for example, “natural splines” and “radial basis functions”), but newcomers often draw on their high school experience and give unwarranted credence to polynomials.
The domain of polynomials, like the power-law functions they are assembled from, is the real numbers, that is, the entire number line
To understand the shape of high-order polynomials, it is helpful to divide the domain into three parts: a wiggly domain at the center and two tail domains, one on the right side and the other on the left.
Figure 27.1 shows a 7th order polynomial—that is, the highest-order term is
In contrast, for even-order polynomials (2, 4, 6, …) the function values in the two tail domains go in the same direction, either to
Polynomials’ runaway behavior does not provide insurance against wild, misleading extrapolations of model formulas. Instead, sigmoid, Gaussian, and sinusoid functions, as well as more modern constructions such as “smoothers,” “natural splines,” and the “wavelets” originating in fractal theory, provide such insurance.
27.3 Indeterminate forms
Let’s return to an issue that has bedeviled mathematicians for millennia and misled even the famous Brahmagupta. This is the question of dividing zero by zero or, more generally, dividing any number by zero.
Elementary-school students learn that it is illegal to “divide by zero.” Happily, the punishment for breaking the law is, for most students, a deep red mark on a homework or exam paper. Much more serious consequences, however, can sometimes occur, especially in computer programming. (See Section 27.4.)
There is a legal loophole, however, that arises in functions like
The sinc() function (pronounced “sink”) is important today, in part because of its role in converting discrete-time measurements (as in an mp3 recording of sound into continuous signals. So there really are occasions that call for evaluating it at zero input.
What is the value of
On the other hand,
Still another answer is suggested by plotting out sinc(
To judge from the output of Active R chunk 27.1,
The graph of sinc() looks smooth and the shape makes sense. Even if we zoom in very close to
Compare the well-behaved sinc() to a very closely related function (which does not seem to be so important in applied work):
Both
Active R chunk 27.2 zooms in around the division by zero. Top: The graph of
Since both
Since we are interested in behavior near
near is already a polynomial. is already a polynomial.
As we will see in Section 27.6 , these approximations are exact as
Compare this to the polynomial approximation to
Evaluating this at
The procedure for checking whether a function involving division by zero behaves well or poorly is described in the first-ever calculus textbook, published in 1697. The title (in English) is: The analysis into the infinitely small for the understanding of curved lines. In honor of the author, the Marquis de l’Hospital, the procedure is called l’Hôpital’s rule.1
Conventionally, the relationship is written
Let’s try this out with our two example functions around
A careless author who states simply that
27.4 Computing with indeterminate forms
In the early days of electronic computers, division by zero would cause a fault in the computer, often signaled by stopping the calculation and printing an error message to some display. This was inconvenient since programmers did not always foresee and avoid division-by-zero situations.
As you’ve seen, modern computers have adopted a convention that simplifies programming considerably. Instead of stopping the calculation, the computer just carries on normally, but produces as a result one of two indeterminate forms: Inf
and NaN
.
Inf
is the output for the simple case of dividing zero into a non-zero number, for instance:
NaN
, standing for “not a number,” is the output for more challenging cases: dividing zero into zero, multiplying Inf
by zero, or dividing Inf
by Inf
.
The idea’s brilliance is that any calculation that involves NaN
will return a value of NaN
. This might seem to get us nowhere. However, most programs are built out of other programs, usually written by people interested in different applications. You can use those programs (mostly) without worrying about the implications of a divide by zero. If it is important to respond in some particular way, you can always check the result for being NaN
in your own programs. (Much the same is true for Inf
, although dividing a non-Inf
number by Inf
will return 0.)
Plotting software will often treat NaN
values as “don’t plot this.” that is why it is possible to make a sensible plot of
27.5 Multiple inputs?
High-order polynomials are rarely used with multiple inputs. One reason is the proliferation of coefficients. For instance, here is the third-order polynomial in two inputs,
This has 10 coefficients. With so many coefficients it is hard to ascribe meaning to any of them individually. And, insofar as some feature of the function does carry meaning in the modeling situation, that meaning is spread out and hard to quantify.
27.6 High-order approximations
Despite the pitfalls of high-order polynomials, they are dear to theoretical mathematicians. In particular, mathematicians find benefits to approximating known functions by high-order polynomials.
The applied student might wonder, what is the point of approximating known functions. If we know the function, why approximate? One good reason is to simplify calculations. For instance, suppose you need the value of the pattern-book function
Another important fact about
Let’s differentiate both sides. The right-hand side is easy:
It’s easy to differentiate power-law functions like
In other words, we know a lot about
For polynomials, the output can be calculated using just multiplication and addition, which makes them attractive for numerical evaluation. As well we can differentiate to any order any polynomial. And, with a bit of practice, we can write down a polynomial whose derivative is a given number at some input value. Once we have learned how to do this, we can, for instance, write down a polynomial that shares the value and derivatives of
The significance of this fact is that we can write a polynomial approximation to any function whose value and derivatives can be evaluated, if only at a single input value like
To illustrate, consider another pattern-book function,
Consider this polynomial:
Our example polynomial,
It is clear from the graph that the approximation is excellent near
One way to measure the quality of the approximation is the error
Figure 27.3 shows that for
That the graph of
The inevitable consequence of
Throughout this book, we’ve been using straight-line approximations to functions around an input
Start with a general, second-order polynomial centered around
To make
Now we can explain where the polynomial that started this section,
Order | ||
---|---|---|
0 | ||
1 | ||
2 | ||
3 | ||
4 |
The first four derivatives of
The polynomial constructed by matching successive derivatives of a function
Let’s construct a 3rd-order Taylor polynomial approximation to
We know it will be a 3rd order polynomial:
The function value and derivatives of
Result: the 3rd-order Taylor polynomial approximation to the exponential at
Figure 27.4 shows the exponential function
The polynomial is exact at
The plot of