Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your task is to implement a function which computes 3-region sign chart, given a

ID: 2324587 • Letter: Y

Question

Your task is to implement a function which computes 3-region sign chart, given a polynomial.

Using Matlab, create a function with signature function [zs ss] = signchart(f).

The f input to signchart will be a symbolic polynomial (see below).

The zs output is a column vector of the unique zeros of the f.

The ss output is a column vector of the signs in regions. For example, if the sign pattern is --+ then ss == [-1; -1; 1].

Here is an example of how f will be constructed.

Hints

The solve will return solutions according to their multiplicity. The function length will tell you the number of elements in a vector. You may find the function unique useful. You can see how to use the functions:

Explanation / Answer

function [zs ss] = signchart(f)
syms x
f = x^2+2*x+1;
zs1 = solve(f==0);
zs = unique(zs1)
tol = 0.001;
for i = 1:length(zs)
x = (zs(i)-tol);
y = subs(f);
if y < 0
ss(i) = -1;
else
ss(i) = 1;
end
end
fprintf('OUTPUT ss: %d ',ss);
%fprintf('OUTPUT zs: %d ',zs);
end