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: 3111089 • 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

On script

clear all

f=@(x)30*cos(2*x+0.1)*log(x^2)-2*x

df=@(x)-60*log(x^2)*sin(2*x+0.1)+60*cos(2*x+0.1)/x-2

x0=input('enter initial guess')

while abs(f(x0))>0.01

x1=x0-(f(x0)/df(x0))

x0=x1

end

On command window

>> newton

f =

    @(x)30*cos(2*x+0.1)*log(x^2)-2*x


df =

    @(x)-60*log(x^2)*sin(2*x+0.1)+60*cos(2*x+0.1)/x-2

enter initial guess1.5

x0 =

    1.5000


x1 =

    0.8792


x0 =

    0.8792


x1 =

    0.9453


x0 =

    0.9453


x1 =

    0.9216


x0 =

    0.9216


x1 =

    0.9179


x0 =

    0.9179

>>
>>