CS229 Project #1: Mathematica

Due: Wednesday, September 22, 1999, 11:59 pm


Goals

You should have two goals for this project:

Mathematica

To get started in Mathematica from any Sun in the CS department: Read through the "Tour of Mathematica" to try out some of the features available. Good things to learn about are: Hints:

The Assignment

Now for the actual assignment...

Mathematica has a spline fitting program that creates C1 continuity spines with the second derivative zero at the two extreme endpoints. Find the discussion and example by searching in the Master Index for "SplineFit". Work through the example, creating a spline from just the first three points given: {0,0},{1,2},{-1,3}.

Plot the spline as shown in the example. (Note that with only three points it is valid only over the range 0-2.)

Recall that a natural cubic spline is a C2 continuous spline with second derivative zero at the endpoints. Set up and solve the equations for a natural cubic spline that interpolates the same three points: {0,0},{1,2},{-1,3}. Don't worry about efficiency, just set up a huge matrix equation and solve it using Mathematica. (LinearSolve will do the dirty work here; if you don't remember how this works from linear algebra, you should read the documentation on LUSolve).

Hint: You will need to compute two natural cubic splines: one for x and one for y. Each will have two cubic segments, say u1 and u2 for x; v1 and v2 for y.

Now plot your spline along with that created by Mathematica.

Hint:Assuming you have solved the equations to define u1, u2, v1, and v2, you can then plot the spline in x-y space using a call such as the following:

All segments (u1, u2, v1, and v2) must be defined over the correct range (0 - 1 for u1 and v1; 1 - 2 for u2 and v2) to make this work properly; otherwise, the two curves will overlap unattractively (unlike SplineFit's plot). This is unfortunate, but not hard to deal with. (If you know a better way to make this plot, please post to the newsgroup).

Questions:


Handing it in..

Things to hand in:


Nancy Pollard