Scientific Computing Linear and Quadratic Splines.

Slides:



Advertisements
Similar presentations
BEZIER CURVES Part II. Assume we are given two endpoints labelled E1 and E2 and two control points labelled C1 and C2. create a smooth curve whose endpoints.
Advertisements

Interpolation A method of constructing a function that crosses through a discrete set of known data points. .
Chapter 3. Interpolation and Extrapolation Hui Pan, Yunfei Duan.
MATH 685/ CSI 700/ OR 682 Lecture Notes
Selected from presentations by Jim Ramsay, McGill University, Hongliang Fei, and Brian Quanz Basis Basics.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
1 Curve-Fitting Spline Interpolation. 2 Curve Fitting Regression Linear Regression Polynomial Regression Multiple Linear Regression Non-linear Regression.
Dr. S.M. Malaek Assistant: M. Younesi
Computational Methods in Physics PHYS 3437
EARS1160 – Numerical Methods notes by G. Houseman
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
Splines II – Interpolating Curves
Curve-Fitting Interpolation
Engineering Computation Curve Fitting: Interpolation 1
Curve-Fitting Polynomial Interpolation
1 Dr. Scott Schaefer Catmull-Rom Splines: Combining B-splines and Interpolation.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 181 Interpolation Chapter 18 Estimation of intermediate.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Interpolation Chapter 18.
ON MULTIVARIATE POLYNOMIAL INTERPOLATION
Chapters 5 and 6: Numerical Integration
(Spline, Bezier, B-Spline)
V. Space Curves Types of curves Explicit Implicit Parametric.
Numerical Computation
Curves.
Review of Interpolation. A method of constructing a function that crosses through a discrete set of known data points.
Section 14.7 Second-Order Partial Derivatives. Old Stuff Let y = f(x), then Now the first derivative (at a point) gives us the slope of the tangent, the.
Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1.
Polynomial Interpolation You will frequently have occasions to estimate intermediate values between precise data points. The function you use to interpolate.
Splines Vida Movahedi January 2007.
Chapter 14 Curve Fitting : Polynomial Interpolation Gab Byung Chae.
Scientific Computing Interpolation – Divided Differences Efficiency and Error Analysis.
1. Interpolating polynomials Polynomial of degree n,, is a linear combination of Definitions: (interval, continuous function, abscissas, and polynomial)
Lecture 22 Numerical Analysis. Chapter 5 Interpolation.
Computers in Civil Engineering 53:081 Spring 2003 Lecture #15 Spline Interpolation.
Jump to first page Chapter 3 Splines Definition (3.1) : Given a function f defined on [a, b] and a set of numbers, a = x 0 < x 1 < x 2 < ……. < x n = b,
Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W Th , F
Functions and Their Representations
Keyframing and Splines Jehee Lee Seoul National University.
Introduction to Numerical Analysis I MATH/CMPSC 455 Splines.
Mohiuddin Ahmad SUNG-BONG JANG Interpolation II (8.4 SPLINE INTERPOLATION) (8.5 MATLAB’s INTERPOLATION Functions)
Cubic Spline Interpolation. Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation.
Section 9.1 Arc Length. FINDING THE LENGTH OF A PLANE CURVE Divide the interval [a, b] into n equal subintervals. Find the length of the straight line.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
 3.3 Hermite Interpolation Chapter 3 Interpolation and Polynomial Approximation -- Hermite Interpolation Find the osculating polynomial P(x) such that.
MA2213 Lecture 2 Interpolation.
By: Mark Coose Joetta Swift Micah Weiss. What Problems Can Interpolation Solve? Given a table of values, find a simple function that passes through the.
Programme F6: Polynomial equations Worked examples and exercises are in the text STROUD PROGRAMME F6 POLYNOMIAL EQUATIONS.
Rendering Bezier Curves (1) Evaluate the curve at a fixed set of parameter values and join the points with straight lines Advantage: Very simple Disadvantages:
5. Interpolation 5.1 Definition of interpolation. 5.2 Formulas for Interpolation. 5.3 Formulas for Interpolation for unequal interval. 5.4 Applications.
1 Lecture 8 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 17 and 18 Interpolation.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Copyright © Cengage Learning. All rights reserved. 15 Multiple Integrals.
Interpolation - Introduction
Answers for Review Questions for Lectures 1-4. Review Lectures 1-4 Problems Question 2. Derive a closed form for the estimate of the solution of the equation.
CSCI480/582 Lecture 9 Chap.2.2 Cubic Splines – Hermit and Bezier Feb, 11, 2009.
Computational Methods CMSC/AMSC/MAPL 460 Polynomial Interpolation Ramani Duraiswami, Dept. of Computer Science.
Curve-Fitting Spline Interpolation
Interpolation Estimation of intermediate values between precise data points. The most common method is: Although there is one and only one nth-order.
Chapter 18.
Chapter 15 Curve Fitting : Splines
Chapter 18.
Spline Interpolation Class XVII.
Numerical Analysis Lecture 23.
Numerical Analysis Lecture 26.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.)
MATH 174: Numerical Analysis I
INTERPOLATION For both irregulary spaced and evenly spaced data.
SKTN 2393 Numerical Methods for Nuclear Engineers
Theory of Approximation: Interpolation
Presentation transcript:

Scientific Computing Linear and Quadratic Splines

Splines Overview We have looked at two methods of finding interpolating polynomials for a set of data points – Lagrange polynomials and Newton’s method. While these methods are fairly simple to program, they have a serious drawback – for a large number of data points, the interpolating polynomial can be quite unstable.

