mirror of
https://bitbucket.org/Mattrixwv/octavefunctions.git
synced 2026-02-04 04:02:32 -05:00
Added check for the correct number of variables and added a few comments
This commit is contained in:
10
Newton.m
10
Newton.m
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user