finding multiple roots using newton raphson
古いコメントを表示

Hello everyone, I am being asked in a homework question to find the instants a function y(t)=4*exp(-0.3t)sin(3t+0.25) crosses zero (the roots) in the interval 0<t<4. I have developed a code that uses Newton Raphson to find roots for functions. Here is that function:
function Xs=NewtonRoot(Fun,FunDer,Xest,Err,imax)
% NewtonRoot: finds the root of Fun=0 near the point Xest using Newton's
% method.
%Fun: Name of a user-defined funtion that calculates Fun for a given x.
% FunDer: Name of a user-defined function that calculates the derivative of
% Fun for a given x.
% Xest: Initial estimate of the solution.
% Err: Maximum error
% imax: Maximum number of iterations
% Output variable
%Xs Solution
for i=1:imax
Xi=Xest-Fun(Xest)/FunDer(Xest);
if abs((Xi-Xest)/Xest)<Err
Xs=Xi;
break
end
Xest=Xi;
end
if i==imax
fprintf('Solution was not obtained in %i iterations.\n',imax)
Xs=('No answer');
end
end
And then I create a function for both y(t) and y'(t). Here is y(t):
function y=problem3fun(x)
% This is the function for damping oscillator
y=4*exp(-0.3*x)*(sin((3*x)+0.25));
end
and y'(t):
if true
function y=problem3funDer(x)
y=-exp((3*x/10)*(6*sin((3*x)+0.25))-60*cos((3*x)+0.25)/(5));
endfunction y=problem3funDer(x)
y=-exp((3*x/10)*(6*sin((3*x)+0.25))-60*cos((3*x)+0.25)/(5));
end
So I think what my problem is that I do not know how to display multiple roots. I have a few guesses (Xest) but I can only at this point guess one root and thats it. On the command line:
Tsolution=NewtonRoot(@problem3fun,@problem3funDer,1,0.001,20)
Tsolution =
1.0000
So my question is how can I make my function work to find multiple roots of this y(t).
採用された回答
その他の回答 (1 件)
Radu Trimbitas
2022 年 5 月 19 日
1 投票
The standard solution, if you know the multiplicities in advance is to use the reccurence relation

where m is the multiplicity. This modification has the order of convergence equal to 2. The ordinary Newton for multiple roots has order 1. If the multiplicity m is unknown, you can estimate it using

You may use this estimation in the previous relation.
カテゴリ
ヘルプ センター および File Exchange で Newton-Raphson Method についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

