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

Problem 2. Consider the function f(x)-cos(2x)+x-1 which has exactly one root ?-0

ID: 3348533 • Letter: P

Question

Problem 2. Consider the function f(x)-cos(2x)+x-1 which has exactly one root ?-0. a) For the given function f(x), one possible start value x0 for Newton's method shall be determined so that the root ? =0 can be found exactly with one iteration only. Turn this problem statement into a root finding problem of the form g(x)0 with unknown root ?=xo . Find one root ?-x0 of the function g(x) as derived in Part a) using a modified Newton's method according to the modified general iteration formula b) g'(%) where x--is the start value for the modified Newton's method (ie. x0 ). Perform two iterations to determine the value ofx, a. c) Give one advantage and one disadvantage of the modified Newton's method used in Part b) compared to (the original version of) Newton's method.

Explanation / Answer

%%Matlab code for Newton Method
clear all
close all
%User Defined function
syms f(x)
f(x) =cos(2*x)+(3/2)*x-1; % The function whose root we want to evaluate
df(x) =diff(f,x);        % The Derivative of the function

x1 = char(f(x));       %Function value to char form
x2 = char(df(x));     %Derivative of the Function value to char form
%Printing the function and its derivative
fprintf(' Derivative of the function is %s ',x1)
fprintf(
' Derivative of the function is %s ',x2)

x=-.5;    
%Initial guess of the root for Newton method
y=10;      %Initial guess for modified Newton method
c=1;        %Initialise the loop
i=1;         %Initialise the counter
a(1)=x;    %Initial guess of the root

while c>=.0005 %Absolute error limit

    %Newton Raphson Algorithm
    x=double(x-(f(x)/df(x)));
    a1(i+1)=double(x);
    i=i+1;
    c=abs(a1(i-1)-a1(i));


end

c=1;    %Initialise the loop
while c>=.0005 %Absolute error limit

    %Modified Newton Raphson Algorithm
    y=double(y-(f(y)/df(pi/2)));
    a2(i+1)=double(y);
    i=i+1;
    c=abs(a2(i-1)-a2(i));


end

%printing the result
fprintf(' The root of the equation using Newton method is is %f ',a1(end))
fprintf(
' The root of the equation using modified Newton method is %f ',a2(end))

%End of matlab code

Result


          Derivative of the function is (3*x)/2 + cos(2*x) - 1

          Derivative of the function is 3/2 - 2*sin(2*x)

          The root of the equation using Newton method is is -0.000000

          The root of the equation using modified Newton method is 0.000000

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote