given simple code in Matlab A clear xlinspace10101000 yx394x
given: simple code in Matlab
A.
clear;
x=linspace(-10,10,1000);
y=x.^3-((9/4)*(x.^2))-((71/8)*x)+(15/2);
figure(1)
plot(x,y);
xlabel(\'x\');
ylabel(\'y\');
title(\'y=x^3-(9/4)x^2-(71/8)x+(15/2)\');
hold on
Y=0;
plot(x,Y,\'--\',\'LineWidth\',2);
grid on
Question:
1. Look up the command roots in the MATLAB help and use it to find the roots of the poly-
nomial in part A. Do the computational results match your findings in part A-5?
Solution
code:
%y=x.^3-((9/4)*(x.^2))-((71/8)*x)+(15/2);
p = [1,-9/4,-71/8,15/2];
r = roots(p);
disp(r);
for i=1:3
x = r(i);
y=x.^3-((9/4)*(x.^2))-((71/8)*x)+(15/2);
disp(y);
end
result:
4.0000
-2.5000
0.7500
9.2371e-014
-3.1974e-014
0
