Title: Numeriska berkningar i Naturvetenskap och Teknik
1Numeriska berÀkningar i Naturvetenskap och Teknik
Todays topic
Approximations Least square
method Interpolations Fit of
polynomials Splines
2Numeriska berÀkningar i Naturvetenskap och Teknik
An exemple
Modell
Why do the measured values deviate from the mode
if the measurement is correct?
3Numeriska berÀkningar i Naturvetenskap och Teknik
How determine the best straight line?
Model
4Numeriska berÀkningar i Naturvetenskap och Teknik
Distance between line and measurements points...
5Numeriska berÀkningar i Naturvetenskap och Teknik
Norm
How to define the distance between the line and
the measurement points?
Largest deviation at minimum
Approximation in maximum norm
Sum of deviations squared as small as possible
Approximation in Euclidian norm
Easier to calculate!
6Numeriska berÀkningar i Naturvetenskap och Teknik
Matrix formulation An example
More equations than unknowns!
with
7Numeriska berÀkningar i Naturvetenskap och Teknik
Matrix formulation An exampe
8Numeriska berÀkningar i Naturvetenskap och Teknik
Matrix formulation An example
9Numeriska berÀkningar i Naturvetenskap och Teknik
Matrix formulation An example
10Numeriska berÀkningar i Naturvetenskap och Teknik
General Statement of the Problem
Depending on the model, the measurement data can
of course be described by other expressions than
the straight line.
In general terms one seeks a function f that
approximates fs given values as good as possible
in euclidian norm.
Specifically, above we looked for a solution
expressed as
but we could as well have looked for a solution
given by another function (possibly then for
different data)
etc...
11Numeriska berÀkningar i Naturvetenskap och Teknik
Generally one can thus write
f(x) is in other words a linear combination of
given functions
Where the coefficients
are sought
One can in accordande with a vector space look at
it so that
Spans a function space (a space of this kind
which fulfills certain conditions is called a
Hilbert space, cmp. quant. mech)
12Numeriska berÀkningar i Naturvetenskap och Teknik
In the case of the straight line we have
In a geometrical comparision these two functions,
which can be seen as two vectors in the function
space, span a plane U
sought function
vector 0
Approximating function
vector 1
The smallest distance from the plane is given by
a normal. The smallest deviation between f och
f is for f-f orthogonal to the plane U!
13Numeriska berÀkningar i Naturvetenskap och Teknik
Normal equations
Since we are interested in fitting m measured
values we leave the picture of the continuous
function space and view f(x) as an
m-dimensional vector with values
That should be expressed by
and
For the straight line
14Numeriska berÀkningar i Naturvetenskap och Teknik
The orthogonality condition now gives the
equations
where
Which gives
the equations for the normal
15Numeriska berÀkningar i Naturvetenskap och Teknik
The equations for the normal
16Numeriska berÀkningar i Naturvetenskap och Teknik
Back to the exemple
Model
Data
17Numeriska berÀkningar i Naturvetenskap och Teknik
Conclusion
Assuming the model
Given data
the minimum of
is orthogonal to the basis vectors
is obtained when
The coefficienterna c1, c2, c3, cn are determined
from
18Numeriska berÀkningar i Naturvetenskap och Teknik
The equations
or
Where the colomuns in A are
19Numeriska berÀkningar i Naturvetenskap och Teknik
Note 1
The funcs
Have to be linearly independent
(cmp vectors in a vector space)
Note 2
Assume our problem would have been (x koord -996)
cmp to
20Numeriska berÀkningar i Naturvetenskap och Teknik
Gauss elimination method
21Numeriska berÀkningar i Naturvetenskap och Teknik
Gauss elimination method
22Numeriska berÀkningar i Naturvetenskap och Teknik
Error sources
1. MĂ€tdata, Ef
23Numeriska berÀkningar i Naturvetenskap och Teknik
Error sources
2. Truncation error
These would be zero for a first degree polynomial
24Numeriska berÀkningar i Naturvetenskap och Teknik
Interpolation
The approximation to data assumes to pass through
the data points, i.e. one assumes the errors are
small.
Linear interpolation
Alt for equidistant data
25Numeriska berÀkningar i Naturvetenskap och Teknik
Quadratic interpolation
Ansatz
1
2
3
26Numeriska berÀkningar i Naturvetenskap och Teknik
Quadratic interpolation
3
27Numeriska berÀkningar i Naturvetenskap och Teknik
Quadratic interpolation
Newtons ansatz
Uniqueness There is only one polynomial of order
m that passes through m1 points.
28Numeriska berÀkningar i Naturvetenskap och Teknik
Error interpolation
Linear interpolation
29Numeriska berÀkningar i Naturvetenskap och Teknik
Exemple
Interpolation of polynomial of order 4,8,16 in
equidistant points
Fit of polynomial of order 6 to 9 equidistant
points
30Numeriska berÀkningar i Naturvetenskap och Teknik
4th order
8th order
16th order
6th order in 9 points
31Numeriska berÀkningar i Naturvetenskap och Teknik
Runges phenomenon
Interpolation in equidistant points by a
polynomal of high order tends to reproduce a
curve better in the central parts of the
interval but gives considerable oscillations
close to the end-points of the interval!
Chebychev polynomials and Chebychev abscissa
If one can select the points in which data is
known (this can be hard if the measurement
values are already given ) then the data points
should be closer close to the end-points of the
interval. An optimal choice is given by the zeros
of the Chebychev polynomial of order m which
minimizes the residue above.
32Numeriska berÀkningar i Naturvetenskap och Teknik
Splines
An alternative is to use a polynomial piece wise
between the points. One can e.g. set the
condition that the functions values, its
derivative and second derivative is equal in the
end points of each short interval for
polynomials that meet in these points. This
approach gives so-called cubic splines. In the
extreme end-points one can e.g. demand the curve
to be straight.
33Numeriska berÀkningar i Naturvetenskap och Teknik
Cubic splines
Function
Derivative
Second derivative
34Numeriska berÀkningar i Naturvetenskap och Teknik
Insertion
Function
Derivative
Second derivative
35Numeriska berÀkningar i Naturvetenskap och Teknik
The condtions
and
give
36Numeriska berÀkningar i Naturvetenskap och Teknik
the following system in matrix form
Easy to solve! Try out MATLABs spline function on
your own!