Applied Math 205. Full office hour schedule:

Similar documents
The Normal Equations. For A R m n with m > n, A T A is singular if and only if A is rank-deficient. 1 Proof:

Cubic Splines; Bézier Curves

Lecture Note 3: Interpolation and Polynomial Approximation. Xiaoqun Zhang Shanghai Jiao Tong University

Cubic Splines MATH 375. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Cubic Splines

Non-polynomial Least-squares fitting

Chapter 4: Interpolation and Approximation. October 28, 2005

We consider the problem of finding a polynomial that interpolates a given set of values:

CS 323: Numerical Analysis and Computing

Numerical Methods I Orthogonal Polynomials

Lecture 10 Polynomial interpolation

MATH 350: Introduction to Computational Mathematics

CS412: Introduction to Numerical Methods

Arsène Pérard-Gayot (Slides by Piotr Danilewski)

Numerical Methods I: Polynomial Interpolation

Lectures 9-10: Polynomial and piecewise polynomial interpolation

Interpolation and extrapolation

Outline. 1 Interpolation. 2 Polynomial Interpolation. 3 Piecewise Polynomial Interpolation

CS 257: Numerical Methods

Interpolation and polynomial approximation Interpolation

Interpolation. Chapter Interpolation. 7.2 Existence, Uniqueness and conditioning

SPLINE INTERPOLATION

Polynomials. p n (x) = a n x n + a n 1 x n 1 + a 1 x + a 0, where

Lecture Note 3: Polynomial Interpolation. Xiaoqun Zhang Shanghai Jiao Tong University

1 Piecewise Cubic Interpolation

Fixed point iteration and root finding

CS 323: Numerical Analysis and Computing

Some notes on Chapter 8: Polynomial and Piecewise-polynomial Interpolation

Numerical Methods I: Interpolation (cont ed)

Bézier Curves and Splines

INTERPOLATION. and y i = cos x i, i = 0, 1, 2 This gives us the three points. Now find a quadratic polynomial. p(x) = a 0 + a 1 x + a 2 x 2.

CS 542G: Robustifying Newton, Constraints, Nonlinear Least Squares

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

On the Lebesgue constant of barycentric rational interpolation at equidistant nodes

Interpolation Theory

1S11: Calculus for students in Science

MAT01A1: Functions and Mathematical Models

Function approximation

Lösning: Tenta Numerical Analysis för D, L. FMN011,

Linear Least-Squares Data Fitting

The degree of the polynomial function is n. We call the term the leading term, and is called the leading coefficient. 0 =

Math 1310 Section 4.1: Polynomial Functions and Their Graphs. A polynomial function is a function of the form ...

Exam 2. Average: 85.6 Median: 87.0 Maximum: Minimum: 55.0 Standard Deviation: Numerical Methods Fall 2011 Lecture 20

Computational Methods. Least Squares Approximation/Optimization

CHAPTER 4. Interpolation

A THEORETICAL INTRODUCTION TO NUMERICAL ANALYSIS

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes

GENG2140, S2, 2012 Week 7: Curve fitting

CONTROL POLYGONS FOR CUBIC CURVES

Introduction Linear system Nonlinear equation Interpolation

AM 205: lecture 6. Last time: finished the data fitting topic Today s lecture: numerical linear algebra, LU factorization

Chapter 1 Numerical approximation of data : interpolation, least squares method

Intro Polynomial Piecewise Cubic Spline Software Summary. Interpolation. Sanzheng Qiao. Department of Computing and Software McMaster University

Math 365 Homework 5 Due April 6, 2018 Grady Wright

Intro Polynomial Piecewise Cubic Spline Software Summary. Interpolation. Sanzheng Qiao. Department of Computing and Software McMaster University

3.1 Interpolation and the Lagrange Polynomial

Lagrange Interpolation and Neville s Algorithm. Ron Goldman Department of Computer Science Rice University

Scientific Computing: An Introductory Survey

BSM510 Numerical Analysis

MATH ASSIGNMENT 07 SOLUTIONS. 8.1 Following is census data showing the population of the US between 1900 and 2000:

MAT 300 Midterm Exam Summer 2017

Math 307 Learning Goals

Problem 1: Toolbox (25 pts) For all of the parts of this problem, you are limited to the following sets of tools:

Interpolation Atkinson Chapter 3, Stoer & Bulirsch Chapter 2, Dahlquist & Bjork Chapter 4 Topics marked with are not on the exam

PROJECTION METHODS FOR DYNAMIC MODELS

