Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ outpoints ] = myNewtonRaphson( )
- x = rand(2,1);
- G = Grad(x);
- points = [];
- points = [points,x];
- while ( norm(G) >= eps )
- G = Grad(x);
- H = Hesj(x);
- x = x - inv(H)* G;
- points = [points, x];
- end
- outpoints = points;
- function [ res ] = Hesj(x)
- res = [2+1200*x(1)^2-400*x(2) -400*x(1); -400*x(1) 200];
- function [ res ] = Grad(x)
- g1 = -2+2*x(1)-400*(x(2)-x(1)^2)*x(1);
- g2 = 200*x(2)-200*x(1)^2;
- res = [g1 g2]';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement