Menu

(Solved) : 2a Write Python Function Construct Vandermonde Matrix Arises Linear System Solve Coefficie Q44054128 . . .

Python. Please help2a) Write a python function to construct the Vandermonde matrix that arises in the linear system to solve for coefficients in= 4. 2b) Test out your function for m = Form the appropriate Vandermonde system and compute the solution using your linear so2c) Construct Vandermonde matrices of size m E [6, 12], and consider the sensitivity of the results to changes in the data. T2d) For larger problems, computing the matrix inverse can be expensive so we would like to avoid it. The alternative approach2e) We discussed the normal equations that arise when the linear system is pre-multiplied by A. Compute the condition numb

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] uniform distribution on [-0.25,0.25]. (You should use a python library function to generate the random values.) X[i] + r[i] where r is an array of values selected from a In [ ]: = 4. 2b) Test out your function for m = 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? In [ ]: 2c) Construct Vandermonde matrices of size m E [6, 12], and consider the sensitivity of the results to changes in the data. The relevant “theoretical” result involves the condition number: K(A) = ||A-‘|l2 ||A||2- ||Ax|l2 ||x||2 ||A||2 is the Euclidean matrix norm defined by ||A||2 but you should not need to code this up. Use a function from the numpy linear algebra package. Compute this expression for the condition number for each of your Vandermonde matrices, and plot condition number as a function of size. In [ ]: 2d) For larger problems, computing the matrix inverse can be expensive so we would like to avoid it. The alternative approach is “experimental”: quantify how the solution changes as a result of a small change to the input data. In particular, change the problem by adding a second random component s[i] to your function values with s[i] uniformly distributed on [-0.01,0.01]. Compute the following ratio as a measure of sensitivity: (norm of change in output) / (norm of change in input) Compare the “experimental” sensitivity to the “theoretical” condition number values computed in 2c. 2e) We discussed the “normal equations” that arise when the linear system is pre-multiplied by A”. Compute the condition number for normal equations for the same problems considered in 2c. Plot the condition number results. Compare with the results from 2c and discuss the implications. [ ): Show transcribed image text 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] uniform distribution on [-0.25,0.25]. (You should use a python library function to generate the random values.) X[i] + r[i] where r is an array of values selected from a In [ ]:
= 4. 2b) Test out your function for m = 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? In [ ]:
2c) Construct Vandermonde matrices of size m E [6, 12], and consider the sensitivity of the results to changes in the data. The relevant “theoretical” result involves the condition number: K(A) = ||A-‘|l2 ||A||2- ||Ax|l2 ||x||2 ||A||2 is the Euclidean matrix norm defined by ||A||2 but you should not need to code this up. Use a function from the numpy linear algebra package. Compute this expression for the condition number for each of your Vandermonde matrices, and plot condition number as a function of size. In [ ]:
2d) For larger problems, computing the matrix inverse can be expensive so we would like to avoid it. The alternative approach is “experimental”: quantify how the solution changes as a result of a small change to the input data. In particular, change the problem by adding a second random component s[i] to your function values with s[i] uniformly distributed on [-0.01,0.01]. Compute the following ratio as a measure of sensitivity: (norm of change in output) / (norm of change in input) Compare the “experimental” sensitivity to the “theoretical” condition number values computed in 2c.
2e) We discussed the “normal equations” that arise when the linear system is pre-multiplied by A”. Compute the condition number for normal equations for the same problems considered in 2c. Plot the condition number results. Compare with the results from 2c and discuss the implications. [ ):

Expert Answer


Answer to 2a) Write a python function to construct the Vandermonde matrix that arises in the linear system to solve for coefficien…

OR