Interpolation Polynomials

For the sake of convenience in reading this document, the applet window should be moved to the right half of the screen, and the two windows should be resized so that they do not overlap.

When the applet is first run you will get a screen called "Polynomial Interpolation", the one to your right. It is a large version of the picture below .

The column entitled "x y values" represents five points in the plane: (-2, 2), (-1, 1), (0, -1), (1, -1), and (2,0). When you click the "Process" button the applet will construct and graph a fourth degree polynomial going through these five points:

The "Display Points" toggles the display of the listed points. If you click on it, the points on the graph will be removed; if you click on it again the points will return.

The fourth degree polynomial constructed by the program is

p1(x) = -1-1.5 x + 1.333 x^2 + .5 x^3 -.333 x^4

It is displayed in the panel at the bottom of the screen. The coefficients are displayed to three decimal places, but trailing 0's are not displayed. That is,-1.150 is written out as -1.15.

If the coefficients of the polynomial are very large (> 1000) then they are written out using the Ek notation for powers of 10: 1532 = 1.532 E3; a negative k is employed for small numbers, 0.001020 = 1.02E-3.

The panel directly above the polynomial displays the x and y values of the mouse pointer when it is on the graphing screen.

The numbers -2 and 2 at the bottom of the graphing screen are the minimum and maximum x values plotted. The values -2 and 1.17 at the left side of the graph are the minimum and maximum of the polynomial on the domain [-2, 2]. The E notation is also used here for large and small numbers.

The graphs of this program can be pasted into other documents, e.g., Word. To do so place the mouse on the applet screen and press Alt-PrintScreen. This places the screen into the clipboard; it can then be pasted into the other document.

General Ideas

Generally speaking, given n points in the plane , where are n distinct numbers, then , the interpolating polynomial for these n points is the function of the form

such that

The general ideas about these polynomials are given in Lagrange Interpolation.

Clearing the Screen

The screen to the right can be "cleared" by first marking and deleting all the numbers in the list of (x, y) values. This is done in the usual way, for the column is a text field and all the usual word- processor commands can be executed in it. After it is cleared, press the "Process" button; this clears the screen.

Inputting Polynomials by the Keyboard

New polynomials are entered by first clearing the screen, typing in one pair of numbers per line in the "x y values" column, and then pressing "Process". For example, clear the (x,y) list and then enter:

Notice that the values can be typed in any order; they need not be entered with the x values in increasing order. The program arrange the points so that the x values are in increasing order. Now, click on the process button; you will get a parabola going through (-1, 1), (0,0) and (1,1):

There are two rules of syntax you must heed when entering values:

Numbers must be separated by at least one blank. You can, if you like, use several blanks as separators.

You cannot use commas or other symbols as separators.

Using the Mouse to Enter Points

To use the mouse to enter points move the pointer to the screen and click it. The mouse location will then be added to end of the list of "x y values". Once you have added all the points you wish, enter click on the process button to display the graph. If you clear the screen before you start clicking, your polynomial will pass through the points you entered.

If you do not clear beforehand, the points you click in will be added to the points already listed.

You may use any mix of keyboard and mouse commands to construct a list of (x,y) values.

Points can be deleted from the graphs by deleting then from the list of (x, y) values. The deletion does not appear on the graph until the process key is pressed.

Graphing two or more polynomials simultaneously

To see how to graph several polynomials at the same time, click on the "Examples" menu at the top, left of the applet screen, click on "Parabolic Arches", and then, press the process button. A graph of four arches will appear.

Looking at the (x,y) listing you will see three appearances of the word "next", which is used as a signal to stop the construction of one polynomial and begin the construction of another. In this case we begin with a parabola, and then translate it to the right three times.

The four different polynomials constructed for this graph are displayed at the bottom of the screen. You will have to scroll down to see the third and the fourth.

The colors used for the different graphs are blue, orange, violet, and rose. If you graph five or more polynomials the colors will cycle through this sequence.

Note also that if you use the mouse to click in points, the values are added to the end of the list. Thus, if you do not add a "next", the values you click in will be added to the last set of values in the list.

