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

use matlab Problem #1: We want to find the roots of the following nonlinear func

ID: 3111091 • Letter: U

Question





use matlab

Problem #1: We want to find the roots of the following nonlinear function in the domain [1.5,4] using Newton's root finding method: f(x) = 30cos(2x + 0.1) In(x)-2x Task 1: 1. Build a MALAB function that implements the Newton's search method. The solution must be updated until at least one of the following stopping criteria has been satisfied: a) Maximum number of iterations is reached. b) Absolute tolerance on the difference between two consecutive iterates is reached. c) Absolute tolerance on the function is reached. I. Your function must have the following input arguments: 1) fun: character string variable that represents the MATLAB function (file) that calculates and returns f(x) and f(x) 2) 1f and 1x, Lower limit and upper limit of the function domain interval, respectively 3) x0: initial guess value 4) xtol: absolute tolerance on the difference between two consecutive iterates (that is, if

Explanation / Answer

x = 1.5; lim = 0.0000001; count = 0; dx = 1; %this is a fake value so that the while loop will execute f = -27.30687; % because f(1.5) = -27.30687 fprintf('step x dx f(x) ') fprintf('---- ----------- --------- ---------- ') fprintf('%3i %12.8f %12.8f %12.8f ', count, x, dx, f) xVec = x; fVec = f; while ((dx > lim || abs(f) > lim) && x