CP05_interpolation

CP05_interpolation - Data types in science Discrete data...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 1 Interpolation 2 Data types in science Discrete data (data tables) Experiment Observations Calculations Continuous data Analytics functions Analytic solutions 3 From continuous to discrete … soon after hurricane Isabel (September 2003) 4 From discrete to continuous? ? ? What do we want from discrete sets of data? Quite often we need to know function values at any arbitrary point x Can we generate values for any x between x 1 and x n from a data table? 0123456 0 1 2 3 4 5 Data points y(x) x 6 If you think that the data values f i in the data table are free from errors, then interpolation lets you find an approximate value for the function f(x) at any point x within the interval x 1 ...x n .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Key point!!! The idea of interpolation is to select a function g(x) such that 1. g(x i )=f i for each data point i 2. this function is a good approximation for any other x between original data points 0123456 1 2 3 4 Data points y(x) x 8 Applications of approximating functions interpolation differentiation integration 9 What is a good approximation? What can we consider as a good approximation to the original data if we do not know the original function? Data points may be interpolated by an infinite number of functions 10 Important to remember Interpolation Approximation There is no exact and unique solution The actual function is NOT known and CANNOT be determined from the tabular data. 11 Two step procedure Select a function g(x) Find coefficients 12 Step 1: selecting a function g(x) g(x) may have some standard form or be specific for the problem We should have a guideline to select a reasonable function g(x) . We need some ideas about data!!!
Background image of page 2
3 13 Some ideas for selecting g(x) ± Most interpolation methods are grounded on smoothness ’o f interpolated functions. However, it does not work all the time ± Practical approach, i.e. what physics lies beneath the data 14 Linear combination is the most common form of g(x) & linear combination of elementary functions, or trigonometric, or exponential functions, or rational functions, … Three of most common approximating functions & Polynomials & Trigonometric functions & Exponential functions ... ) ( ) ( ) ( ) ( 3 3 2 2 1 1 + + + = x h a x h a x h a x g 15 Approximating functions should have following properties & It should be easy to determine & It should be easy to evaluate & It should be easy to differentiate & It should be easy to integrate 16 Linear Interpolation: Idea 17 Linear Interpolation: coefficients 18 double int1(double x, double xi[], double yi[], int imax) { double y; int j; // if x is ouside the xi[] interval if (x <= xi[0]) return y = yi[0]; if (x >= xi[imax-1]) return y = yi[imax-1]; // loop to find j so that x[j-1] < x < x[j] j = 0; while (j <= imax-1) { if (xi[j] >= x) break; j = j + 1; } y = yi[j-1]+(yi[j]-yi[j-1])*(x-xi[j-1])/(xi[j]-xi[j-1]); return y; } Example: C++ bisection approach is much more efficient to search an array bisection approach is much more efficient to search an array
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 19 0123 -1.0 -0.5 0.0 0.5 1.0 f(x)=sin(x 2 ) Data points linear interpolation sin(x 2 ) x 20 Linear interpolation: conclusions The linear interpolation may work well for very smooth functions when the second and higher derivatives are small.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

CP05_interpolation - Data types in science Discrete data...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online