GNU Octave, version 3.8.1 Copyright (C) 2014 John W. Eaton and others. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'. Octave was configured for "x86_64-pc-linux-gnu". Additional information about Octave is available at http://www.octave.org. Please contribute if you find this software useful. For more information, visit http://www.octave.org/get-involved.html Read http://www.octave.org/bugs.html to learn how to submit bug reports. For information about changes from previous versions, type 'news'. octave:1> F = @(x) [0.5*sin(x(1)*x(2))-0.25*x(2)/pi-0.5*x(1);... > (1-0.25/pi)*(exp(2*x(1))-exp(1))+exp(1)*x(2)/pi-2*exp(1)*x(1)]; octave:2> F([1;2]) ans = -0.20451 0.59303 octave:3> F([1,2]) ans = -0.20451 0.59303 octave:4> x1 = [0;0]; octave:5> x2 = [1;1]; octave:6> x3 = [0.25;3]; octave:7> [x, delta, its] = secanti2 (F, x1, x2, x3) x = 0.29945 2.83693 delta = 1.0272e-07 its = 9 octave:8> F(x) ans = 2.1633e-10 -4.7582e-10 octave:9> x3 = [2;2]; octave:10> [x, delta, its] = secanti2 (F, x1, x2, x3) warning: secanti2: tolleranza non raggiunta x = -0.32547 -0.32547 delta = 0.071957 its = 50 octave:11> F F = @(x) [0.5 * sin(x (1) * x (2)) - 0.25 * x(2) / pi - 0.5 * x(1); (1 - 0.25 / pi) * (exp(2 * x (1)) - exp(1)) + exp(1) * x(2) / pi - 2 * exp(1) * x(1)] octave:12> JF=@(x) [0.5*x(2)*cos(x(1)*x(2))-0.5,0.5*x(1)*cos(x(1)*x(2))-0.25/pi;... > 2*(1-0.25/pi)*exp(2*x(1))-2*exp(1),exp(1)/pi]; octave:13> [x,delta,its]=newton(F,JF,[0.25;3]) error: 'newton' undefined near line 1 column 14 octave:13> ls 2018-10-23.txt 2018-11-20.txt gradott.m~ jacobi.m~ potenzeOP.m secanti2.m 2018-11-06.txt gradott.m jacobi.m potenze.m qr_shift.m octave:14> [x,delta,its]=newton(F,JF,[0.25;3]) x = 0.29945 2.83693 delta = 1.2841e-07 its = 4 octave:15> [x,delta,its]=newton(F,JF,[0.25;3]) ans = 0.012055 ans = 2.1533e-04 ans = 1.2841e-07 x = 0.29945 2.83693 delta = 1.2841e-07 its = 4 octave:16> JF=@(x) [cos(x(1)*x(2))-0.5,0.5*x(1)*cos(x(1)*x(2))-0.25/pi;... > 2*(1-0.25/pi)*exp(2*x(1))-2*exp(1),exp(1)/pi]; octave:17> [x,delta,its]=newton(F,JF,[0.25;3]) ans = 2.0172 ans = 0.47223 ans = 1.6974 ans = 1.7078 ans = 2.1617 ans = 2.3335 ans = 3.1622 ans = 4.5152 ans = 0.78688 warning: newton: tolerance not met x = 0.46264 3.58751 delta = 0.78688 its = 10 octave:18> JF=@(x) [x(2)*cos(x(1)*x(2))-0.5,0.5*x(1)*cos(x(1)*x(2))-0.25/pi;... > 2*(1-0.25/pi)*exp(2*x(1))-2*exp(1),exp(1)/pi]; octave:19> [x,delta,its]=newton(F,JF,[0.25;3]) ans = 0.029522 ans = 0.019235 ans = 0.012669 ans = 0.0083583 ans = 0.0055175 ans = 0.0036425 ans = 0.0024044 ans = 0.0015869 ans = 0.0010472 warning: newton: tolerance not met x = 0.29861 2.83490 delta = 0.0010472 its = 10 octave:20> [x,delta,its]=newton(F,JF,[0.25;3],1e-6,100) x = 0.29945 2.83692 delta = 3.0984e-06 its = 24 octave:21> [x,delta,its]=newton(F,JF,[0.25;3]) warning: newton: tolerance not met x = 0.29861 2.83490 delta = 0.0010472 its = 10 octave:22> JF JF = @(x) [x(2) * cos(x (1) * x (2)) - 0.5, 0.5 * x(1) * cos(x (1) * x (2)) - 0.25 / pi; 2 * (1 - 0.25 / pi) * exp(2 * x (1)) - 2 * exp(1), exp(1) / pi] octave:23> x=rand(2,1) x = 0.024593 0.947504 octave:24> y=rand(2,1) y = 0.495736 0.014733 octave:25> JF(x)*y ans = 0.22073 -1.72377 octave:26> epsilon=1e-4; octave:27> (F(x+epsilon*y)-F(x))/epsilon ans = -0.014067 -1.723726 octave:28> JF=@(x) [0.5*x(2)*cos(x(1)*x(2))-0.5,0.5*x(1)*cos(x(1)*x(2))-0.25/pi;... > 2*(1-0.25/pi)*exp(2*x(1))-2*exp(1),exp(1)/pi]; octave:29> JF(x)*y ans = -0.014067 -1.723774 octave:30> imag(F(x+1i*epsilon*y))/epsilon ans = -0.014067 -1.723774 octave:31> format long e octave:32> epsilon=1e-8 epsilon = 1.00000000000000e-08 octave:33> imag(F(x+1i*epsilon*y))/epsilon ans = -1.40671376148423e-02 -1.72377358282187e+00 octave:34> JF(x)*y ans = -1.40671376148424e-02 -1.72377358282187e+00 octave:35> xnmenoxnmeno1=rand(2,1) xnmenoxnmeno1 = 5.26878065312859e-01 1.85212255236148e-01 octave:36> u=rand(2,1) u = 7.75905519814294e-02 3.07030035355388e-01 octave:37> u*xnmenoxnmeno1' ans = 4.08807599145323e-02 1.43707211174981e-02 1.61767391020985e-01 5.68657252734058e-02 octave:38> rank(u*xnmenoxnmeno1') ans = 1.00000000000000e+00 octave:39> F F = @(x) [0.5 * sin(x (1) * x (2)) - 0.25 * x(2) / pi - 0.5 * x(1); (1 - 0.25 / pi) * (exp(2 * x (1)) - exp(1)) + exp(1) * x(2) / pi - 2 * exp(1) * x(1)] octave:40> [x,delta,its]=broyden(F,[0.25;3]) x = 2.99448680071217e-01 2.83692771525380e+00 delta = 1.28448846659478e-06 its = 9.00000000000000e+00 octave:41> [x,delta,its]=broyden(F,[0.25;3],1e-9) x = 2.99448680071217e-01 2.83692771525380e+00 delta = 1.28448846659478e-06 its = 9.00000000000000e+00 octave:42> [x,delta,its]=broyden(F,[0.25;3],1e-12) x = 2.99448680071217e-01 2.83692771525380e+00 delta = 1.28448846659478e-06 its = 9.00000000000000e+00 octave:43> [x,delta,its]=broyden(F,[0.25;3],1e-12) x = 2.99448692490926e-01 2.83692777045894e+00 delta = 3.41714565069603e-12 its = 1.20000000000000e+01 octave:44> [x, delta, its] = secanti2 (F, x1, x2, x3,1e-12) warning: secanti2: tolleranza non raggiunta x = -3.25467087822051e-01 -3.25467087822051e-01 delta = 7.19574128069582e-02 its = 5.00000000000000e+01 octave:45> x3 x3 = 2.00000000000000e+00 2.00000000000000e+00 octave:46> [x, delta, its] = secanti2 (F, x1, x2, [0.25;3],1e-12) x = 2.99448692490926e-01 2.83692777045894e+00 delta = 2.33558045179711e-14 its = 1.10000000000000e+01 octave:47> [x, delta, its] = newton(F,[0.25;3],1e-12) error: newton: subscript indices must be either positive integers less than 2^31 or logicals error: called from: error: /home/accounts/personale/clrmrc90/aa1819/calcolo_numerico2/newton.m at line 27, column 7 octave:47> [x, delta, its] = newton(F,JF,[0.25;3],1e-12) x = 2.99448692490926e-01 2.83692777045894e+00 delta = 4.42288592032290e-14 its = 5.00000000000000e+00 octave:48>