Answered step by step
Verified Expert Solution
Question
1 Approved Answer
To avoid starting from scratch, let's put some of our previous code into use. The instructions below walk you through how to save previously created
To avoid starting from scratch, let's put some of our previous code into use. The instructions below walk you through how to save previously created functions for solving linear systems in a file so that the function definitions can be readily imported for re-use. 2a) Write a python function to construct the Vandermonde matrix that arises in the linear system to solve for coefficients in polynomial interpolation. (The matrix should be very similar to an example from class.) Your function's input should include an array of input values and an array of corresponding function values and the degree, n, of the desired polynomial. In general, the number of data points m can be larger than the number of coefficients in the polynomial, but for the remainder of this problem you can make the following specializations: i) Focus on the case m = n + 1 that produces a square matrix. ii) Choose the input array x to consist of m values equally spaced across the unit interval [0, 1]. iii) Choose the array of function values so that y[i] = x[i] + r[i] where r is an array of values selected from a uniform distribution on (-0.25, 0.25). (You should use a python library function to generate the random values.) - [ ]: 2b) Test out your function for m = 4. Form the appropriate Vandermonde system and compute the solution using your linear solver code. Plot the input data and the computed degree 3 polynomial. Does your polynomial interpolate the data points? - [ ]: To avoid starting from scratch, let's put some of our previous code into use. The instructions below walk you through how to save previously created functions for solving linear systems in a file so that the function definitions can be readily imported for re-use. 2a) Write a python function to construct the Vandermonde matrix that arises in the linear system to solve for coefficients in polynomial interpolation. (The matrix should be very similar to an example from class.) Your function's input should include an array of input values and an array of corresponding function values and the degree, n, of the desired polynomial. In general, the number of data points m can be larger than the number of coefficients in the polynomial, but for the remainder of this problem you can make the following specializations: i) Focus on the case m = n + 1 that produces a square matrix. ii) Choose the input array x to consist of m values equally spaced across the unit interval [0, 1]. iii) Choose the array of function values so that y[i] = x[i] + r[i] where r is an array of values selected from a uniform distribution on (-0.25, 0.25). (You should use a python library function to generate the random values.) - [ ]: 2b) Test out your function for m = 4. Form the appropriate Vandermonde system and compute the solution using your linear solver code. Plot the input data and the computed degree 3 polynomial. Does your polynomial interpolate the data points? - [ ]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started