Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- u = [3; 2];
- r = 1;
- % Expecting x = [3; 0] or roughly x = [1.2; 2.7].
- f = @(x) [x'*x+4*r*r-u'*u; x'*x-x'*u];
- fp = @(x) [2*x'; 2*x'-u'];
- x = [0; 1];
- for i=1:10
- x = x - fp(x)\f(x);
- disp(x')
- end
- #{
- This is the output:
- octave:3> main
- -0.33333 5.00000
- 0.69504 3.45745
- 1.0777 2.8835
- 1.1509 2.7736
- 1.1538 2.7692
- 1.1538 2.7692
- 1.1538 2.7692
- 1.1538 2.7692
- 1.1538 2.7692
- 1.1538 2.7692
- Good! Expected something like [1.2; 2.7].
- }#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement