Problem 1-Consider the following function: (x)--3-1. Then complete part (a) by M
ID: 3908960 • Letter: P
Question
Problem 1-Consider the following function: (x)--3-1. Then complete part (a) by MATLAB, and (b) and (c) by hand calculations. (a) Plot the function with an appropriate range of x such that all real roots are clearly visible. (b) Find the lowest root with bisection method. Start by choosing an appropriate bracket from observing the plot from part (a). Iterate twice. Clearly show bracket locations for each iteration. Evaluate function values and approximate relative percent errors. Generate an iteration table similar to the one that was used in lab handout. (c) Find the second lowest root with false position method. The rest is similar to (b). Iterate twice and generate an iteration table.Explanation / Answer
a)
p=[1 0 -3 -1] % making matrix of polynomial
r=roots(p) % calulating roots
r1 = r(imag(r)==0); % check for real roots
r1 % displaying real roots
f = @(x) x.^3-3*x-1;
x = -2:0.1:2; %interval [-2,2] well contained under 1.13 and -0.74
plot(x,f(x)) %plot the funtion
grid on
hold on
plot(r1,'bx') % plot real root as blue cross
b)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.