Professional Documents
Culture Documents
Topics
Mathematics: polynomial interpolation; divided dierence tables. MATLAB: more practice with input and output arguments for functions; MATLABs interpolation tools; nested for loops.
Preparation
Read your lecture notes. See also Chapra and Canales account of divided dierences and polynomial interpolation (Section 8.1, pages 474486). In this lab you will work through two of their exercises about engineering applications of interpolation (Exercises 44 and 24 from Chapter 20). You will need an extra function M-le for this lab session: mypolyint.m uses divided dierences to construct an interpolation polynomial of specied degree. This M-le is available from the Sample M-les on the course webpage. Read the help for this M-le to see how to use it.
Linear interpolation
Polynomial interpolation is used to estimate function values between precise data points (Chapra and Canale, page 474). Dynamic viscosity of water () is related to temperature (T ) in the following manner. T ( C ) (103 N.s/m2 ) 0 1.787 5 1.519 10 1.307 20 1.002 30 0.7975 40 0.6529
1. How many data points are needed to construct a linear interpolation polynomial? 2. Choose the appropriate points from the above table and use linear interpolation and mypolyint.m to nd the approximate value of at T = 7.5 C . 3. Using the same points as in Question 2, plot the linear approximation you have just used, along with all the data points. (Use mypolyint.m again, but this time let xi be a vector spanning the desired plotting range.) Make sure that your plot agrees with your answer to Question 2.
MATLAB has several built-in interpolation and approximation tools. Read the help for the commands polyfit and polyval. Checkpoint: Use these commands to nd the straight line which gives the best t to the data points. Use this line to calculate an estimate for the river ow if the rainfall was 120 cm. Use the same commands to plot the straight line and the data points together.
x * * * * * *
f * * * * * *
Ai,1 =
fi+1 fi , xi+1 xi
Ai,j =
Checkpoint: Use your program to calculate the table of divided dierences for the viscosity temperature data given above.