Caution: If you are working with a text window and the applet window at the same time you might, in the process of using the mouse to move from one window to the other, inadvertently click on the graphing window of the applet. This will add a point to the list of (x, y) values and produce a strange graph. So, if your graph has a unexpected form, scroll down the list of (x, y) values and check to see what is there.


Example 1

Go to "Examples" , and click in and process "Arches, 4th Degree".

The graphs you get here differ from the parabolic arches in that two extra points have been added to the definition of each polynomial, making them polynomials of the fourth degree. The extra point for each graph, as you can see, alters the shape of the arch.

Test your knowledge of calculus: Looking at the definition of p1(x) and its graph, determine how roots there are to the equation d(p1(x))/dx = 0. Then do the same for the remaining three polynomials.

Example 2

Go to "Examples", click in and process "Leaf".

Recall that a polynomial p(x) is a function of x: for each x in the domain there is exactly one associated value p(x). Thus the leaf-like figure in the graph is not the graph of a single polynomial; it was formed by pasting two polynomials together, using the "next" command.

Problem: Draw a "stem" to the leaf at its lower, left corner.

Example 3

Go to "Examples", click in "Primitive Polynomial Art" and then process, and toggle the "Display Points" button to get this happy face:

Problem: By changing one, single point in the list of (x, y) values change happy face to a sad face.

Example 4

This program was written under the assumption that the user would enter two numbers on each line of the (x, y) list to define a point in the plane. To see what can happen if this is not done load the "Parabolic Arches" in "Examples" and then delete the last 0 from each group of points defining an arch. That is delete the 0s in the third, seventh, eleventh, and fifteenth lines. Then process.

The following has occurred: The first five numbers in the (x, y) list

have been replaced by the points (0, 0), (1, 1) and (0, 0); the graph is the straight line from the point (0,0) to (1,1) and back to (0,0).

The next five numbers

have been replaced by the points (2, 0 ), (3, 1) and (0, 0). The graph is the parabola from the point (0,0) to (2,0) and (3,1). (Remember, the points are arranged so that the x values are in increasing order.)

A similar change occurs in the last two parabolas.

Example 5

As another example of the behavior exhibited in Example 4, load the "Leaf" in "Examples".

Delete the 1 in the first row, the 8 in the sixth row, and then process.

Studying what has happened one sees that the first set of values

have been grouped into three points (0,1), (2,2), and (4,3) and appear as the blue line in the graph. The last 8 has been ignored.

The second set of values

have been arranged as points (3,2), (6.5, 1) (5, 0) plus the point (1,0). The extra 1 in this case spawned the point at (0, 0).

In short, if the (x, y) list does not contain two numbers on each line, between "next"s, then the program groups all the numbers into pairs according to the order in which they were entered. If there is a number leftover after this grouping then the it may be ignored or it may be converted to the point (0,0). The precise action the program takes is a rather complicated function of the number of polynomials being graphed and the position of the "missing" numbers.

THE MORAL: Be sure that each point is defined by two numbers on each line!

An Amusement: Load examples, delete numbers in the (x,y) list at random; see what you get

Example 6

In this example we begin by loading Examples|Triangular Frame, which is a picture of three triangles. The inner and outer

triangles form a frame; the inner one is a guide to the center. The object is to construct a polynomial that starts at (0, 0), ends at (2,0), and stays within the frame. The file "Examples| Triangular Frame, part 2" gives an example of such a polynomial

Looking at an enlarged picture of this last graph, you may not be convinced that the polynomial stays within the frame. If not, you can get a more convincing picture by changing the 0.5 and 0.5 in the (x,y) list to 0.6 and 1.4 and the 1.5 and 0.5 to 1.4 and 0.6.

You might also think of the polynomial as "snaking" along the middle line and ask if you could get a "better fit" by adding more points to the definition of the polynomial. Try adding 0.8 and 0.8 as one point and 1.2 and 0.8 as another to see what happens.

Example 7

You try it. Load " Examples|Frame Problem"

and then find a polynomial that starts at (0,0), ends at (3, 1.5), and stays within the frame.