> restart;
(1) Collegamenti tra somma serie e concetto di "media"
(rivediamo es. già considerato, usando questa volta del sosftware)
N: numero di volte per cui devo lanciare una moneta equa affinche' esca Testa
Pr(N=1) = 1/2
Pr(N=2) = 1/4
Pr(N=3) = 1/8
Pr(N=k) = 1/2^k
Ci aspettiamo che: Somma [k=1..INF] Pr(N=k) = 1
> P:= k -> 1/2^k;
Conviene mettere l'indice tra apici: vedi l'help su sum.
> F := k -> sum('P(i)', 'i'=1..k);
> F(1); F(2); F(3); F(n); F(infinity);
    1/2   3/4   7/8   −2/2(n+1)+1   1
OK (la somma doveva essere 1).

Con Poligon:
P(x)=1/2^x
[1,10] P SUM
=0.9990234375
[1,40] P SUM
=0.999999999999091
[1,80] P SUM
=1
---------------
Valor medio del lancio di un dado.
Ogni uscita ha prob. 1/6
> Q:= k -> 1/6;
> Sum('Q(i)', 'i'=1..6)= sum('Q(i)', 'i'=1..6);
    ∑ i = 1..6 Q(i) = 1
Media:
> sum('Q(k)*k', 'k'=1..6);
    7/2
OK

Con Poligon:
Q(x)=1/6
R(x)=Q(x)*x
[1,6] R SUM
=7/2
---------------
Lancio di due dadi (H(n) = prob. che la somma sia n):
> H := k -> piecewise(k<8, (k-1)/36, k>=8, (13-k)/36);
> Sum('H(i)', 'i'=2..12) = sum('H(i)', 'i'=2..12);
    ∑ i = 2..12 H(i) = 1
Media:
> sum('H(k)*k', 'k'=2..12);
    7
OK
Con Poligon avrei fatto:
h(x)=(x<8)*((INT(x)-1)/36)+(x>=8)*((13-INT(x))/36)
plot x:1..13 n=1000 y: h | 14
oo
-
[2,12] h SUM
S(x)=x*h(x)
[2,12] S SUM
---------------
Torniamo all'es. inziale.
Media:
> sum('P(k)*k', 'k'=1..infinity);
    2
OK
--------------
(2) Altri primi esempi di somma infinita
Somma per n da 1 a INF 1/n^2.   Mentre:
> Sum('1/n', 'n'=1..infinity) = sum('1/n', 'n'=1..infinity);
    ∑ n = 1..∞ 1/n = ∞
diverge, abbiamo che la nostra somma converge:
> Sum('1/n^2', 'n'=1..infinity) = sum('1/n^2', 'n'=1..infinity);
    ∑ n = 1..∞ 1/n2 = π2/6
Come fare il grafico della somma parziale di ordine k al variare di k? Idea:
> plot(round(x),x=-2..5);
   
> f := x -> sum('1/n^2', 'n'=1..round(x));
> plot (f,1/2..10+1/2); plot (f,1/2..100+1/2);
   
> evalf(Pi^2/6);
    1.644934068
--------------------
Invece per   ∑ 1/n   avremmo avuto ...
> f := x -> sum('1/n', 'n'=1..round(x));
> plot (f,1/2..1000+1/2);
   
-----------------
(continua)

Note
(1) The sum command is for "symbolic" summation. It is used to compute a formula for an indefinite or definite sum. It Maple cannot compute a closed form, Maple returns the sum ``unevaluated''. A typical example would be sum(k,k=0..n-1); which returns the formula n^2/2-n/2. If you want to add up a finite sequence of values, rather than compute a formula, use the add command. For example add(k,k=0..9) returns 45. Although the sum command can be used to compute explicit sums, the add command should be used in programs where an explicit sum is needed.
(2) It is recommended (and often necessary) that both f and k be enclosed in single quotes to prevent premature evaluation. (For example, k may have a previous value.) Thus the common format is sum('f', 'k'=m..n).