Question: Exercise 3 (6 points) In this exercise you will be given a set of polynomials B. You will determine whether it is a basis for

Exercise 3 (6 points) In this exercise you will be given a set of polynomials B. You will determine whether it is a basis for the corresponding space of the polynomials. This could be done by using the isomorphism between a linear space of polynomials and R^n, for the corresponding n. If P, which is the matrix of the E-coordinates of the polynomials in B, is a basis, your function will (1) find a vector y of the B-coordinates of the polynomial Q (originally Q is written through the standard basis); and (2) write a given polynomial R through the standard basis if you are given the vector r of its B-coordinates.

**First, you should create the following function in MATLAB, if you have not done it yet, that will help you to run the code and also will be used later for presentation of a matrix with some entries close to 0:

function B=closetozeroroundoff(A)

[m,n]=size(A);

for i=1:m

for j=1:n

if abs(A(i,j))<10^(-7)

A(i,j) = 0;

end

end

end

B=A;

**Then, you will create a

function P =polyspace(B,Q,r)

where B=[B1,b2,...Bn]s a vector whose components are polynomials from the vector space P_n-1 of the polynomials of degree at most (n-1), Q is a single polynomial from the same space P_n-1 and r is a vector with n components.

Note on the form of a polynomial: for the purpose of this program, it is required that the coefficient of the degree x^n-1 must not be zero. However, the zero coefficient is accepted by the definition of the space P_n-1and some of the given polynomials do not have term x^n-1 that is, the coefficient is zero at x^n-1 To be able to work with such polynomials, we insert the coefficient 10^(-8) of x^n-1, and it will be converted into a 0 after you run the function closetozeroroundoff in your code.

**You should begin writing the function polyspace with the commands:

format rat,

u=sym2poly(B1);

n=length(u);

The command sym2poly(B1) takes the coefficients of the polynomial B1 (written through the standard basis in the descending order according to the degree) and writes them as a row vector (a 1xnmatrix).

Note: The number n is the dimension of the vector space P_n-1, thus, P_n-1 s isomorphic to the Euclidean space R^n The number n will be used later in this program.

**To use the isomorphism, you will create an nxn matrix C, whose columns are the vectors of coefficients of the polynomials in the set B, and then you will convert to 0 the entries that are close to zero to get the matrix P. Here is a suggested code:

C=zeros(n);

for i=1: n

C( : , i) = transpose(sym2poly(B(i)));

end

P=closetozeroroundoff(C);

Then you will check if P is a basis for R^n. I suggest using the command rank.

If P is not a basis, the program terminates and outputs the reduced echelon form matrix A of the matrix P, A=rref(P) with a comment.

The set of commands that outputs the results for this part may have a form:

sprintf(the polynomials in B do not form a basis for P%d,n-1)

fprintf(the reduced echelon form of P is % \ n)

A=rref(P)

return

**If B is a basis, create a message indicating that the polynomials in B form a basis for the corresponding space of the polynomials, and your function will continue with two more tasks:

(1) Find a row vector y of B-coordinates of the polynomial Q. Your output for this part should contain a message and the row vector y. The message might have a form:

fprintf(the coordinates of the polynomial Q with respect to the basis P are % \ n)

y = closetozeroroundoff(y)

(Hint: to find y, you will be solving a system of equations)

(2) Find the coordinate vector q of the polynomial R with respect to the standard basis, whose B-coordinates is the given vector r.

(Hint: you will be using matrix-vector multiplication to find q.)

Then, calculate the vector:

q=transpose(closetozeroroundoff(q));

The outputs have to be a message similar to the one for part(1) as well as the polynomial R written through the standard basis E using the entries of the vector q as coefficients. Use the command poly2sym applied to the row vector q to get the polynomial R in the required form.

**Type the functions closetozeroroundoff and polyspace in your diary file.

**Then type:

syms x

The last command will allow you to type the polynomials in the variable x in usual way. For example, you will type a polynomial in MATLAB command window as Q=x^3+3*x^2-1. If you do not put semicolon at the end of the line and hit enter, you will see the polynomial that you have typed.

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!