Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: Write a function that solve for the coefficients of an nth order polynomial equation. The accuracy of these coefficients depends on the condition number

image text in transcribed

Assignment: Write a function that solve for the coefficients of an nth order polynomial equation. The accuracy of these coefficients depends on the condition number (see Case Study 11.3). Use VPA() (Variable Precision Arithmetic) to limit the accuracy of your output. You may use length() to determine the number of data point (n).

function [p] = myPolyInv (x, y)

% Solve for the coefficients of an nth order polynomial interpolation

% inputs: x = vector of x input points, y = vector of y input points, x and y have the same dimension

% output: p = coefficients p1 to pn with the available accuracy

[c] = myCondition (A); % A = coefficient matrix

end % end of function

Write a sub function, myCondition, to calculate the matrix condition number based on the coefficient matrix and inverse matrix calculated by using a second sub function, myInverse. For this assignment, use the Frobenius norm to determine the condition number. You may not use the Matlab built-in functions for matrix norm or for condition number. The condition number in Matlab uses a different norm, and the result will be different from the one you calculate. Use myInverse to obtain the inverse coefficient matrix to determine the condition number. Hence, myInverse should be included as a second sub function.

function [c] = myCondition (A)

% Determine the condition number, using the Frobenius norm

% inputs: A = Coefficient matrix

% output: c = Condition number of coefficient matrix

[L, U, B] = myInverse (A)

end % end of function

For this assignment, matrix inverse should be determined by using the LU factorization as shown in Section 10.1. You may not use any of the built-in Matlab functions to solve for linear equations, including the left division operator. The inverse function should have the form:

function [L, U, B] = myInverse (A)

% Solve for the Inverse of A using L U factorization

% input: A = Coefficient matrix

% output

% U = Upper triangular matrix, L = Lower triangular matrix, B = Inverse matrix of A

end % end of function

You may not use the Matlab built-in function for LU factorization or for matrix inversion such as lu() and inv(). Please note that solving for the inverse by using LU (cf. 11.1) requires the use of back substitution (Fig 9.4 of text), and a forward substitution similar to the backward substitution. You may check your results by using the Matlab built-in functions: lu(), inv(), cond(), etc.

Background: Polynomial interpolation consists of detennining the unique (n-1)s order polynomial that fits n data points. Such polynomials have the general form: Where the p's are unlnown constant coefficients. If we have n pairs of datasets that passes through the polynomial, f(x), a straightforward way for computing the constant coefficients is substituting the given pairs into the equation and generate the n linear algebraic equations, as a function of the coefficients Pi P. P. The resulting linear equation looks like this The coefficient matrix is known to be ill-conditioned (cf 11.2.2 for matrix condition). Background: Polynomial interpolation consists of detennining the unique (n-1)s order polynomial that fits n data points. Such polynomials have the general form: Where the p's are unlnown constant coefficients. If we have n pairs of datasets that passes through the polynomial, f(x), a straightforward way for computing the constant coefficients is substituting the given pairs into the equation and generate the n linear algebraic equations, as a function of the coefficients Pi P. P. The resulting linear equation looks like this The coefficient matrix is known to be ill-conditioned (cf 11.2.2 for matrix condition)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions