Added check for the correct number of variables and added a few comments

This commit is contained in:
2018-09-22 16:19:44 -04:00
parent 3b669a2979
commit 3f00730c9f
6 changed files with 60 additions and 13 deletions

View File

@@ -1,12 +1,20 @@
function [xList,errorList] = Newton (f, startingValue, errorAllow)
function [xList,errorList] = Newton(f, startingValue, errorAllow)
%
%Newton(f, startingValue, errorAllow)
%This function uses Newtons method to find a solution to the root of f
%
%Check that the number of arguments is correct
if(nargin ~= 3)
error('That is the wrong number of arguments')
end
%Things that are necessary to begin
pkg load symbolic;
warning('off','OctSymPy:sym:rationalapprox');
%Constant variables
maxIt = 50;
fp = diff(f);
%Variables
oldAnswer = startingValue;
newAnswer = 0;
cnt = 1;