desencontros.mws

Problema dos Desencontros

11/10/2007

Cálculo do número D_n de desencontros de ordem n

>    Des := proc(n::integer)

>       local k;

>       RETURN(sum((-1)^k  * (n!/k!), k=0..n));

>    end;

Des := proc (n::integer) local k; RETURN(sum((-1)^k*n!/k!,k = 0 .. n)) end proc

>    Des(5);

44

>    seq(Des(i),i=2..15);

1, 2, 9, 44, 265, 1854, 14833, 133496, 1334961, 14684570, 176214841, 2290792932, 32071101049, 481066515734

Cálculo da probabilidade

>    Digits := 20;

>    for i from 2 to 20 do

>       i, evalf(Des(i)/i!);

>    od;

Digits := 20

2, .50000000000000000000

3, .33333333333333333333

4, .37500000000000000000

5, .36666666666666666667

6, .36805555555555555556

7, .36785714285714285714

8, .36788194444444444444

9, .36787918871252204586

10, .36787946428571428571

11, .36787943923360590027

12, .36787944132128159906

13, .36787944116069116069

14, .36787944117216190629

15, .36787944117139718992

16, .36787944117144498469

17, .36787944117144217323

18, .36787944117144232942

19, .36787944117144232120

20, .36787944117144232161

Gráfico da probabilidade

>    with(plots);

>    grafprob := proc(n::integer)

>       local w,i,j;

>       for i from 2 to n do

>          w[i]:=Des(i)/i!;

>       od;

>    pointplot({seq([j,w[j]],j=2..n)},symbol=circle,symbolsize=8,color=red,axes=boxed,title=`Probabilidade para n em [2,20]`,style=LINE):

>    end:

>   

Warning, the name changecoords has been redefined

[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...

>    grafprob(20);

[Maple Plot]

>