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

Consider the problem of finding a solution to the equation x = cos(x). Use your

ID: 3837414 • Letter: C

Question

Consider the problem of finding a solution to the equation x = cos(x). Use your computer implementation of Steffensen's method with initial guess x)0 = 1 to compute at least the first 12 iterations. Calculate the error at each iteration e_n = x_n - alpha, where alpha is the exact solution. Use alpha = 0.7390851332151607. Implement the Newton's method for solving the problem described in 2) and use x_0 = 1 as initial conditions. Calculate the error at each iteration e_n = x_n - alpha, where alpha is the exact solution. Use alpha = 0.7390851332151607.

Explanation / Answer

% we need to find solution of

%    cox(x) = x

% or cos(x) - x = 0

%

% so differentiation of cos(x) - x

% is -sin(x) - 1

a = 0.7390851332151607;

f = @(x) cos(x) - x;

df = @(x) -sin(x) - 1;

n = 0;

x = 1;

while ( n < 12 && f(x) ~= 0)

    n = n + 1;

    e = a - x;

    fprintf("For iteration #%d, error e = %f ",n,e);

    x = x - f(x)/df(x);

end

fprintf("results were found after %d iterations ", n);

I hope this helps you. If in case you need more information on this, please feel free to comment below. I shall be glad to help you with the same.

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