Root Finding Newton Method

1 Ansicht (letzte 30 Tage)
Jacob Janson
Jacob Janson am 17 Okt. 2020
Beantwortet: Walter Roberson am 17 Okt. 2020
I am a beginner at coding working on this homework assignment to make a working Newton method root finder. When I do this on paper I can figure out what needs to happen. I am so lost to getting it into code. I think that I need to put in a new variable to find the roots of a function but I'm really uncertain how to do that. Can anyone help me out?
function [y] = Newton_3397(chuckie,x)
syms x
%chuckie(x)=x.^2-7
y=x-(chuckie(x)/diff(chuckie(x)));
y=vpa(subs(y,x,1));
ans=y-(chuckie(x)/diff(chuckie(x)))
end

Antworten (1)

Walter Roberson
Walter Roberson am 17 Okt. 2020
function [y] = Newton_3397(chuckie,x)
syms x
You should not be ignoring the input x value. The user is supposed to pass you an initial value, the point to start at.
function [y] = Newton_3397(chuckie,x0)
and
x0=vpa(subs(y,x,x0));
and you just repeat that same assignment several times until you are satisfied that the error is low enough.

Kategorien

Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by