octave:2> z=1e-6;(exp(z)-1)/z ans = 1.0000 octave:3> format long e octave:4> z=1e-6;(exp(z)-1)/z ans = 1.00000049996218e+00 octave:5> z=1e-8;(exp(z)-1)/z ans = 9.99999993922529e-01 octave:6> z=1e-10;(exp(z)-1)/z ans = 1.00000008274037e+00 octave:7> z=1e-12;(exp(z)-1)/z ans = 1.00008890058234e+00 octave:8> z=1e-14;(exp(z)-1)/z ans = 9.99200722162641e-01 octave:9> z=1e-15;(exp(z)-1)/z ans = 1.11022302462516e+00 octave:10> z=1e-15;(exp(z)-1)/log(exp(z)) ans = 1.00000000000000e+00 octave:11> z=0;(exp(z)-1)/log(exp(z)) warning: division by zero ans = NaN octave:12> help expm 'expm' is a function from the file /usr/share/octave/3.8.1/m/linear-algebra/expm.m -- Function File: expm (A) Return the exponential of a matrix, defined as the infinite Taylor series expm (A) = I + A + A^2/2! + A^3/3! + ... The Taylor series is _not_ the way to compute the matrix exponential; see Moler and Van Loan, 'Nineteen Dubious Ways to Compute the Exponential of a Matrix', SIAM Review, 1978. This routine uses Ward's diagonal Pade' approximation method with three step preconditioning (SIAM Journal on Numerical Analysis, 1977). Diagonal Pade' approximations are rational polynomials of matrices -1 D (A) N (A) whose Taylor series matches the first '2q+1' terms of the Taylor series above; direct evaluation of the Taylor series (with the same preconditioning steps) may be desirable in lieu of the Pade' approximation when 'Dq(A)' is ill-conditioned. See also: logm, sqrtm. Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. octave:13> A=[1,2;3,4] A = 1.00000000000000e+00 2.00000000000000e+00 3.00000000000000e+00 4.00000000000000e+00 octave:14> format octave:15> A A = 1 2 3 4 octave:16> exp(A) % non fare cosi!!!!! ans = 2.7183 7.3891 20.0855 54.5982 octave:17> expm(A) % fare cosi!!!!! ans = 51.969 74.737 112.105 164.074 octave:18> phi1m(0) ans = 1 octave:19> phi1m(3) ans = 6.3618 octave:20> (exp(3)-1)/3 ans = 6.3618 octave:21> phi1m(-2) ans = 0.43233 octave:22> (exp(-2)-1)/(-2) ans = 0.43233 octave:23> A=rand(2) A = 0.47558 0.64532 0.40948 0.27418 octave:24> phi1m(A) ans = 1.34130 0.42594 0.27027 1.20837 octave:25> A\(expm(A)-eye(2)) ans = 1.34130 0.42594 0.27027 1.20837 octave:26> A=[1,1;1,1] A = 1 1 1 1 octave:27> phi1m(A) ans = 2.0973 1.0973 1.0973 2.0973 octave:28> A\(expm(A)-eye(2)) warning: matrix singular to machine precision, rcond = 0 ans = 1.5973 1.5973 1.5973 1.5973 octave:29> ese11odeEE octave:30> y y = 6.6769e-05 9.4426e-05 6.6769e-05 octave:31> ese11odeERE error: 'ese11odeERE' undefined near line 1 column 1 octave:31> ese11odeERE error: 'ese11odeERE' undefined near line 1 column 1 octave:31> ls 2015-10-07.txt ese11odeEE.m logistica0.m~ 2015-10-21.txt ese11odeEE.m~ logistica.m 2015-10-28.txt ese11odeERE.m logistica.m~ 2015-11-04.txt ese11ODEERE.m phi1m.m 2015-11-18.txt ese11ODEERE.m~ rk23.m 2015-12-02.txt fem0.m rk2.m 2015-12-09.txt fem0.m~ stiff.m 2015-12-16.txt fourier.m stiff.m~ catenaria.m fourier.m~ catenaria.m~ logistica0.m octave:32> ese11odeERE error: 'ese11odeERE' undefined near line 1 column 1 octave:32> ese11odeEE octave:33> clear all octave:34> ese11odeERE error: 'ese11odeERE' undefined near line 1 column 1 octave:34> cd .. octave:35> cd equazioni_differenziali/ octave:36> ls 2015-10-07.txt ese11odeEE.m logistica0.m~ 2015-10-21.txt ese11odeEE.m~ logistica.m 2015-10-28.txt ese11odeERE.m logistica.m~ 2015-11-04.txt ese11ODEERE.m phi1m.m 2015-11-18.txt ese11ODEERE.m~ rk23.m 2015-12-02.txt fem0.m rk2.m 2015-12-09.txt fem0.m~ stiff.m 2015-12-16.txt fourier.m stiff.m~ catenaria.m fourier.m~ catenaria.m~ logistica0.m octave:3> ese11odeERE octave:4> y y = 6.6129e-05 9.3520e-05 6.6129e-05 octave:5> ese11odeEE octave:6> y y = 6.6769e-05 9.4426e-05 6.6769e-05 octave:7> help ese11odeERE 'ese11odeERE' is a function from the file /home/accounts/personale/clrmrc90/aa1516/equazioni_differenziali/ese11odeERE.m Eulero Rosenbrock esponenziale y = ese11odeERE(ts) ts numero di time step Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. octave:8> ese11odeEE(100) ans = 6.6769e-05 9.4426e-05 6.6769e-05 octave:9> ese11odeERE(100) ans = 6.6129e-05 9.3520e-05 6.6129e-05 octave:10> yrif=ese11odeERE(500) yrif = 6.6146e-05 9.3545e-05 6.6146e-05 octave:11> y=ese11odeEE(100); octave:12> norm(y-yrif) ans = 1.2463e-06 octave:13> y=ese11odeEE(200); octave:14> norm(y-yrif) ans = 6.0859e-07 octave:15> y=ese11odeEE(400); octave:16> norm(y-yrif) ans = 3.0128e-07 octave:17> y=ese11odeERE(1000); octave:18> yrif=y; octave:19> y=ese11odeERE(50); octave:20> norm(y-yrif) ans = 1.5333e-07 octave:21> y=ese11odeERE(100); octave:22> norm(y-yrif) ans = 3.6469e-08 octave:23> 1.5333e-07/4 ans = 3.8333e-08 octave:24> y=ese11odeERE(200); octave:25> norm(y-yrif) ans = 8.6581e-09 octave:26> 3.6469e-08/4 ans = 9.1173e-09 octave:27> y0=[sqrt(2)/2;1;sqrt(2)/2]; octave:28> A=16*toeplitz([-2,1,0]); octave:29> J0=A+diag(2*y0) J0 = -30.58579 16.00000 0.00000 16.00000 -30.00000 16.00000 0.00000 16.00000 -30.58579 octave:30> eig(J0) ans = -52.9222 -30.5858 -7.6636 octave:31> -2/min(eig(J0)) ans = 0.037791 octave:32> octave:32> eig(A) ans = -54.6274 -32.0000 -9.3726 octave:33> diary off