Interpolation. 1. Judd, K. Numerical Methods in Economics, Cambridge: MIT Press. Chapter

Section 0.2 & 0.3 Worksheet. Types of Functions

Introduction to Computer Graphics. Modeling (1) April 13, 2017 Kenshi Takayama

Sample Exam 1 KEY NAME: 1. CS 557 Sample Exam 1 KEY. These are some sample problems taken from exams in previous years. roughly ten questions.

Numerical Analysis: Interpolation Part 1

LECTURE 7, WEDNESDAY

Numerical Analysis Lecture Notes

Quantitative Techniques (Finance) 203. Polynomial Functions

Global polynomial interpolants suffer from the Runge Phenomenon if the data sites (nodes) are not chosen correctly.

TABLE OF CONTENTS INTRODUCTION, APPROXIMATION & ERRORS 1. Chapter Introduction to numerical methods 1 Multiple-choice test 7 Problem set 9

PARTIAL DIFFERENTIAL EQUATIONS

Numerical integration - I. M. Peressi - UniTS - Laurea Magistrale in Physics Laboratory of Computational Physics - Unit V

Q1. Discuss, compare and contrast various curve fitting and interpolation methods

Scientific Computing

Graphs of Polynomial Functions

Final Year M.Sc., Degree Examinations

Fitting Linear Statistical Models to Data by Least Squares I: Introduction

(0, 0), (1, ), (2, ), (3, ), (4, ), (5, ), (6, ).

1 Roots of polynomials

Polynomial Interpolation Part II

Today. Calculus. Linear Regression. Lagrange Multipliers

CSE 167: Lecture 11: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Curve Fitting and Interpolation

MAT300/500 Programming Project Spring 2019

AM 205: lecture 6. Last time: finished the data fitting topic Today s lecture: numerical linear algebra, LU factorization

CHAPTER 2 POLYNOMIALS KEY POINTS

Applied Linear Algebra in Geoscience Using MATLAB

x x2 2 + x3 3 x4 3. Use the divided-difference method to find a polynomial of least degree that fits the values shown: (b)

Numerical Analysis Comprehensive Exam Questions

Review: complex numbers

MA2501 Numerical Methods Spring 2015

Introductory Numerical Analysis

Assignment 6, Math 575A

Preliminary Examination in Numerical Analysis

1 Motivation for Newton interpolation

CLEP EXAMINATION: Precalculus

Transcription:

Applied Math 205 Full office hour schedule: Rui: Monday 3pm 4:30pm in the IACS lounge Martin: Monday 4:30pm 6pm in the IACS lounge Chris: Tuesday 1pm 3pm in Pierce Hall, Room 305 Nao: Tuesday 3pm 4:30pm in Pierce Hall, Room 320 Tara: Friday 10am 12pm in Maxwell Dworkin, Room 215

Bernstein interpolation The Bernstein polynomials on [0, 1] are b m,n (x) = ( n m ) x m (1 x) n m. For a function f on the [0, 1], the approximating polynomial is n B n (f )(x) = f m=0 ( m n ) b m,n (x). Bernstein interpolation is impractical for normal use, and converges extremely slowly. However, it has robust convergence properties, which can be used to prove the Weierstraß approximation theorem. See a textbook on real analysis for a full discussion. 1 1 e.g. Elementary Analysis by Kenneth A. Ross

Bernstein interpolation 1 Bernstein polynomials f(x) 0.5 0-0.5-1 0 0.2 0.4 0.6 0.8 1 x

Bernstein interpolation 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0-0.1-0.2 Bernstein polynomials g(x) 0 0.2 0.4 0.6 0.8 1 x

Lebesgue Constant Then, we can relate interpolation error to f pn as follows: f I n (f ) f pn + pn I n (f ) = f pn + I n (pn) I n (f ) = f pn + I n (pn f ) = f pn + I n(pn f ) pn f p f n f pn + Λ n (X ) f pn = (1 + Λ n (X )) f pn

Lebesgue Constant Small Lebesgue constant means that our interpolation can t be much worse that the best possible polynomial approximation! [lsum.py] Now let s compare Lebesgue constants for equispaced (X equi ) and Chebyshev points (X cheb )

Lebesgue Constant Plot of 10 k=0 L k(x) for X equi and X cheb (11 pts in [ 1, 1]) 30 2.5 25 20 2 15 10 1.5 5 0 1 0.5 0 0.5 1 1 1 0.5 0 0.5 1 Λ 10 (X equi ) 29.9 Λ 10 (X cheb ) 2.49

