Root Finding Newton Method

3 views (last 30 days)
Jacob Janson
Jacob Janson on 17 Oct 2020
Answered: Walter Roberson on 17 Oct 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

Answers (1)

Walter Roberson
Walter Roberson on 17 Oct 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.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!