octave:30> F = @(x) [x(1) ^ 2 + x(2) ^ 2 - 1; sin(pi * x(1) / 2) + x(2) ^ 3]; octave:31> JF = @(x) [2 * x(1), 2 * x(2); pi / 2 * cos(pi * x(1) / 2), 3 * x(2) ^ 2]; octave:32> x=rand(2,1) x = 0.14282 0.92031 octave:33> y=rand(2,1) y = 0.081022 0.963456 octave:34> espilon=1e-4 espilon = 1.0000e-04 octave:35> (F(x+epsilon*y)-F(x))/epsilon error: 'epsilon' undefined near line 1 column 6 error: evaluating argument list element number 1 octave:35> epsilon=1e-4 epsilon = 1.0000e-04 octave:36> (F(x+epsilon*y)-F(x))/epsilon ans = 1.7966 2.5724 octave:37> JF(x)*y ans = 1.7965 2.5721 octave:38> JF = @(x) [2 * x(1), 2 * x(2); cos(pi * x(1) / 2), 3 * x(2) ^ 2]; octave:39> JF(x)*y ans = 1.7965 2.5270 octave:40> JF = @(x) [2 * x(1), 2 * x(2); -cos(pi * x(1) / 2), 3 * x(2) ^ 2]; octave:41> JF(x)*y ans = 1.7965 2.3691 octave:42> rand(4,1)*rand(1,4) ans = 0.66761 0.51763 0.41843 0.66133 0.67012 0.51958 0.42000 0.66382 0.23994 0.18603 0.15038 0.23768 0.23549 0.18258 0.14759 0.23327 octave:43> rank(rand(4,1)*rand(1,4)) ans = 1 octave:44> u=rand(4,1) u = 0.741368 0.372249 0.068807 0.294950 octave:45> w=rand(1,4) w = 0.49709 0.69202 0.61336 0.27292 octave:46> u*w ans = 0.368524 0.513045 0.454724 0.202337 0.185040 0.257605 0.228322 0.101595 0.034203 0.047616 0.042203 0.018779 0.146615 0.204112 0.180909 0.080499 octave:47> u*w(1) ans = 0.368524 0.185040 0.034203 0.146615 octave:48> u*w(2) ans = 0.513045 0.257605 0.047616 0.204112 octave:49> test broyden PASSES 1 out of 1 test octave:50> F = @(x) [x(1) ^ 2 + x(2) ^ 2 - 1; sin(pi * x(1) / 2) + x(2) ^ 3]; octave:51> JF = @(x) [2 * x(1), 2 * x(2); pi / 2 * cos(pi * x(1) / 2), 3 * x(2) ^ 2]; octave:52> x0 = [1; 1]; octave:53> [x,delta,its]=broyden(F,x0) x = 0.47610 -0.87939 delta = 1.6280e-07 its = 10 octave:54> [x,delta,its]=newton(F,JF,x0) x = 0.47610 -0.87939 delta = 7.0069e-12 its = 9 octave:55> diary off