PLEASE EXPLAIN EACH STEP and show the coding for the plotted

PLEASE EXPLAIN EACH STEP and show the coding for the plotted function. Also, please take into consideration the notes that have been given.

PART B: MATLAB 2) MATLAB Program We want to find the root of the following function using fixed-point iteration: 2 In(x) f(x) a) Finding the root of an equation can be difficult because the algorithm may diverge or go to a different root. One way to help avoid this difficulty is to first graph the function and get an approximation of the root from the graph. Graph the above function and get an estimate of the root from the graph. b) Write a MATLAB script that will implement the fixed-point iteration algorithm to find the root. Use the approximation from (a) as the starting value. Display your root with 10 decimal places. Note: (1) You will need a convergence criteria for (b). Some programs use the machine epsilon for this. For your program, use the machine epsilon. (2) One way to check if your answer is the correct root is to calculate the residual of the answer. The residual is given by substituting your calculated root into the function: this should be very small. In your program, calculate the residual and display it with your root.

Solution

%idea is to guess the initial solution and if new solution is very close to old solution then u found the root
% f(x) = 2-2ln(x)-x^1/2
% Simple Fixed-Point Iteration

clear all

x = 1 %initial assumption or guess
Esp = 0.1 %tolerance u can decide ur own tolerance (very small)
Eap = 1000; % very large approximate error
xold = x;   
n = 0; %iteration counter

while Eap > Esp % found the solution or process converges
x = 2-2*log(x)-sqrt(x);
Eap = abs((x-xold)/x)*100; % calculate the difference b/w old solution and new solution
xold = x; %assinging new solution to old solution
n = n + 1;
end

x %gives root
n % gives number of iterations

PLEASE EXPLAIN EACH STEP and show the coding for the plotted function. Also, please take into consideration the notes that have been given. PART B: MATLAB 2) MA

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site