Lebesgue Constant Plot of 20 k=0 L k(x) for X equi and X cheb (21 pts in [ 1, 1]) 12000 10000 8000 6000 4000 2000 0 1 0.5 0 0.5 1 3 2.8 2.6 2.4 2.2 2 1.8 1.6 1.4 1.2 1 1 0.5 0 0.5 1 Λ 20 (X equi ) 10,987 Λ 20 (X cheb ) 2.9

Lebesgue Constant Plot of 30 k=0 L k(x) for X equi and X cheb (31 pts in [ 1, 1]) 7 x 106 6 5 4 3.5 3 2.5 3 2 1 0 1 0.5 0 0.5 1 2 1.5 1 1 0.5 0 0.5 1 Λ 30 (X equi ) 6,600,000 Λ 30 (X cheb ) 3.15

Lebesgue Constant The explosive growth of Λ n (X equi ) is an explanation for Runge s phenomenon 2 It has been shown that as n, Λ n (X equi ) 2n en log n BAD! whereas Λ n (X cheb ) < 2 log(n + 1) + 1 π GOOD! Important open mathematical problem: What is the optimal set of interpolation points (i.e. what X minimizes Λ n (X ))? 2 Runge s function f (x) = 1/(1 + 25x 2 ) excites the worst case behavior allowed by Λ n(x equi)

Summary It is helpful to compare and contrast the two key topics we ve considered so far in this chapter 1. Polynomial interpolation for fitting discrete data: We get zero error regardless of the interpolation points, i.e. we re guaranteed to fit the discrete data Should use Lagrange polynomial basis (diagonal system, well-conditioned) 2. Polynomial interpolation for approximating continuous functions: For a given set of interpolating points, uses the methodology from 1 above to construct the interpolant But now interpolation points play a crucial role in determining the magnitude of the error f I n (f )

Piecewise Polynomial Interpolation

Piecewise Polynomial Interpolation We can t always choose our interpolation points to be Chebyshev, so another way to avoid blow up is via piecewise polynomials Idea is simple: Break domain into subdomains, apply polynomial interpolation on each subdomain (interp. pts. now called knots ) Recall piecewise linear interpolation, also called linear spline 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 1 0.5 0 0.5 1

Piecewise Polynomial Interpolation With piecewise polynomials, we avoid high-order polynomials hence we avoid blow-up However, we clearly lose smoothness of the interpolant Also, can t do better than algebraic convergence 3 3 Recall that for smooth functions Chebyshev interpolation gives exponential convergence with n

Splines Splines are a popular type of piecewise polynomial interpolant In general, a spline of degree k is a piecewise polynomial that is continuously differentiable k 1 times Splines solve the loss of smoothness issue to some extent since they have continuous derivatives Splines are the basis of CAD software (AutoCAD, SolidWorks), also used in vector graphics, fonts, etc. 4 (The name spline comes from a tool used by ship designers to draw smooth curves by hand) 4 CAD software uses NURB splines, font definitions use Bézier splines

Splines We focus on a popular type of spline: Cubic spline C 2 [a, b] Continuous second derivatives = looks smooth to the eye Example: Cubic spline interpolation of Runge function 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 1 0.5 0 0.5 1

Cubic Splines: Formulation Suppose we have knots x 0,..., x n, then cubic on each interval [x i 1, x i ] = 4n parameters in total Let s denote our cubic spline, and suppose we want to interpolate the data {f i, i = 0, 1,..., n} We must interpolate at n + 1 points, s(x i ) = f i, which provides two equations per interval = 2n equations for interpolation Also, s (x i ) = s +(x i ), i = 1,..., n 1 = n 1 equations for continuous first derivative And, s (x i ) = s +(x i ), i = 1,..., n 1 = n 1 equations for continuous second derivative Hence 4n 2 equations in total

Cubic Splines We are short by two conditions! There are many ways to make up the last two, e.g. Natural cubic spline: Set s (x 0 ) = s (x n ) = 0 Not-a-knot spline 5 : Set s (x 1 ) = s + (x 1 ) and s (x n 1 ) = s + (x n 1 ) Or we can choose any other two equations we like (e.g. set two of the spline parameters to zero) 6 See examples: [spline.py] & [spline2.py] 5 Not-a-knot because all derivatives of s are continuous at x 1 and x n 1 6 As long as they are linearly independent from the first 4n 2 equations

Unit I: Data Fitting Chapter I.3: Linear Least Squares

