Created
September 15, 2014 18:49
-
-
Save dmadisetti/8b4cc9a6520d4d415e75 to your computer and use it in GitHub Desktop.
newtonRaphson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Third stab at matlab | |
function out = newtonRaphson(funct,old) | |
delta = 0.001; | |
y = funct(old); | |
m = (funct(old+delta)-y)/delta; | |
new = (m*old-y)/m; | |
apprx = funct(new); | |
% Let's check to see if it hit the needed level | |
if abs((apprx - y)/2) < 0.01 || funct(apprx) == 0, | |
out = new; | |
return; | |
end | |
out = newtonRaphson(funct,new); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment