Math 272: Polynomial Interpolation (Curve Fitting)
Names:

Make sure your name appears at the top of the file. Upload completed labs to Moodle: 
https://lms.ats.amherst.edu/mod/assign/view.php?id=302543
If you finish this lab before the end of class, let me know so I can briefly check it over and then you will be free to go.

Here is how to enter a matrix into Mathematica (put cursor on line below and hit shift-enter):

A={{1,2,3,5},{2,3,4,6},{4,5,7,1}}

This is hard to read, so use the MatrixForm command to see the matrix in the usual form:

A //MatrixForm

We can have Mathematica do the Gaussian elimination for us via the RowReduce command, with two different options for the syntax:

RowReduce[A]//MatrixForm

A//RowReduce//MatrixForm

Suppose you ran two parallel experiments and recorded levels of something every hour for the 5 hours following the start of the experiment:

({{Time, 1hr, 2hr, 3hr, 4hr, 5hr}, {Experiment 1, 3, 4, 2, 6, 7}, {Experiment 2, 2, 3, 2, 6, 8}})

Let's find polynomials that interpolate each set of data and compare them.  We have 5 data points for each experiment, which means that we will be able to fit a fourth order polynomial: (Subscript[a, 1])+(Subscript[a, 2])t+(Subscript[a, 3])(t^2)+(Subscript[a, 4])(t^3)+(Subscript[a, 5])(t^4).

The observation at t=1hr in Experiment 1 leads to the equation (Subscript[a, 1])+(Subscript[a, 2])+(Subscript[a, 3])+(Subscript[a, 4])+(Subscript[a, 5])=3 (plugged in t=1).  Plugging in t=2, 3, 4, 5 will lead to a system of 5 linear equations.

t=1;a1+a2*t+a3*t^2+a4*t^3+a5*t^4==3

Exercise 1.  Determine the system of five equations in 5 unknowns for fitting a fourth order polynomial to the Experiment 1 data.

Exercise 2.  Rewrite this linear system as an augmented matrix.

Observe that the coefficient matrix will have rows consisting of increasing powers of each time t:

(({{({{1}, {1}})({{(Subscript[t, 1])}, {(Subscript[t, 2])}}), ({{(Subscript[t, 1]^2), (Subscript[t, 1]^3)}, {(Subscript[t, 2]^2), (Subscript[t, 2]^3)}})}, {, }})({{({{(Subscript[t, 1]^4)}, {(Subscript[t, 2]^4)}})}, {}}))

A matrix with this pattern is called a Vandermonde matrix.  Alexandre-Theophile Vandermonde lived in Paris in the eighteenth century and made contributions to both music and mathematics, although no one knows of any connection of his to the matrix that bears his name (seems to have been a mistake!).  The website  http://www-history.mcs.st-andrews.ac.uk/Biographies/Vandermonde.html has an interesting tidbit about Vandermonde:

In 1778 Vandermonde presented the first of a two part work on the theory of music to the Académie des Sciences. The second part was presented two years later. This work Système d'harmonie applicable à l'état actuel de la musique did not propose a mathematical theory of music as one might have expected from someone who was an expert in both fields. On the contrary the aim of the work was to put forward the idea that musicians should ignore all theory of music and rely solely on their trained ears when judging music. As one might expect this proved a controversial work with musicians being sharply divided as to whether they agreed with Vandermonde or not. Despite the opposition of many musicians at first, the ideas put forward by Vandermonde gained favour over the years and by the beginning of the nineteenth century the Académie des Sciences had moved music from the mathematical area to the arts area. It is worth repeating that it is strange that a mathematician of the highest rank should have argued against music as a mathematical art, a position it had held since the days of ancient Greece.

Okay, back to work!

Exercise 3.  Solve the linear system using the RowReduce[A] command, where A is your augmented matrix.

Exercise 4.  The solution in Exercise 3 consists of the coefficients for the polynomial for Experiment 1.  Plot this polynomial (recall the Plot command from Lab#1: Plot[f,{t,0,5}]).

Exercise 5.  Update your augmented matrix to find the interpolating polynomial for Experiment 2.

Exercise 6.  Plot both polynomials on the same set of axes for t from 0 to 5 hours.

Now suppose we also want to specify the slope of the curve, as well as what point it passes through (as we did above).

Exercise 7.  Find the fourth order polynomial (Subscript[a, 1])+(Subscript[a, 2])t+(Subscript[a, 3])(t^2)+(Subscript[a, 4])(t^3)+(Subscript[a, 5])(t^4) whose graph passes through points (0,0), (1,1), and (-1,3), and whose slope at t= -1 is 20 and whose slope at t=1 is 9. Do this by first finding a linear system of 5 equations and then solving for the coefficients. Plot your resulting polynomial on the interval [-1,1].

Exercise 8.  Design a ski jump with the following specifications: The ski jump starts at a height of 100 feet and ends at a height of 10 feet above the ground. From start to finish, the ski jump covers a horizontal distance of 120 feet. A skier using the jump will start off horizontally and will fly off the end at a 30 degree angle up from the horizontal.  Find a polynomial whose graph is a side view of the ski jump, and then plot that polynomial. (Exercise adapted from ATLAST by S. Leon, E. Herman, and R. Faulkenberry.)