
Spline Interpolation Given: (n + 1) observations or data pairs [(x0, f0), (x1, f1), (x2, f2) … (xn, fn)] This gives a mesh of nodes ,,,⋯ on the independent variable and the corresponding function values as ,,,⋯ Goal: fit an independent polynomial in each interval (between two points) with certain continuity requirements at the nodes. Linear spline: continuity in function values, C0 continuity Quadratic spline: continuity in function values and 1st derivatives, C1 continuity Cubic spline: continuity in function values, 1st and 2nd derivatives, C2 continuity Denote for node i or at xi: functional value fi, first derivative ui, second derivative vi Spline Interpolation: Cubic xi+2, fi+2 xi, fi qi(x) qi+1(x) qi-1(x) xi+1, fi+1 xi-1, fi-1 A cubic polynomial in each interval: (n+1) points, n cubic polynomials, 4n unknowns Available conditions: (n + 1) function values, (n - 1) function continuity, (n -1) 1st derivative continuity conditions and (n -1) 2nd derivative continuity conditions, total 4n - 2 conditions. 2 free conditions to be chosen by the user! Spline Interpolation: Cubic Cubic Spline in the interval , : is a set of linear splines. Let us denote the 2nd derivative (v) of the function at the ith node as Therefore: and We may write: ℎ ℎ 6ℎ 6ℎ ℎ 6 ℎ 6 Spline Interpolation: Cubic 6ℎ 6ℎ ℎ ℎ ; 6 6 ℎ ℎ ℎ , 6 ℎ ℎ 6 6 ℎ ℎ ℎ ℎ 6 6 ℎ ℎ 6 ℎ 6 ℎ ℎ ℎ We need to estimate (n + 1) unknown vi. We have (n – 1) conditions from the continuity of the first derivative. Spline Interpolation: Cubic ; 1, 2, 3, ⋯ 1 …. 1 ℎ ℎ 6 ℎ 6 ℎ ℎ ℎ 3 3 ℎ ℎ , 6 ℎ 6 ℎ 3 3 ℎ ℎ , 6 ℎ 6 ℎ In eq. 1, ℎ ℎ ℎ ℎ , , 6 3 3 6 ℎ ℎ ℎ ℎ , , 6 3 6 , , , , Spline Interpolation: Cubic , , 1, 2, 3, ⋯ . 1 So, (n – 1) equations, (n + 1) unknowns, two conditions have to be provided by the users. They decide the type of cubic splines Natural Spline: 0 Parabolic Runout: and Not-a-knot: ⟹ ℎ ℎ ⟹ ℎ ℎ Periodic: ; and First one comes from the data (if not satisfied, the periodic spline is not appropriate); the next two give the other two equations. Spline Interpolation: Cubic , , 1, 2, 3, ⋯ . 1 So, (n – 1) equations, (n + 1) unknowns, two conditions have to be provided by the users. They decide the type of cubic splines Clamped Spline: and β 3 3 ℎ ℎ , 6 ℎ 6 ℎ ℎ ℎ , ⟹ , 6 3 3 3 ℎ ℎ , 6 ℎ 6 ℎ ℎ ℎ , β 3 6 ⟹ , Example Problem: Q4 of Tutorial 9 Consider the function exp(x) sampled at points x, 0 0.5, 1.0, 1.5 and 2 Estimate the function value at x = 1.80 by interpolating the function using - (a) natural cubic spline and (b) not-a-knot cubic spline. Calculate the true percentage error for both the splines. Which is the better spline for this problem and why? Solution: Posted online along with Tutorial 9 solutions Example Problem: Heat Transfer in Lake Lakes in temperate zone can become thermally stratified during the summer. As depicted below, warm, buoyant water near the surface overlies colder, denser bottom water. Such stratification effectively divides the lake into two layers: the epilimnion and the hypolimnion separated by a plane called the thermocline. Temperature (oC) z (m) T(oC) 0.0 5.0 10.0 15.0 20.0 25.0 0 022.8 2.3 22.8 5 4.9 22.8 10 9.1 22.6 15 13.7 13.9 20 18.3 11.7 Depth, z(m) 22.9 11.1 25 27.2 11.1 30 Example Problem: Heat Transfer in Lake The location of the thermocline can be defined as the inflection point of the T-z curve; i.e. where = 0. It is also the point at which the absolute value of the first derivative or gradient is maximum. Use cubic splines to determine the thermocline depth of this lake. Also use splines to determine the value of the gradient at the thermocline. Spline Interpolation: Using Local Coordinate ∈ , → ∈ 0, 1 in , → in 0, 1 At each node i, we denote the following: Location: xi Functional value: fi Intervals: ℎ and ℎ nd Derivatives: First derivative ui and the 2 derivative vi Transformations: 1 1 ⟹ ℎ ℎ 1 1 ℎ ℎ Spline Interpolation: Using Local Coordinate C0 – Continuity: 1 0 C1 – Continuity: 1 1 1 0 ℎ ℎ C2 – Continuity: 1 1 1 0 ℎ ℎ Linear and Quadratic Splines: Local Coordinate Linear Spline: C0 – Continuous ⇒ 0 , 1 ⟹ , Quadratic Spline: C1 – Continuous ⇒ 0 , 1 Using the definition of ui: 1 0 ⇒ ℎ , ℎ ℎ ℎ , ℎ Using C1 – Continuity: 1 1 1 0 ⇒ 2, ℎ ℎ Cubic Spline: Using Local Coordinate Cubic Spline: C2 – Continuous Using C0 – Continuity: 0 , 1 Now we have two options: st 2 Option 1: Using the 1 derivative ui as unknown and C – Continuity to estimate them nd 1 Option 2: Using the 2 derivative vi as unknown and C – Continuity to estimate them Cubic Spline: Using Local Coordinates st 2 Option 1: Using the 1 derivative ui as unknown and C – Continuity to estimate them , 1 1 3 2 0 ; 1 ℎ ℎ ℎ ℎ ℎ 2 , ℎ 3 , 2 Using C2 – Continuity: 1 1 6 2 2 1 0⇒ ℎ ℎ ℎ ℎ ℎ 2 ℎ ℎ ℎ 3ℎ , 3ℎ , 1, 2, 3, ⋯ 1 Using the two other conditions, one may obtain similar splines of different types! Cubic Spline: Using Local Coordinates Natural Spline: 0 0 2 0; ℎ 3 , 2 0 ℎ ℎ 1 6 2 0 ℎ ℎ 6ℎ 2 , 2ℎ 3 , 2 0 2 3, 2 3, Clamped Spline: and β Parabolic Runout: and 0 1 2 6 2 ⟹ ⟹ 2, ℎ ℎ ℎ ℎ 0 1 2 6 2 ⟹ ⟹ 2, ℎ ℎ ℎ ℎ Cubic Spline: Using Local Coordinates Not-a-knot: ⟹ ℎ ℎ ⟹ ℎ ℎ Periodic: ; and First one comes from the data (if not satisfied, the periodic spline is not appropriate); the next two give the other two equations. Formulation of these two is left as homework! Cubic Spline: Using Local Coordinates nd 1 Option 2: Using the 2 derivative vi as unknown and C – Continuity to estimate them , 1 2 1 6 2 0 ; 1 ℎ ℎ ℎ ℎ ℎ ℎ ; ℎ , 2 6 6 Using C1 – Continuity: 1 1 3 2 1 0 ⇒ ℎ ℎ ℎ ℎ ℎ 2 ℎ ℎ ℎ 6, 6 , 1, 2, 3, ⋯ 1 This is the same equation that was obtained using Lagrange polynomials! Boundary conditions are also the same! ESO 208A: Computational Methods in Engineering Numerical Differentiation Abhas Singh Department of Civil Engineering IIT Kanpur Acknowledgements: Profs. Saumyen Guha and Shivam Tripathi (CE) Numerical Differentiation Let us compute dy/dx or df/dx at node i Denote the difference operators: ∆ Numerical Differentiation: Finite Difference Approximate the function between , as: ∆ ∆ Forward Difference: ∆ ∆ ∆ Approximate the function between , as: Backward Difference: Numerical Differentiation: Finite Difference Approximate the function between three points: ,, ∆ ∆ ∆ ∆ Now, evaluate df/dx at x = xi: ∆ ∆ ∆ ∆ ∆ ∆ Numerical Differentiation: Finite Difference Central Difference: ∆ ∆ ∆ ∆ ∆ ∆ For regular or uniform grid: Let us assume regular grid with a mesh size of h Numerical Differentiation: Finite Difference Approximate the function between three points: ,, 2ℎ ℎ 2ℎ 2 2 Now, evaluate central difference approximations of df/dx and d f/dx at x = xi: 2ℎ ℎ 2ℎ 2ℎ 2 ℎ Numerical Differentiation: Finite Difference Similarly, one can approximate the function between three points and obtain the forward difference expressions of the first and second derivatives at x = xi as follows: This is left for homework practice! Numerical Differentiation: Finite Difference Similarly, one can approximate the function between three points and obtain the backward difference expressions of the first and second derivatives at x = xi as follows: This is left for homework practice! Numerical Differentiation: Finite Difference Accuracy: How accurate is the numerical differentiation scheme with respect to the TRUE differentiation? Truncation Error analysis Modified Wave Number, Amplitude Error and Phase Error analysis for periodic functions Recall: True Value (a) = Approximate Value + Error (ε) Consistency: A numerical expression for differentiation or a numerical differentiation scheme is consistent if it converges to the TRUE differentiation as h → 0..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages28 Page
-
File Size-