Question: Given a function f(x) and n+1 numbers {i}i=1n+1 with the i 's distinct, consider the problem of finding an nth degree polynomial pn such that

 Given a function f(x) and n+1 numbers {i}i=1n+1 with the i

Given a function f(x) and n+1 numbers {i}i=1n+1 with the i 's distinct, consider the problem of finding an nth degree polynomial pn such that pn(i)=f(i)(i=1,,n+1); that is pn is the polynomial that interpolates the given function. Since pn is polynomial of degree n, we can write pn(x)=anxn+an1xn1+a1x+a0=j=0najxj for some constants ajR. Hence the problem reduces to finding the coefficients {aj}j=0n such that j=0najij=f(i)(i=1,2,,n+1); that is an1n+an11n1++a11+a0=f(1),an2n+an12n1++a12+a0=f(2),ann+1n+an1n+1n1++a1n+1+a0=f(n+1). Putting this (n+1)(n+1) system of linear equations in matrix form, we have Ax=b with A=1n2n3nn1nnnn+1n1n12n13n1n1n1nn1n+1n11n22n23n2n1n2nn2n+1n2122232n12n2n+12123n1nn+1111111,x=anan1an2a2a1a0,b=f(1)f(2)f(3)f(n1)f(n)f(n+1) The matrix A is called a Vandermonde matrix, which has many interesting properties. One of which is that it is non-singular provided i=j if i=j. Another is that it is horribly ill-conditioned if the i 's are close to each other and n is large. In this project you will solve a Vandermonde matrix by Gaussian elimination with pivoting to interpolate the function f(x)=sin(5x) over the interval [1,1]. Your program should do the following: (1) Ask the user for the value of n (the polynomial degree) using the input command. If the given value of n is less than zero or not an integer, then the program should display an error message and quit. (2) Create the set of numbers {1,2,3,n+1}[1,1] that are equidistant from each other. I suggest you use the linspace command to do this (although it is not necessary); see Matlab's product help menu for details. (3) Create the Vandermonde matrix, A, using the points {i}i=1n+1 you created. You may use the built-in Matlab command vander to do this. Again, see Matlab's product help menu for details. (4) Create the vector b=[sin(51)sin(52)sin(5n)sin(5n+1)]T

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!