# Numeriska beräkningar i Naturvetenskap och Teknik Today’s topic: Approximations Least square method Interpolations Fit of polynomials Splines.

## Presentation on theme: "Numeriska beräkningar i Naturvetenskap och Teknik Today’s topic: Approximations Least square method Interpolations Fit of polynomials Splines."— Presentation transcript:

Numeriska beräkningar i Naturvetenskap och Teknik Today’s topic: Approximations Least square method Interpolations Fit of polynomials Splines

Numeriska beräkningar i Naturvetenskap och Teknik An exemple Modell Why do the measured values deviate from the mode if the measurement is correct?

Numeriska beräkningar i Naturvetenskap och Teknik How determine the ‘best’ straight line? Model

Numeriska beräkningar i Naturvetenskap och Teknik Distance between line and measurements points...

Numeriska beräkningar i Naturvetenskap och Teknik 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! Norm

Numeriska beräkningar i Naturvetenskap och Teknik Matrix formulation: An example with More equations than unknowns!

Numeriska beräkningar i Naturvetenskap och Teknik Matrix formulation: An exampe

Numeriska beräkningar i Naturvetenskap och Teknik Matrix formulation: An example

Numeriska beräkningar i Naturvetenskap och Teknik Matrix formulation: An example

Numeriska 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 f’s 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...

Numeriska 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)

Numeriska 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: ”vector” 0 ”vector” 1 Approximating function sought function 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!

Numeriska 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 byand For the straight line:

Numeriska beräkningar i Naturvetenskap och Teknik The orthogonality condition now gives the equations: where the equations for the normal: Which gives

Numeriska beräkningar i Naturvetenskap och Teknik The equations for the normal :

Numeriska beräkningar i Naturvetenskap och Teknik Back to the exemple: Model:Data:

Numeriska beräkningar i Naturvetenskap och Teknik Conclusion: the minimum of is orthogonal to the basis vectors Assuming the modelGiven data is obtained when The coefficienterna c 1, c 2, c 3, c n are determined from

Numeriska beräkningar i Naturvetenskap och Teknik The equations or Where the colomuns in A are:

Numeriska beräkningar i Naturvetenskap och Teknik Note 1: The func’sHave to be linearly independent (cmp vectors in a vector space) Note 2: Assume our problem would have been (x koord -996) cmp to

Numeriska beräkningar i Naturvetenskap och Teknik Gauss’ elimination method:

Numeriska beräkningar i Naturvetenskap och Teknik Gauss’ elimination method:

Numeriska beräkningar i Naturvetenskap och Teknik Error sources 1. Mätdata, E f

Numeriska beräkningar i Naturvetenskap och Teknik Error sources 2. Truncation errorThese would be zero for a first degree polynomial

Numeriska beräkningar i Naturvetenskap och Teknik 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 Interpolation

Numeriska beräkningar i Naturvetenskap och Teknik Quadratic interpolation Ansatz 1 2 3

Numeriska beräkningar i Naturvetenskap och Teknik Quadratic interpolation 3

Numeriska beräkningar i Naturvetenskap och Teknik Quadratic interpolation Newton’s ansatz Uniqueness: There is only one polynomial of order m that passes through m+1 points.

Numeriska beräkningar i Naturvetenskap och Teknik Error interpolation Linear interpolation

Numeriska 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

Numeriska beräkningar i Naturvetenskap och Teknik 4th order 8th order 16th order 6th order in 9 points

Numeriska beräkningar i Naturvetenskap och Teknik Runge’s 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.

Numeriska 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 function’s 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.

Numeriska beräkningar i Naturvetenskap och Teknik Cubic splines FunctionDerivative Second derivative

Numeriska beräkningar i Naturvetenskap och Teknik Insertion: Function Derivative Second derivative

Numeriska beräkningar i Naturvetenskap och Teknik The condtions and give

Numeriska beräkningar i Naturvetenskap och Teknik the following system in matrix form: Easy to solve! Try out MATLABs spline function on your own!

Download ppt "Numeriska beräkningar i Naturvetenskap och Teknik Today’s topic: Approximations Least square method Interpolations Fit of polynomials Splines."

Similar presentations