1> p =[3 -7 2 0 1 -1 1]; 2> p(2) ans = -7 3> p(3) ans = 2 4> % per trovare il valore del polinomio p(x) per x = 2 si scrive polyval(p,2) 4> polyval(p,2) ans = 3 5> p =[3 -7 2 0 -1 1]; 6> polyval(p,2) ans = -1 7> q=[3 -1 0 0 -1]; 8> p/q error: operator /: nonconformant arguments (op1 is 1x6, op2 is 1x5) 8> pd=[15 -28 6 0 -1]; % la derivata del polinomio p 9> polyval(pd,2) ans = 39 10> polyval(q,2) ans = 39 11> % p'(2) = q(2), dove p(x) = q(x)(x-2)+p(2), ne deriva: p'(2)=q'(2)(2-2) +q(2) 11> polyder(p) ans = 15 -28 6 0 -1 12> polyint(pd) % l'integrale di pd(x) ans = 3 -7 2 0 -1 0 13> % polyder(p) per calcolare la derivata di un polinomio, % polyint(p) per calcolare l'integrale di p 13> conv(p,q) ans = 9 -24 13 -2 -6 11 -3 0 1 -1 14> % per calcolare (x-1)^7 si possono scrivere i polinomi x-1 e moltiplicarli tra loro con il comando conv 14> p1 = [1 -1]; 15> p2=conv(p1,p1) p2 = 1 -2 1 16> p3=conv(p2,p1) p3 = 1 -3 3 -1 17> % facendo un ciclo si calcola in maniera piu' veloce e comoda 17> f=p1; 18> for k=1:6 f=conv(f,p1); end 19> f f = 1 -7 21 -35 35 -21 7 -1 20> quit %%%%%%%%%%%%%%%%%%%%% pausa %%%%%%%%%%%%%%%%%%%%% 1> 0^0 ans = 1 2> % si costruisce il Triangolo di Tartaglia con Octave 2> f1=[1] f1 = 1 3> f2=[1 1]; 4> f=f1; 5> for k=1:7 f=conv(f,f2) end f = 1 1 f = 1 2 1 f = 1 3 3 1 f = 1 4 6 4 1 f = 1 5 10 10 5 1 f = 1 6 15 20 15 6 1 f = 1 7 21 35 35 21 7 1 6> f f = 1 7 21 35 35 21 7 1 7> for k=1:8 f=conv(f,f2); end 8> f f = Columns 1 through 11: 1 15 105 455 1365 3003 5005 6435 6435 5005 3003 Columns 12 through 16: 1365 455 105 15 1 9> for k=1:8 f=conv(f,f2) end f = Columns 1 through 9: 1 16 120 560 1820 4368 8008 11440 12870 Columns 10 through 17: 11440 8008 4368 1820 560 120 16 1 f = Columns 1 through 9: 1 17 136 680 2380 6188 12376 19448 24310 Columns 10 through 18: 24310 19448 12376 6188 2380 680 136 17 1 f = Columns 1 through 9: 1 18 153 816 3060 8568 18564 31824 43758 Columns 10 through 18: 48620 43758 31824 18564 8568 3060 816 153 18 Column 19: 1 f = Columns 1 through 9: 1 19 171 969 3876 11628 27132 50388 75582 Columns 10 through 18: 92378 92378 75582 50388 27132 11628 3876 969 171 Columns 19 and 20: 19 1 f = Columns 1 through 8: 1 20 190 1140 4845 15504 38760 77520 Columns 9 through 16: 125970 167960 184756 167960 125970 77520 38760 15504 Columns 17 through 21: 4845 1140 190 20 1 f = Columns 1 through 8: 1 21 210 1330 5985 20349 54264 116280 Columns 9 through 16: 203490 293930 352716 352716 293930 203490 116280 54264 Columns 17 through 22: 20349 5985 1330 210 21 1 f = Columns 1 through 8: 1 22 231 1540 7315 26334 74613 170544 Columns 9 through 16: 319770 497420 646646 705432 646646 497420 319770 170544 Columns 17 through 23: 74613 26334 7315 1540 231 22 1 f = Columns 1 through 7: 1 23 253 1771 8855 33649 100947 Columns 8 through 14: 245157 490314 817190 1144066 1352078 1352078 1144066 Columns 15 through 21: 817190 490314 245157 100947 33649 8855 1771 Columns 22 through 24: 253 23 1 10> clear f 11> f1=[1] f1 = 1 12> f2=[1 1]; 13> f=f1; 14> for k=1:8 f=conv(f,f2); end 15> f f = 1 8 28 56 70 56 28 8 1 16> quit