ma/cs 375 fall 20021 ma/cs 375 fall 2002 lecture 23

Download MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 23

If you can't read please download the document

Upload: ashlee-adams

Post on 19-Jan-2018

221 views

Category:

Documents


0 download

DESCRIPTION

MA/CS 375 Fall Runge Phenomenon Theorem 2 (van Loan page 90) –Suppose If(x) is an N-1’th order interpolating polynomial of the function f at N distinct points x 1,x 2,..,x N. If f is N times continuously differentiable on an interval I containing the {x 1,x 2,..,x N } then for any x in I=[a,b]:

TRANSCRIPT

MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 23 MA/CS 375 Fall Class Exercise Part 1: Build a function called vandermonde.m which accepts a vector of x values and a polynomial order P In the function find N=length of x Function returns a matrix V which is Nx(P+1) and whose entries are: V(n,m) = (x n ) (m-1) Part 2: Translate this pseudo-code to a Matlab script: for N=1:5:20 build x = set of N points in [-1,1] build f = exp(x) build xfine = set of 10N points in [-1,1] build Vorig = vandermonde(N-1,x) build Vfine = vandermonde(N-1,xfine) build Finterp = Vfine*(Vorig\f); plot x,f and xfine,Finterp on the same graph end MA/CS 375 Fall Runge Phenomenon Theorem 2 (van Loan page 90) Suppose If(x) is an N-1th order interpolating polynomial of the function f at N distinct points x 1,x 2,..,x N. If f is N times continuously differentiable on an interval I containing the {x 1,x 2,..,x N } then for any x in I=[a,b]: MA/CS 375 Fall Runge Phenomenon If we base the interpolant on the equi- spaced points then after some basic math we can show: where M N bounds the Nth derivative MA/CS 375 Fall Runge Phenomenon If we base the interpolant on the equi-spaced points then after some basic math we can show: where M N bounds the Nth derivative Hence if the Nth derivative is badly behaved this bound suggests the quality of interpolation may decrease with increasing N!!. MA/CS 375 Fall Example: Runge Phenomenon Use your Vandermonde routine to interpolate the function: for 10,20,30,40,50,60 points on the interval [-1,1] Volunteer to describe what happens MA/CS 375 Fall Interpolating in Two Directions A picture (e.g. jpeg, tif or gif) is actually an array of pixel values There are a number of ways to represent color on the pixel. 1)gif uses a colormap, indexed by an integer 2)jpeg uses an 8 bit number for each component of red, green and blue MA/CS 375 Fall Loading an Image in Matlab % read in the three dimensional array pic = imread(foo.jpg); red = pic(:,:,1); green = pic(:,:,2); blue = pic(:,:,3); MA/CS 375 Fall Double The Resolution In Each Direction Using 4 th order Interpolation MA/CS 375 Fall Results From Interpolation Notice 600 pixelsNotice 300 pixels MA/CS 375 Fall Details of Interpolation MA/CS 375 Fall Details of Interpolation Notice reduced pixellation on new image MA/CS 375 Fall But Not So Fast MA/CS 375 Fall Now try 10 th order interpolation MA/CS 375 Fall Not So Good! Note stripes appearing on new image MA/CS 375 Fall Close Up of 10 th Order Interpolation Looks quite bad!!! MA/CS 375 Fall Whats Going On We have divided each line of the picture into non-overlapping sections, containing 10 points each. We have then interpolated the picture values at the 10 points to 20 points on the same section The equispaced points lead to the Runge phenomenon i.e. highly oscillatory interpolants at the ends of each section How can we make this better? MA/CS 375 Fall Team Exercise ( a little tricky feel free to use loops) Even for 10+ points the interpolant function is probably going to be ok at the center of the region. 1)build VDM for N points (N even) 2)build weights = VDM\(1;0;0;;0) 3)load in your jpeg picture 4) now use these weights to build the interpolating values between each given points MA/CS 375 Fall Nth Order Mid-point Interpolation MA/CS 375 Fall Nth Order Mid-point Interpolation MA/CS 375 Fall Nth Order Mid-point Interpolation MA/CS 375 Fall Summary So we have started to invert general matrix systems to obtain interpolating polyomial coefficients We saw the Runge phenomenon in action when equi-spaced interpolation is used We improved things somewhat by ignoring the interpolating polynomial away from the center of its range. MA/CS 375 Fall Next Time Using Matlabs built in interpolation routine Morphing images class project