octave:2> 1 ans = 1 octave:3> 1+3 ans = 4 octave:4> sqrt(9) ans = 3 octave:5> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== ans 1x1 8 double Total is 1 element using 8 bytes octave:6> help dectobin 'dectobin' is a function from the file /home/accounts/personale/clrmrc90/aa1819/calcolo_numerico1/dectobin.m [d, c] = dectobin (mantissa, espon) Converte un numero decimale in binario. Il numero decimale va rappresentato come mantissa * 10 ^ (espon). Il risultato e` mostrato come cifre intere (d) e cifre dopo la virgola (c). Per esempio: > [d, c] = dectobin (125, -3) restituisce > d = 0 > c = [0, 0, 1] perche' 0.125 in base 10 e` 0.001 in base 2. Ovviamente tale notazione non e` normalizzata. 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:7> help dectobin 'dectobin' is a function from the file /home/accounts/personale/clrmrc90/aa1819/calcolo_numerico1/dectobin.m [d, c] = dectobin (mantissa, espon) Converte un numero decimale in binario. Il numero decimale va rappresentato come mantissa * 10 ^ (espon). Il risultato e` mostrato come cifre intere (d) e cifre dopo la virgola (c). Per esempio: > [d, c] = dectobin (125, -3) restituisce > d = 0 > c = [0, 0, 1] perche' 0.125 in base 10 e` 0.001 in base 2. Ovviamente tale notazione non e` normalizzata. 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> dectobin(125,-3) ans = 0 octave:9> [tizio,caio]=dectobin(125,-3) tizio = 0 caio = 0 0 1 octave:10> [tizio,caio]=dectobin(1,-1) tizio = 0 caio = Columns 1 through 20: 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 Columns 21 through 40: 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 Columns 41 through 55: 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 octave:11> [tizio,caio]=dectobin(3427,-2) tizio = 1 0 0 0 1 0 caio = Columns 1 through 20: 0 1 0 0 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 1 Columns 21 through 40: 1 0 0 0 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 1 Columns 41 through 51: 1 0 0 0 0 1 0 1 0 0 1 octave:12> [tizio,caio]=dectobin(125,-3) tizio = 0 caio = 0 0 1 octave:13> 0:-1:-3 ans = 0 -1 -2 -3 octave:14> 0:3 ans = 0 1 2 3 octave:15> 0:-1:-3 ans = 0 -1 -2 -3 octave:16> p=0:-1:-3 p = 0 -1 -2 -3 octave:17> 2^p error: for x^A, A must be a square matrix. Use .^ for elementwise power. octave:17> 2.^p ans = 1.00000 0.50000 0.25000 0.12500 octave:18> 1+p ans = 1 0 -1 -2 octave:19> 2*p ans = 0 -2 -4 -6 octave:20> 2^p error: for x^A, A must be a square matrix. Use .^ for elementwise power. octave:20> 2.^p ans = 1.00000 0.50000 0.25000 0.12500 octave:21> [d,c] error: 'd' undefined near line 1 column 2 octave:21> [tizio,caio] ans = 0 0 0 1 octave:22> tizio tizio = 0 octave:23> caio caio = 0 0 1 octave:24> [tizio,caio] ans = 0 0 0 1 octave:25> 2.^p ans = 1.00000 0.50000 0.25000 0.12500 octave:26> [tizio,caio].*2.^p ans = 0.00000 0.00000 0.00000 0.12500 octave:27> sum([tizio,caio].*2.^p) ans = 0.12500 octave:28> ls 2019-03-18.txt bintodec.m dectobin.m primafunction.m primoscript.m octave:29> length(caio) ans = 3 octave:30> bintodec(tizio,caio) ans = 0.12500 octave:31> [tizio,caio]=dectobin(3427,-2) tizio = 1 0 0 0 1 0 caio = Columns 1 through 20: 0 1 0 0 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 1 Columns 21 through 40: 1 0 0 0 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 1 Columns 41 through 51: 1 0 0 0 0 1 0 1 0 0 1 octave:32> bintodec(tizio,caio) ans = 34.270 octave:33> format long e octave:34> bintodec(tizio,caio) ans = 3.42700000000000e+01 octave:35> bintodec(4,3) ans = 5.50000000000000e+00 octave:36> v=[4,5,6] v = 4.00000000000000e+00 5.00000000000000e+00 6.00000000000000e+00 octave:37> format octave:38> v(1) ans = 4 octave:39> v(0) error: subscript indices must be either positive integers less than 2^31 or logicals octave:39> polinomio0([1,2,3],5) ans = 38 octave:40> polinomio0([1,2,3],[1,5]) error: for A^b, A must be a square matrix. Use .^ for elementwise power. error: called from: error: /home/accounts/personale/clrmrc90/aa1819/calcolo_numerico1/polinomio0.m at line 9, column 9 octave:40> sqrt([4,9]) ans = 2 3 octave:41> polinomio0([1,2,3],[1,5]) ans = 6 38 octave:42> polinomio0([1,2,3],[1,5;6,7]) ans = 6 38 51 66 octave:43> polinomio1([1,2,3],5) ans = 38 octave:44> polinomio1([1,2,3],[1,5]) error: polinomio1: operator *: nonconformant arguments (op1 is 1x2, op2 is 1x2) error: called from: error: /home/accounts/personale/clrmrc90/aa1819/calcolo_numerico1/polinomio1.m at line 11, column 15 octave:44> polinomio1([1,2,3],[1,5]) ans = 6 38 octave:45> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== ans 1x2 16 double caio 1x51 408 double p 1x4 24 double tizio 1x6 48 double v 1x3 24 double Total is 66 elements using 520 bytes octave:46> 1*2^-1022 ans = 2.2251e-308 octave:47> realmin ans = 2.2251e-308 octave:48> realmax ans = 1.7977e+308 octave:49> realmax*2 ans = Inf octave:50> 2*Inf ans = Inf octave:51> Inf+Inf ans = Inf octave:52> Inf/Inf ans = NaN octave:53> 2^(-52-1) ans = 1.1102e-16 octave:54> 34.27 ans = 34.270 octave:55> format long e octave:56> 34.27 ans = 3.42700000000000e+01 octave:57> 1/3 ans = 3.33333333333333e-01 octave:58> eps ans = 2.22044604925031e-16 octave:59> 1+eps ans = 1.00000000000000e+00 octave:60> 1+eps>1 ans = 1.00000000000000e+00 octave:61> format octave:62> 1+eps>1 ans = 1 octave:63> 1+eps/2>1 ans = 0 octave:64> 1+eps/2==1 ans = 1 octave:65> format bit octave:66> \1 parse error: syntax error >>> \1 ^ octave:66> 1 ans = 0011111111110000000000000000000000000000000000000000000000000000 octave:67> eps ans = 0011110010110000000000000000000000000000000000000000000000000000 octave:68> 1+eps ans = 0011111111110000000000000000000000000000000000000000000000000001 octave:69> 1+eps/2 ans = 0011111111110000000000000000000000000000000000000000000000000000 octave:70> format octave:71> (1+eps/2)+eps/2==1 ans = 1 octave:72> 1+(eps/2+eps/2)==1 ans = 0 octave:73> 1+(eps/2+eps/2)>1 ans = 1 octave:74> A=randn(4) A = -0.2471419 -1.6191943 -0.9863305 -0.2154682 0.8214265 -0.6787938 0.0538856 -0.0095894 -1.7598564 0.5151267 1.0331612 0.5162880 0.2543309 1.1896174 0.3404916 -0.1603690 octave:75> A=randn(4) A = 1.63275 0.63511 1.39836 1.90850 -1.40424 -0.73286 -0.69060 0.63598 -1.31524 -0.88710 -1.20206 -0.34536 -0.25561 -1.04199 -1.01829 1.21823 octave:76> A=randn(4) A = -0.507311 0.479790 0.034134 2.082971 0.274501 0.537065 0.510467 -0.710573 -1.407907 -0.612954 -0.673479 -0.067686 1.352397 -0.914509 1.887233 0.014207 octave:77> A=randn(4) A = 1.234542 1.148108 0.169277 -0.379209 1.357668 0.147879 -0.532339 -0.684378 -0.568943 -1.498534 -1.945901 1.920894 0.543187 -0.794222 -0.400530 0.019589 octave:78> A=randn(4) A = -0.40786 0.28590 0.38567 0.17599 0.55098 -0.43376 1.02737 1.86323 -0.67271 -0.93543 0.53089 -1.74887 -0.29428 -1.01829 1.49864 -1.17140 octave:79> A=randn(4) A = -0.471450 -0.940273 0.438373 0.397845 -1.429220 0.207975 -0.483184 1.195331 -0.491351 -0.315763 0.524348 -0.396069 1.163455 -1.522792 0.957981 0.012207 octave:80> (A^2)*A ans = -2.289511 0.174474 0.067098 -0.230122 -0.757755 -1.821655 0.991486 0.395560 -2.006691 1.455698 -1.258649 1.039333 -0.962397 0.627271 0.609348 -2.322195 octave:81> A*(A^2) ans = -2.289511 0.174474 0.067098 -0.230122 -0.757755 -1.821655 0.991486 0.395560 -2.006691 1.455698 -1.258649 1.039333 -0.962397 0.627271 0.609348 -2.322195 octave:82> (A^2)*A==A*(A^2) ans = 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 octave:83> (A^2)*A-A*(A^2) ans = -4.4409e-16 6.6613e-16 -4.4409e-16 8.3267e-17 -2.2204e-16 -2.2204e-16 0.0000e+00 2.7756e-16 0.0000e+00 2.2204e-16 0.0000e+00 -2.2204e-16 -2.2204e-16 0.0000e+00 -2.2204e-16 8.8818e-16 octave:84> pi ans = 3.1416 octave:85> format long e octave:86> pi ans = 3.14159265358979e+00 octave:87> sin(pi) ans = 1.22464679914735e-16 octave:88> 2^(-52) ans = 2.22044604925031e-16 octave:89> diary off