Answer in matlab code please 6.3 Determine the highest real root of f(x)=x3-6x2
ID: 3167365 • Letter: A
Question
Answer in matlab code please
6.3 Determine the highest real root of f(x)=x3-6x2 +1 1x-61 using the following techniques a) Graphically -don't forget to always add a title and axis labels. Add comment to your code identifying the solution, or add a text box to the figure b) Create a Newton-Raphson function and use it to solve this problem,with a starting value ofx 3.5. Assign a convergence factor ey such that the answer will have at least 3 significant figures c) Create a secant function and use it to solve this problem. Your two starting values should be x 2.5 and x-3.5. Assign a convergence factor ey such that the answer will have at least 3 significant figures d) Create a modified secant function and use it to solve this problem. The starting value of x should be 3.5 and 6-0.01. Assign a convergence factor, er such that the answer will have at least 3 significant figures. e) Use a built in MATLAB function, roots, to determine all the roots.IExplanation / Answer
Find the root using Newton-Raphson method:
Code:
fun=@(x) x^3-6*x^2+11*x-6.1;
x=3.5;
c_factor=0.001;
d=@(x) 3*x^2-12*x+11;
for i=1:100
x(i+1)=x(i)-((fun(x(i))/d(x(i))));
e(i)=abs((x(i+1)-x(i))/x(i));
if e(i)<c_factor
break
end
end
fprintf('The root of given equation is: %.4f ', x(i))
Find the root using secant method:
Code:
fun=@(x) x^3-6*x^2+11*x-6.1;
x(1)=2.5;
x(2)=3.5;
c_factor=0.001;
iter=0;
for i=3:1000
x(i) = x(i-1) - (fun(x(i-1)))*((x(i-1) - x(i-2))/(fun(x(i-1)) - fun(x(i-2))));
iter=iter+1;
if abs((x(i)-x(i-1))/x(i))*100<c_factor
fprintf('The root of given equation is: %.4f ',root=x(i))
fprintf('The iteration is: %d ',iter)
break
end
end
Find the root using modified secant method:
Code:
fun=@(x) x^3-6*x^2+11*x-6.1;
x(1)=2.5;
x(2)=3.5;
delta=0.01;
c_factor=0.001;
iter=0;
for i=3:1000
x(i) = x(i-1)-((delta*fun(x(i-1)))/(fun(x(i-1)+delta*x(i-2))-fun(x(i-2))));
iter=iter+1;
if abs((x(i)-x(i-1))/x(i))*100<c_factor
fprintf('The root of given equation is: %.4f ',root=x(i))
fprintf('The iteration is: %d ',iter)
break
end
end
(e)
Code:
fun = [1 -6 11 -6.1];
fprintf('All roots in the given equation')
roots(fun)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.