Professional Documents
Culture Documents
Week9 ENG1060 Lecture20
Week9 ENG1060 Lecture20
• Polynomial
Extrapolation • Introduced the basic statistics underlying Curve
• Be Careful! fitting methods including methods for quantifying
• Lecture
the ‘goodness of fit’
Summary
• Next lecture
• We looked at both linear and non-linear curve fits
2
Last Lecture
Consider you are lucky enough to be designing the
• Last lecture
aero package on a F1 car.
• Today’s Lecture
• Polynomial
Interpolation
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
• Polynomial
Interpolation
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
The floor can measure the ‘weight’ (i.e. force exerted by the car
on the floor) of the car as a function of wind velocity.
4
Last Lecture
The down force can be measured by a pressure
• Last lecture
sensitive floor in a wind tunnel.
• Today’s Lecture
• Polynomial After many tests, typical data collection may look like:
Interpolation
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
• Be Careful!
• Lecture
Summary
• Next lecture
You will already be familiar with one type: ‘line of best fit’6
Last Lecture
Or you may need an estimate of the down force for
• Last lecture
a velocity of 55 m/s even though you have not done
• Today’s Lecture
experiments at this velocity.
• Polynomial
Interpolation (i.e you need to interpolate between data points)
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
?
7
Last Lecture
Or your wind tunnel may have a maximum wind
• Last lecture
velocity of 80m/s but you need to estimate the
• Today’s Lecture
down force at 120 m/s
• Polynomial
Interpolation (i.e you need to extrapolate the data)
• Polynomial
Extrapolation
• Be Careful!
• Lecture ?
Summary
• Next lecture
8
Last Lecture
Commonly accepted method :
• Last lecture
n n For a ‘linear’ line of
• Today’s Lecture
Minimise S r e ( yi a0 a1 xi )
2
i
2
best fit (y=a0+a1x)
• Polynomial i =1 i =1
Interpolation
• Polynomial
Extrapolation Sr Sr (a0, a1 )
• Be Careful!
• Lecture
Summary
a1 a0
9
Last Lecture
In practice how do we find ao and a1 of the line of best fit;
• Last lecture
y=ao+a1x?
• Today’s Lecture
n a0 ( x i ) a1 y i
• Polynomial
Interpolation Resultant equations :
• Polynomial ( x i ) a0 ( x i2 ) a1 x i y i
Extrapolation
• Be Careful!
Using the ‘elimination of unknowns’ from last weeks lecture we arrive
• Lecture at equations for a0 and a1.
Summary
n x i y i x i y i
• Next lecture
a1 x i nx y i ny
x
2
n x i2 i
• Polynomial
Extrapolation
p1 x n p2 x n1 pn x pn 1
• Be Careful!
11
Today’s Lecture
• Last lecture • Using MATLAB for interpolations and
• Today’s Lecture
extrapolations
• Polynomial
Interpolation
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
12
Polynomial Interpolation
Curve Fitting: Polynomial Interpolation
• Last lecture
13
Polynomial Interpolation
METHOD [1]
• Last lecture
T ( o C) (kg / m 3 ) >> T = [50 100 150 200 250 300 400 500];
• Today’s Lecture
50 1.09
• Polynomial Input data
Interpolation 100 0.946
• Polynomial
150 0.835
Extrapolation 200 0.746 fit quadratic to available data
• Be Careful! 250 0.675
• Lecture 300 0.616
Summary
400 0.525
• Next lecture
500 0.457 evaluate density at T = 350
Temperature 0.55214321852500
dependence
d350 = METHOD [1] 0.5521
of air density
Suppose we need to find >> d350 = polyval(p3,350)
‘polyval’ MATLAB function allows us
at T = 350 oC to interpolate easily
0.00000260649932 -
0.00278303561004 14
Polynomial Interpolation
METHOD [2]
• Last lecture
T ( o C) (kg /m 3 ) >> T = [50 100 150 200 250 300 400 500];
• Today’s Lecture 50 1.09
• Polynomial 100 0.946 Input data
Interpolation
>> p2=polyfit(T(6:8), dens(6:8), 2)
150 0.835
• Polynomial
200 0.746 fit quadratic to T =
Extrapolation
300, 400, 500
• Be Careful! 250 0.675
• Lecture 300 0.616
Summary
400 0.525
• Next lecture 500 0.457
evaluate density at T = 350
Temperature
dependence
0.56762500000000
of air density
METHOD [2] 0.5676
Suppose we need to find d350 = QUITE DIFFERENT
at T = 350 oC METHOD [1] 0.5521
>> d350 = polyval(p2,350)
0.00000115000000 - 15
Polynomial Interpolation
• Last lecture METHOD [1] 0.5521
• Be Careful!
• Lecture
Summary
better here
16
Polynomial Interpolation
• Last lecture
Curve Fitting: Polynomial Interpolation
• Today’s Lecture
• Polynomial
Interpolation
• Polynomial
f ( x) p1x n p2 x n1 p3 x n2 pn1 x 2 pn x pn1
Extrapolation
• Be Careful!
• Lecture
Summary Polynomial interpolation:
(a) choose the order of polynomial [usually as low as possible]
• Next lecture
(b) choose the coefficients so that the polynomial passes through the
tabulated points closest to the required intermediate point
17
Polynomial Interpolation
Examples of interpolating polynomials:
(a) first-order (linear) connecting two points,
• Last lecture
(b) second-order (quadratic or parabolic) connecting three points,
• Today’s Lecture (c) third-order (cubic) connecting four points.
• Polynomial
Interpolation • linear interpolation
• Polynomial
Extrapolation • quadratic interpolation
• Be Careful!
• Lecture
Summary
• Next lecture
• cubic interpolation
18
Polynomial Extrapolation
Extrapolation: estimating values outside the range where data is available
• Last lecture
Extrapolation based on fitting a parabola through the first three known points.
• Today’s Lecture
• Polynomial
Interpolation
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
• It can go badly wrong!
19
Polynomial Extrapolation
Use of a seventh-order polynomial to make a prediction of U.S. population in 2000
• Last lecture based on data from 1920 through 1990.
• Today’s Lecture
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
Prediction!
20
Be careful with Inter/Extrapolation
• Last lecture
Oscillations
• Today’s Lecture
• although "more is better" in many contexts, it is absolutely not
• Polynomial
Interpolation
true for polynomial interpolation'.
• Polynomial
Extrapolation • one problem is that higher order polynomials tend to be ill-
conditioned. They are highly susceptible to round-off errors.
• Be Careful!
They are also very sensitive to changes in the values of the
• Lecture coefficients
Summary
21
Be careful with Inter/Extrapolation
Comparison of Runge’s function (dashed line) with a fourth-order polynomial fit to
• Last lecture 5 points sampled from the function.
• Today’s Lecture
• Polynomial
Interpolation 1
f (x)
• Polynomial 1 25x 2
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
22
Be careful with Inter/Extrapolation
Comparison of Runge’s function (dashed line) with a tenth-order polynomial fit to
• Last lecture 11 points sampled from the function.
• Today’s Lecture
• Polynomial
Interpolation
• Polynomial
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
23
Be careful with Inter/Extrapolation
• Last lecture
•choice of interpolating function is sometimes difficult
• Today’s Lecture
• Lecture
Summary
•usually different coefficients will apply to different sections
of a table
• Next lecture
24
Lecture Summary
• Last lecture • Used the ‘polyval’ MATLAB function to
• Today’s Lecture interpolate between data points and to
• Polynomial extrapolate outside the range of data points
Interpolation
• Polynomial
Extrapolation
• Highlighted a number of possible problems
• Be Careful!
with interpolation and extrapolation
• Lecture
Summary (in particular if curve fitting with high order
• Next lecture polynomials)
25
Next Lecture
• Last lecture • We move on to the much more interesting
• Today’s Lecture topic of ‘Numerical Integration’.
• Polynomial
Interpolation
• This is one of the most important numerical
• Polynomial
tools you will learn during your education
Extrapolation
• Be Careful!
• Lecture
Summary
• Next lecture
26