use matlab Problem #1: We want to find the roots of the following nonlinear func
ID: 3111089 • Letter: U
Question
use matlab
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
>>
>>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.