Lecture_26.pdf - 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

# Lecture_26.pdf - Spline Interpolation Given(n 1...

• Notes
• 28

This preview shows page 1 out of 28 pages. #### You've reached the end of your free preview.

Want to read all 28 pages?

Unformatted text preview: 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 , f i xi-1, fi-1 qi-1(x) qi(x) qi+1(x) 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: We may write: ℎ 6ℎ and ℎ 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 6 ℎ ℎ In eq. 1 , 6 3 ℎ 6 ℎ 6 ℎ 3 ℎ , 1 … . 1 ℎ 3 ℎ 3 ℎ 6 ℎ 3 ℎ 6 ℎ 1, 2, 3, ⋯ ℎ ℎ 6 ℎ 3 6 ℎ ; ℎ 3 ℎ 6 , ℎ 6 ℎ , , , , , ℎ , , , ℎ Spline Interpolation: Cubic , , 1, 2, 3, ⋯ 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. 1. 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 ℎ 6 ℎ 6 ℎ ℎ , 6 3 3 6 ℎ ℎ 3 ⟹ 3 ℎ 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) 0.0 0 Depth, z(m) 5 10 15 20 25 30 5.0 10.0 15.0 20.0 25.0 z (m) 0 2.3 4.9 9.1 13.7 18.3 22.9 27.2 o T( C) 22.8 22.8 22.8 22.6 13.9 11.7 11.1 11.1 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 ∈ , in , → ∈ 0, 1 → in 0, 1 At each node i, we denote the following: Location: xi Functional value: fi Intervals: ℎ and ℎ Derivatives: First derivative ui and the 2nd derivative vi Transformations: 1 ℎ 1 ℎ ⟹ 1 ℎ 1 ℎ Spline Interpolation: Using Local Coordinate C0 – Continuity: 1 C1 – Continuity: 1 1 ℎ C2 – Continuity: 1 1 ℎ 0 1 0 ℎ 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: Option 1: Using the 1st derivative ui as unknown and C2 – Continuity to estimate them Option 2: Using the 2nd derivative vi as unknown and C1 – Continuity to estimate them Cubic Spline: Using Local Coordinates Option 1: Using the 1st derivative ui as unknown and C2 – Continuity to estimate them , 1 1 0 ; 1 ℎ ℎ ℎ ℎ ℎ 3 , Using C2 – Continuity: 1 ℎ ℎ 2 ℎ 1 ℎ 3 2 ℎ 2 , 2 1 6 2 0 ⇒ ℎ ℎ ℎ 3ℎ , 1, 2, 3, ⋯ 1 2 ℎ 3ℎ , Using the two other conditions, one may obtain similar splines of different types! Cubic Spline: Using Local Coordinates Natural Spline: 0 ℎ 2 ℎ 6ℎ 2 0; 1 ℎ 2 , 3 , 0 ℎ 3 , 6 2 0 0 ℎ 2ℎ 2 3 , 2 2 3 , Clamped Spline: and β Parabolic Runout: 0 ℎ 0 ℎ ℎ 1 and 2 6 2 ⟹ ⟹ ℎ ℎ ℎ 2 6 1 2 ⟹ ⟹ ℎ ℎ 2 , 2 , 0 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 Option 2: Using the 2nd derivative vi as unknown and C1 – Continuity to estimate them 1 0 ℎ ℎ 6 , 2 ; ℎ ; Using C1 – Continuity: 1 ℎ ℎ 1 2 ℎ 1 6 2 1 ℎ ℎ ℎ ℎ , 6 1 3 2 0 ⇒ ℎ ℎ ℎ ℎ 6 , 1, 2, 3, ⋯ 1 2 ℎ 6 , 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ℎ , , Now, evaluate central difference approximations of df/dx and d2f/dx2 at x = xi: 2ℎ ℎ 2ℎ 2 ℎ 2ℎ Numerical Differentiation: Finite Difference Similarly, one can approximate the function between and obtain the forward three points 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 and obtain the backward three points 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. ...
View Full Document

• Fall '19

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern  