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

code in matlab is required. not in C++ Given f(x)2r - 1.5x4 10x 2 Use the follow

ID: 2293264 • Letter: C

Question

code in matlab is required. not in C++

Given f(x)2r - 1.5x4 10x 2 Use the following root location technique to determine the maximum of this function. Perform iterations until the approximate relative error falls below 5%. .Newton-Raphson (initial guess of x1) The secant method (initial guesses of x O and x 1) Modified secant method (initial guess of x-1) Assuming that convergence is not an issue, choose the technique that is best suited to this problem. Justify your choice Submit the following: Iterations with estimated values and any comments/discussions * code/program

Explanation / Answer

MATLAB code is given below for each of the given methods.

clc;
close all;
clear all;


% Newton_RhapsonMethod
x(1)=1;
error=0.05;

for i=1:100
  
x(i+1)=x(i)-(-2*x(i)^6 - 1.5*x(i)^4 + 10*x(i) + 2)/...
(-12*x(i)^5-6*x(i)^3+10);

err(i)=abs((x(i+1)-x(i))/x(i));

if err(i)<error
break
end
end

root=x(i)
iterations = i


% Secant Method

x(1)=0;
x(2)=1;
error=0.05;

for i=3:100
  
x(i)=x(i-1)-(-2*x(i-1)^6 - 1.5*x(i-1)^4 + 10*x(i-1) + 2) *(x(i-1)-x(i-2))/...
((-2*x(i-1)^6 - 1.5*x(i-1)^4 + 10*x(i-1) + 2)-(-2*x(i-2)^6 - 1.5*x(i-2)^4 + 10*x(i-2) + 2));

err(i)=abs((x(i)-x(i-1))/x(i-1));

if err(i)<error
break
end
end

root=x(i)
iterations = i


% Modified Secant Method

x(1)=0;
error=0.05;
delta = 0.01;

for i=2:100
  
x(i+1)=x(i) - delta*(-2*x(i)^6 - 1.5*x(i)^4 + 10*x(i) + 2) /...
((-2*(x(i)+delta)^6 - 1.5*(x(i)+delta)^4 + 10*(x(i)+delta) + 2)-(-2*x(i)^6 - 1.5*x(i)^4 + 10*x(i) + 2));

err(i)=abs((x(i)-x(i-1))/x(i-1));

if err(i)<error
break
end
end

root=x(i)
iterations = i

RESULT:


root =

1.3706


iterations =

5


root =

-0.1997


iterations =

6


root =

1.3255


iterations =

7

It si observed that the Newton-Rhapson's method is better interms of the number of iterations taken to reach the root within 5%. (with Newtons method number of iteration = 5 which is less than both the secant and modified secant methods which have taken 6 and 7 iterations respectively.)