polynomial interpolation a x

Similar documents

Review of Taylor Series. Read Section 1.2

Chapter 4: Root Finding

Chapter 12. Ordinary Differential Equation Boundary Value (BV) Problems

Chapter Newton s Method

EEE 241: Linear Systems

Single Variable Optimization

Lecture 2 Solution of Nonlinear Equations ( Root Finding Problems )

NUMERICAL DIFFERENTIATION

( ) [ ( k) ( k) ( x) ( ) ( ) ( ) [ ] ξ [ ] [ ] [ ] ( )( ) i ( ) ( )( ) 2! ( ) = ( ) 3 Interpolation. Polynomial Approximation.

Section 3.6 Complex Zeros

2 Finite difference basics

: Numerical Analysis Topic 2: Solution of Nonlinear Equations Lectures 5-11:

Generalized Linear Methods

Math1110 (Spring 2009) Prelim 3 - Solutions

Lecture 13 APPROXIMATION OF SECOMD ORDER DERIVATIVES

Advanced Algebraic Algorithms on Integers and Polynomials

Negative Binomial Regression

Linear Feature Engineering 11

Complex Numbers Alpha, Round 1 Test #123

Errors for Linear Systems

6.1 The function can be formulated as a fixed-point iteration as

The univariate Bernstein-Bézier form

MLE and Bayesian Estimation. Jie Tang Department of Computer Science & Technology Tsinghua University 2012

Differentiating Gaussian Processes

ADVANCED MACHINE LEARNING ADVANCED MACHINE LEARNING

For now, let us focus on a specific model of neurons. These are simplified from reality but can achieve remarkable results.

Analytical Chemistry Calibration Curve Handout

An efficient algorithm for multivariate Maclaurin Newton transformation

Numerical Algorithms for Visual Computing 2008/09 Example Solutions for Assignment 4. Problem 1 (Shift invariance of the Laplace operator)

Implicit Integration Henyey Method

1 Matrix representations of canonical matrices

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

Report on Image warping

CHAPTER 4d. ROOTS OF EQUATIONS

OPTIMISATION. Introduction Single Variable Unconstrained Optimisation Multivariable Unconstrained Optimisation Linear Programming

10-701/ Machine Learning, Fall 2005 Homework 3

is the calculated value of the dependent variable at point i. The best parameters have values that minimize the squares of the errors

Lecture 21: Numerical methods for pricing American type derivatives

Finite Differences, Interpolation, and Numerical Differentiation

CISE301: Numerical Methods Topic 2: Solution of Nonlinear Equations

The Geometry of Logit and Probit

Complex Numbers. x = B B 2 4AC 2A. or x = x = 2 ± 4 4 (1) (5) 2 (1)

MTH 263 Practice Test #1 Spring 1999

Summary with Examples for Root finding Methods -Bisection -Newton Raphson -Secant

LINEAR REGRESSION MODELS W4315

Some Comments on Accelerating Convergence of Iterative Sequences Using Direct Inversion of the Iterative Subspace (DIIS)

β0 + β1xi. You are interested in estimating the unknown parameters β

IV. Performance Optimization

SPANC -- SPlitpole ANalysis Code User Manual

Problem Set 9 Solutions

C/CS/Phy191 Problem Set 3 Solutions Out: Oct 1, 2008., where ( 00. ), so the overall state of the system is ) ( ( ( ( 00 ± 11 ), Φ ± = 1

Bezier curves. Michael S. Floater. August 25, These notes provide an introduction to Bezier curves. i=0

π e ax2 dx = x 2 e ax2 dx or x 3 e ax2 dx = 1 x 4 e ax2 dx = 3 π 8a 5/2 (a) We are considering the Maxwell velocity distribution function: 2πτ/m

2. PROBLEM STATEMENT AND SOLUTION STRATEGIES. L q. Suppose that we have a structure with known geometry (b, h, and L) and material properties (EA).

Curve Fitting with the Least Square Method

Lecture 10 Support Vector Machines. Oct

Module 3: Element Properties Lecture 1: Natural Coordinates

Calculation of time complexity (3%)

ME 501A Seminar in Engineering Analysis Page 1

Homework Assignment 3 Due in class, Thursday October 15

Bézier curves. Michael S. Floater. September 10, These notes provide an introduction to Bézier curves. i=0

CS 331 DESIGN AND ANALYSIS OF ALGORITHMS DYNAMIC PROGRAMMING. Dr. Daisy Tang

Lecture Notes on Linear Regression

= = = (a) Use the MATLAB command rref to solve the system. (b) Let A be the coefficient matrix and B be the right-hand side of the system.

36.1 Why is it important to be able to find roots to systems of equations? Up to this point, we have discussed how to find the solution to

Convexity preserving interpolation by splines of arbitrary degree

Digital Signal Processing

Newton s Method for One - Dimensional Optimization - Theory

STAT 3340 Assignment 1 solutions. 1. Find the equation of the line which passes through the points (1,1) and (4,5).

Singular Value Decomposition: Theory and Applications

β0 + β1xi. You are interested in estimating the unknown parameters β

Introduction to Regression

Denote the function derivatives f(x) in given points. x a b. Using relationships (1.2), polynomials (1.1) are written in the form

Formal solvers of the RT equation

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0

Inexact Newton Methods for Inverse Eigenvalue Problems

COMPLEX NUMBERS AND QUADRATIC EQUATIONS

What would be a reasonable choice of the quantization step Δ?

Learning Theory: Lecture Notes

ECONOMICS 351*-A Mid-Term Exam -- Fall Term 2000 Page 1 of 13 pages. QUEEN'S UNIVERSITY AT KINGSTON Department of Economics

CALCULUS CLASSROOM CAPSULES

Army Ants Tunneling for Classical Simulations

Statistical analysis using matlab. HY 439 Presented by: George Fortetsanakis

November 5, 2002 SE 180: Earthquake Engineering SE 180. Final Project

From Biot-Savart Law to Divergence of B (1)

Min Cut, Fast Cut, Polynomial Identities

STAT 511 FINAL EXAM NAME Spring 2001

Topic 5: Non-Linear Regression

Solutions HW #2. minimize. Ax = b. Give the dual problem, and make the implicit equality constraints explicit. Solution.

THE ARIMOTO-BLAHUT ALGORITHM FOR COMPUTATION OF CHANNEL CAPACITY. William A. Pearlman. References: S. Arimoto - IEEE Trans. Inform. Thy., Jan.

Richard Socher, Henning Peters Elements of Statistical Learning I E[X] = arg min. E[(X b) 2 ]

ˆ (0.10 m) E ( N m /C ) 36 ˆj ( j C m)

Root Locus Techniques

One-sided finite-difference approximations suitable for use with Richardson extrapolation

STAT 405 BIOSTATISTICS (Fall 2016) Handout 15 Introduction to Logistic Regression

Lecture 10 Support Vector Machines II

14 The Postulates of Quantum mechanics

Week 5: Neural Networks

SOLVING NON-LINEAR SYSTEMS BY NEWTON s METHOD USING SPREADSHEET EXCEL Tay Kim Gaik Universiti Tun Hussein Onn Malaysia

Transcription:

8 polynomal nterpolaton 3.1.6 a 7 6 5 4 3 2 1 0 0 0.2 0.4 0.6 0.8 1 x

5 polynomal nterpolaton 3.1.6 b 4.5 4 3.5 3 2.5 2 1.5 1 0.5 0 1 0.5 0 0.5 1 x

output.txt Oct 17, 11 5:21 Page 1/1 >> prob1 Part a z0 z1 z2 teratons root 1.00000000 2.00000000 3.00000000 5 4.12310563 + 0.00000000 4.00000000 4.50000000 5.00000000 4 4.12310563 + 0.00000000 0.00000000 1.00000000 2.00000000 9 2.49999999 + 1.32287554 the remanng root s conjugate of the prevous one double check wth Matlab: 4.123105625617665 4.123105625617663 2.499999999999999 + 1.322875655532298 2.499999999999999 1.322875655532298 Part b z0 z1 z2 teratons root 5.00000000 4.00000000 3.00000000 4 3.54823290 + 0.00000000 3.00000000 4.00000000 5.00000000 4 4.38111344 + 0.00000000 0.00000000 1.00000000 2.00000000 5 0.58355973 + 1.49418801 the remanng root s conjugate of the prevous one double check wth Matlab: 4.381113440995941 3.548232897979697 0.583559728491880 + 1.494188006011256 0.583559728491880 1.494188006011256 >> prob3 B&F 3.1.6 a and 3.1.8 a degree Lagrange Newton err bound 1 5.5643e 02 5.5643e 02 1.1294e 01 2 1.4298e 02 1.4298e 02 2.4094e 02 3 2.5560e 03 2.5560e 03 5.1801e 03 B&F 3.1.6 b and 3.1.8 b degree Lagrange Newton err bound 1 6.6406e 02 6.6406e 02 2.5000e 01 2 4.6876e 02 4.6876e 02 3.1250e 02 3 1.5626e 02 1.5626e 02 1.5625e 02 >> Oct 17, 11 5:21 Page 1/1 HW 4 Problem 1 B&F 2.6.4 a,b tol = 1e 5; maxt = 20; format long fprntf( Part a \n ); p = [1 5 9 85 136]; fprntf( 13s 13s 13s 8s 13s\n, z0, z1, z2, teratons, root ); z0=1; z1=2; z2=3; fprntf( 13.8f 13.8f 13.8f 8d 13.8f + 13.8f\n,z0,z1,z2,k,real(z),mag(z)); z0= 4; z1= 4.5; z2= 5; fprntf( 13.8f 13.8f 13.8f 8d 13.8f + 13.8f\n,z0,z1,z2,k,real(z),mag(z)); z0=0; z1=1; z2=2; fprntf( 13.8f 13.8f 13.8f 8d 13.8f + 13.8f\n,z0,z1,z2,k,real(z),mag(z)); fprntf( the remanng root s conjugate of the prevous one\n ); fprntf( double check wth Matlab:\n ); dsp(roots(p)); prob1.m fprntf( Part b \n ); p = [1 2 12 16 40]; fprntf( 13s 13s 13s 8s 13s\n, z0, z1, z2, teratons, root ); Prnted by Fernando Guevara Vasquez z0= 5; z1= 4; z2= 3; fprntf( 13.8f 13.8f 13.8f 8d 13.8f + 13.8f\n,z0,z1,z2,k,real(z),mag(z)); z0=3; z1=4; z2=5; fprntf( 13.8f 13.8f 13.8f 8d 13.8f + 13.8f\n,z0,z1,z2,k,real(z),mag(z)); z0=0; z1=1; z2=2; fprntf( 13.8f 13.8f 13.8f 8d 13.8f + 13.8f\n,z0,z1,z2,k,real(z),mag(z)); fprntf( the remanng root s conjugate of the prevous one\n ); fprntf( double check wth Matlab:\n ); dsp(roots(p)); Monday October 17, 2011 output.txt, prob1.m 1/5

Oct 16, 11 1:49 Page 1/3 HW4 Problem 3 B&F 3.1.6 a and 3.1.8 a fprntf( B&F 3.1.6 a and 3.1.8 a \n ); nterpolaton node abscssas (we reordered st the node at whch we evaluate the nterpolaton s always nsde the nterval) xd = [0.25,0.5,0.75,0]; ordnates yd = [1.64872, 2.71828, 4.48169,1]; evaluaton pont x = 0.43; true functon (USING VECTORIZED OPERATIONS) f = @(x) exp(2*x); The functon and frst few dervatves are: f(z) = exp(2*x) f (z) = 2*exp(2*x) f (z) = 4*exp(2*x) f (z) = 8*exp(2*x) f (z) = 16*exp(2*x) here we gve the part of the bound dependng on f. It would be better to fnd the max of ths functons over the nterpolaton nterval [0,0.75] for nterp poly of degree 1 we bound f fmax(1) = 4*exp(2*0.75); for nterp poly of degree 2 we bound f fmax(2) = 8*exp(2*0.75); for nterp poly of degree 2 we bound f fmax(3) = 16*exp(2*0.75); vectors to store nterpolaton polynomal evaluated at x and error lagr = zeros(3,1); newt = zeros(3,1); err = zeros(3,1); for k=1:3, loop on degree Lagrange nterpolaton lttle trck to take only the frst k nodes lagr(k) = lagrange(xd(1:k+1),yd(1:k+1),x); Newton nterpolaton usng dvded dfferences d = newtondd(xd(1:k+1),yd(1:k+1)); newt(k) = newtonev(xd(1:k+1),d,x); compute error bound err(k) = fmax(k)/factoral(k+1); for j=1:k+1; err(k) = err(k)*(x xd(j)); for j for k prob3.m dsplay errors fprntf( 10s 13s 13s 13s\n, degree, Lagrange, Newton, err bound ); for k=1:3, fprntf( 10d 13.4e 13.4e 13.4e\n, k,abs(lagr(k) f(x)),abs(newt(k) f(x)),abs(err(k))); for k Show all three nterpolaton polynomals n a plot fgure(1); IF DOING MORE THAN ONE FIGURE, CHANGE FIGURE NUMBER clf; clears fgure xs = lnspace(0,1); equally space ponts n an nterval contanng nterp. po Oct 16, 11 1:49 Page 2/3 nts we are gong to do several plots, so we tell Matlab to accumulate all the plot commands hold on; Plots the true functon plot(xs,f(xs), r ); Plots the nterpolaton nodes plot(xd,yd, * ); Plot the nterpolaton polynomals for k=1:3, Newton nterpolaton usng dvded dfferences d = newtondd(xd(1:k+1),yd(1:k+1)); newt = newtonev(xd(1:k+1),d,xs); plot(xs,newt, b ); We don t want to add anymore plots to the current fgure hold off; put some labels xlabel( x ); ttle( polynomal nterpolaton 3.1.6 a ); prnt to a fle prnt( depsc2, prob3_a.eps ); B&F 3.1.6 b and 3.1.8 b fprntf( B&F 3.1.6 b and 3.1.8 b \n ); prob3.m nterpolaton node abscssas (we reordered st the node at whch we evaluate the nterpolaton s always nsde the nterval) xd = [ 0.25,0.25, 0.5,0.5]; ordnates yd = [1.33203, 0.800781, 1.93750, 0.687500]; evaluaton pont x = 0; true functon (USING VECTORIZED OPERATIONS) f = @(x) x.^4 x.^3 + x.^2 x +1; The functon and frst few dervatves are: f(z) = z^4 z^3 + z^2 z +1 f (z) = 4*z^3 3*z^2 + 2*z 1 f (z) = 12*z^2 6*z + 2 f (z) = 24*z 6 f (z) = 24 here we gve the part of the bound dependng on f. It would be better to fnd the max of ths functons over the nterpolaton nterval [0,0.75] for nterp poly of degree 1 we bound f fmax(1) = 12*( 0.5)^2 6*( 0.5) + 2; for nterp poly of degree 2 we bound f fmax(2) = 24*0.5 6; for nterp poly of degree 2 we bound f fmax(3) = 24; vectors to store nterpolaton polynomal evaluated at x and error lagr = zeros(3,1); newt = zeros(3,1); err = zeros(3,1); for k=1:3, loop on degree Lagrange nterpolaton lttle trck to take only the frst k nodes lagr(k) = lagrange(xd(1:k+1),yd(1:k+1),x); Prnted by Fernando Guevara Vasquez Monday October 17, 2011 prob3.m 2/5

Oct 16, 11 1:49 prob3.m Page 3/3 Newton nterpolaton usng dvded dfferences d = newtondd(xd(1:k+1),yd(1:k+1)); newt(k) = newtonev(xd(1:k+1),d,x); compute error bound err(k) = fmax(k)/factoral(k+1); for j=1:k+1; err(k) = err(k)*(x xd(j)); for j for k dsplay errors fprntf( 10s 13s 13s 13s\n, degree, Lagrange, Newton, err bound ); for k=1:3, fprntf( 10d 13.4e 13.4e 13.4e\n, k,abs(lagr(k) f(x)),abs(newt(k) f(x)),abs(err(k))); for k Show all three nterpolaton polynomals n a plot fgure(2); clf; clears fgure xs = lnspace( 1,1); equally space ponts n an nterval contanng nterp. p onts we are gong to do several plots, so we tell Matlab to accumulate all the plot commands hold on; Plots the true functon plot(xs,f(xs), r ); Plots the nterpolaton nodes plot(xd,yd, * ); Plot the nterpolaton polynomals for k=1:3, Newton nterpolaton usng dvded dfferences d = newtondd(xd(1:k+1),yd(1:k+1)); newt = newtonev(xd(1:k+1),d,xs); plot(xs,newt, b ); We don t want to add anymore plots to the current fgure hold off; put some labels xlabel( x ); ttle( polynomal nterpolaton 3.1.6 b ); prnt to a fle prnt( depsc2, prob3_b.eps ); Oct 17, 11 5:19 Page 1/1 functon [z3,k] = muller(z0,z1,z2,p,maxt,tol) Fnds a polynomal root gven the ntal guesses z0,z1,z2 usng a quadratc mode (Muller s method). Ths method allows convergence to a complex root even f the z0,z1,z2 are real. Inputs z0,z1,z2 ntal guesses p vector of polynomal coeffcents, from hghest to lowest degree maxt maxmum number of teraton tol tolerance Outputs z3 approxmaton of the root k number of teratons functon [z3,k] = muller(z0,z1,z2,p,maxt,tol) [q,fz0] = horner(p,z0); [q,fz1] = horner(p,z1); [q,fz2] = horner(p,z2); for k=1:maxt, compute coeffcents of quadratc c = fz2; h1 = z1 z0; h2 = z2 z1; d1 = (fz1 fz0)/h1; d2 = (fz2 fz1)/h2; a = (d2 d1)/(z2 z0); b = d2 +h2*a; double check that a,b,c are OK qd = @(z) a*(z z2)^2 + b*(z z2) + c; quadratc model [qd(z2) fz2, qd(z1) fz1, qd(z0) fz0] quadratc model should nterp f delta = sqrt(b^2 4*a*c); choose root wth smallest magntude f (abs(b delta)<abs(b+delta)) z3 = z2 + ( b+delta)/2/a; else z3 = z2 + ( b delta)/2/a; check convergence f abs(z3 z2)<tol break; prepare next teraton [q,fz3] = horner(p,z3); muller.m f (abs(fz3)<tol) break; fz0=fz1; z0=z1; fz1=fz2; z1=z2; fz2=fz3; z2=z3; Prnted by Fernando Guevara Vasquez Monday October 17, 2011 prob3.m, muller.m 3/5

Prnted by Fernando Guevara Vasquez Sep 28, 11 9:15 horner.m Page 1/1 Horner s algorthm to dvde a polynomal p by the lnear factor z z0.e. p(z) = q(z) (z z0) + r Inputs p vector of polynomal coeffcents, from hghest to lowest degree z0 root of lnear factor Outputs q vector of polynomal coeffcents for the quotent polynomal r resdual functon [q,r] = horner(p,z0) n = length(p); q = zeros(sze(p)); q(1) = p(1); for k=1:n 1, q(k+1) = p(k+1) + z0 * q(k); r = q(n); q = q(1:n 1); Sep 28, 11 9:14 Page 1/1 functon y = lagrange(xd,yd,x) Evaluates Lagrange nterpolaton polynomal at some ponts Inputs: xd absssa of data ponts yd ordnate of data ponts x abscssa where we want to evaluate Lagrange nterp. polynomal Outputs: y p(x) One way ot test ths s to run the followng: x = lnspace(0,5); xd = [1 2 3 4]; yd = [ 1 2 2 5]; y = lagrange(xd,yd,x) ; plot(x,y,xd,yd, r+ ) functon y = lagrange(xd,yd,x) y = zeros(sze(x)); for =1:length(xd), yb = yd(); for j=1:length(xd), f (j ) yb = yb.* (x xd(j))/(xd() xd(j)); y = y + yb; lagrange.m Monday October 17, 2011 horner.m, lagrange.m 4/5

Prnted by Fernando Guevara Vasquez newtondd.m Sep 28, 11 9:14 Page 1/1 computes Newton s dvded dfferences, needs only a vector for storage Inputs x nterpolaton nodes f functon values Outputs d coeffcents of Newton nterpolaton polynomal One way ot test ths s to run the followng: x = lnspace(0,5); xd = [1 2 3 4]; yd = [ 1 2 2 5]; d = newtondd(xd,yd); y = newtonev(xd,d,x); plot(x,y,xd,yd, r+ ) functon d = newtondd(x,f) n = length(x) 1; f (length(f) n+1) fprntf( length of nput vectors must be the same ); d = f; for j=1:n, for =n: 1:j, d(+1) = (d(+1) d())/(x(+1) x( j+1)); Sep 28, 11 9:14 Page 1/1 functon y = newtonev(xd,d,x) uses Horner s algorthm to evaluate the Newton nterpolaton polynomal at the ponts x, where the nterpolaton nodes are gven n xd Inputs xd nterpolaton nodes d coeffcents of the Newton nterpolaton polynomal x ponts of evaluaton of the Newton nterpolaton polynomal Outputs y p(x) functon y = newtonev(xd,d,x) santy check f (length(d) length(xd)) error( there must be as many dvded dfferences as nterpolaton nodes ); n = length(d); y = zeros(sze(x)); Horner s algorthm y = d(n); for k=n 1: 1:1, y = (x xd(k)).*y + d(k); newtonev.m Monday October 17, 2011 newtondd.m, newtonev.m 5/5