The Problem Formulation Recall that it can be advantageous to not fit data points exactly (e.g. due to experimental error), we don t want to overfit Suppose we want to fit a cubic polynomial to 11 data points 4.2 4 3.8 3.6 y 3.4 3.2 3 2.8 0 0.5 1 1.5 2 x Question: How do we do this?

The Problem Formulation Suppose we have m constraints and n parameters with m > n (e.g. m = 11, n = 4 on previous slide) In terms of linear algebra, this is an overdetermined system Ab = y, where A R m n, b R n (parameters), y R m (data) A b = y i.e. we have a tall, thin matrix A

The Problem Formulation In general, cannot be solved exactly (hence we will write Ab y); instead our goal is to minimize the residual, r(b) R m r(b) y Ab A very effective approach for this is the method of least squares: 7 Find parameter vector b R n that minimizes r(b) 2 As we shall see, we minimize the 2-norm above since it gives us a differentiable function (we can then use calculus) 7 Developed by Gauss and Legendre for fitting astronomical observations with experimental error

The Normal Equations Goal is to minimize r(b) 2, recall that r(b) 2 = n i=1 r i(b) 2 Since minimizing b is the same for r(b) 2 and r(b) 2 2, we consider the differentiable objective function φ(b) = r(b) 2 2 φ(b) = r 2 2 = r T r = (y Ab) T (y Ab) = y T y y T Ab b T A T y + b T A T Ab = y T y 2b T A T y + b T A T Ab where last line follows from y T Ab = (y T Ab) T, since y T Ab R φ is a quadratic function of b, and is non-negative, hence a minimum must exist, (but not nec. unique, e.g. f (b 1, b 2 ) = b 2 1 )

The Normal Equations To find minimum of φ(b) = y T y 2b T A T y + b T A T Ab, differentiate with respect to b and set to zero 8 First, let s differentiate b T A T y with respect to b That is, we want (b T c) where c A T y R n : b T c = n i=1 b i c i = b i (b T c) = c i = (b T c) = c Hence (b T A T y) = A T y 8 We will discuss numerical optimization of functions of many variables in detail in Unit IV

The Normal Equations Next consider (b T A T Ab) (note A T A is symmetric) Consider b T Mb for symmetric matrix M R n n b T Mb = b T ( n j=1 m (:,j) b j ) From the product rule b k (b T Mb) = e T k = n m (:,j) b j + b T m (:,k) j=1 n m (k,j) b j + b T m (:,k) j=1 = m (k,:) b + b T m (:,k) = 2m (k,:) b, where the last line follows from symmetry of M Therefore, (b T Mb) = 2Mb, so that (b T A T Ab) = 2A T Ab

The Normal Equations Putting it all together, we obtain We set φ(b) = 0 to obtain φ(b) = 2A T y + 2A T Ab 2A T y + 2A T Ab = 0 = A T Ab = A T y This square n n system A T Ab = A T y is known as the normal equations

The Normal Equations For A R m n with m > n, A T A is singular if and only if A is rank-deficient. 9 Proof: ( ) Suppose A T A is singular. z 0 such that A T Az = 0. Hence z T A T Az = Az 2 2 = 0, so that Az = 0. Therefore A is rank-deficient. ( ) Suppose A is rank-deficient. z 0 such that Az = 0, hence A T Az = 0, so that A T A is singular. 9 Recall A R m n, m > n is rank-deficient if columns are not L.I., i.e. z 0 s.t. Az = 0

The Normal Equations Hence if A has full rank (i.e. rank(a) = n) we can solve the normal equations to find the unique minimizer b However, in general it is a bad idea to solve the normal equations directly, because it is not as numerically stable as some alternative methods Question: If we shouldn t use normal equations, how do we actually solve least-squares problems?

Least-squares polynomial fit Find least-squares fit for degree 11 polynomial to 50 samples of y = cos(4x) for x [0, 1] Let s express the best-fit polynomial using the monomial basis: p(x; b) = 11 k=0 b kx k (Why not use the Lagrange basis? Lagrange loses its nice properties here since m > n, so we may as well use monomials) The ith condition we d like to satisfy is p(x i ; b) = cos(4x i ) = over-determined system with 50 12 Vandermonde matrix

Least-squares polynomial fit [lfit.py] But solving the normal equations still yields a small residual, hence we obtain a good fit to the data r(b normal ) 2 = y Ab normal 2 = 1.09 10 8 r(b lst.sq. ) 2 = y Ab lst.sq. 2 = 8.00 10 9