Splines Overview Here is a set of 11 data points and the computer interpolating polynomial. Note the high degree of oscillation near the ends. This is an unfortunate property of interpolating polynomials of high degree!

Splines Overview Here is a picture of the same data, but with spline curves interpolating the data. Note how this interpolation is so much more smooth and stable than the previous example.

What is a Spline Curve? A spline curve is a curve that is made of a set of simple curves (lines, quadratics, cubics) that are joined together. A spline is piece-wise defined. That is, it is defined over a set of sub-intervals of a given interval. This set is called a partition. Definition: A partition of an interval [a,b] is a sequence of points between a and b such that a = t 0 < t 1 < … < t n = b The numbers t i (i = 1 to n-1) are called knots

Linear Spline Definition: A function S is a linear spline on [a,b] if – The domain of S is [a,b] – S is continuous on [a,b] – There is a partition of points on [a,b] such that S is a linear function on each sub-interval [t i, t i+1 ]

Linear Spline A linear spline is defined by its values at the set of knots. Given the table of values there is a unique linear spline with those values. On each sub-interval, [t i, t i+1 ], the linear spline is defined by a linear function: Then, S(t i )= y i and S(t i+1 ) = y i+1 (verify this)

Linear Spline Example:

Linear Spline Piece-Wise Linear Formula for Spline: Note: The fractions here are just the first divided differences for the data.

Matlab Linear Spline Function function v = piecelin2(x,y,u) %Piecewise linear interpolation. (Slightly modified from Moler text) % v = piecelin2(x,y,u) finds the piecewise linear value of S(x) % with S(x(j)) = y(j) and returns v = S(u). % First divided difference – “diff” is a built-in Matlab command delta = diff(y)./diff(x); % Find subinterval index k so that x(k) <= u < x(k+1) n = length(x); k = 1; for j = 2:n-1 if x(j) <= u; k = j; end % Evaluate spline at u s = u - x(k); v = y(k) + s*delta(k);

Matlab Linear Spline Example % x,y data in vector form x = 1:6; y = [ ]; % A series of values along the x-axis u = 1.0:.05:6.0; [m n] = size(u); % polyvals stores the linear spline values for the u-values splinevals = zeros(n); for i = 1:n % Compute each polynomial value splinevals(i) = piecelin2(x,y,u(i)); end % Plot the x-y data as circles ('o') and the polynomial data as '-' plot(x,y,'o',u,splinevals,'-')

Matlab Linear Spline Example

Quadratic Spline Definition: A function Q is a quadratic spline on [a,b] if – The domain of Q is [a,b] – Q is continuous on [a,b] – Q’ is continuous on [a,b] – There is a partition of points on [a,b] such that Q is a polynomial of degree <= 2 on each sub-interval [t i, t i+1 ]

Quadratic Spline Example: Class Exercise: Verify that Q satisfies all parts of the definition of a quadratic spline.

Formula for Quadratic Spline Need to find constants a i, b i, c i, such that

Formula for Quadratic Spline

Need to find constants a i, b i, c i, such that Thus, we need to determine 3n different constants.

Formula for Quadratic Spline We know that: – Q i (t i ) = y i – Q i (t i+1 ) = y i+1 – Q i ’ (t i+1 ) = Q i+1 ’ (t i+1 ) (Q’ is continuous at knots) This gives n + n + (n-1) =3n -1 equations for 3n unknowns! Need one more condition on Q. Could use one of these – a 0 = 0 (Q 0 is a line) – Q’(t 0 ) = z 0 (slope at start) – Q’’(t 0 ) = w 0 (curvature at start) We will use the second condition.

Formula for Quadratic Spline Let z i = Q i ’ (t i ) Recall: Q i (x) = a i (x-t i ) 2 + b i ( x-t i ) + c i Then, Q i (t i ) = y i -> c i = y i Also, Q i ’ (t i ) = z i -> b i = z i So, Q i (x) = a i (x-t i ) 2 + z i (x-t i ) + y i Since Q i ’(t i+1 ) = z i+1 we get 2a i (t i+1 -t i ) + z i = z i+1 Thus, a i = (z i+1 -z i )/2(t i+1 -t i )

Formula for Quadratic Spline We then get a formula for Q i (x) in terms of data points t i and y i and the derivative values z i Now, z 0 is given as data. How do we get other z i ?

Formula for Quadratic Spline

Algorithm: Given data (t i, y i ) and z 0 = derivative at Q(a), compute – 1) for i = 1, 2, …,n – 2)

Quadratic Spline Example: Data x = [0 1 4], y = [1 -2 1] Create Matlab Program piecequad. This is one of your homework problems. We add another input variable z0, so we have piecequad(x,y,z0,u) Output is Q i (u) for i = interval in which u lies. Our example, get – Q 0 (x)= -3x – Q 1 (x) = 7/3 (x-1) 2 – 7 (x-1) -2 (Verify this is correct!)

Quadratic Spline Example: Plot this using Matlab: x = [0 1 4]; y = [1 -2 1]; % A series of values along the x-axis u = 0.0:.05:4.0; [m n] = size(u); % polyvals stores the quadratic spline values for the u-values splinevals = zeros(n); for i = 1:n splinevals(i) = piecequad(x,y,1,u(i)); end % Plot the x-y data as circles ('o') and the polynomial data as '-' plot(x,y,'o',u,splinevals,'-')

Quadratic Spline Example: