Sponsored links: Algebra eBooks
 

Related

block-load-mod-next_prime-power_mod-totient

nod(a,b):=block(load(...

q1:next_prime(8462384...

q2:next_prime(56432423);

Calculate

block-emptyp-first-if-last-listp-makelist-rest-second

pairs(items):=block([...

pairs(makelist(n, n, ...

pairs(makelist(n, n, ...

Calculate

block-load-mod-next_prime-power_mod-totient

nod(a,b):=block(load(...

P:next_prime(9999999);

Q:next_prime(99999999...

Calculate

block-do-if-length-makelist-random-while

merge(a) := block( lo...

combinarListas(b, izq...

mergesort(makelist(ra...

Calculate

block-ident-length-matrix-sqrt-transpose

R(a,b):= block ([v, s...

cross(a,b) := [a[2]*b...

norm(v):= sqrt(v[1]^2...

Calculate

block-length-ratsimp-sum-tab

lagrange(tab) := bloc...

lagrange([[1,3],[2,3]...

Calculate

block

foo (x, y) := y - x;

block (a: %e, b: 17);

foo (a, b);

Calculate

block-length-makelist-print

sustprogresiva(matrix...

Calculate

block-load-mod-next_prime-power_mod-totient

nod(a,b):=block(load(...

p1:next_prime(655674);

p2:next_prime(3535763...

Calculate

block-listofvars-op-polynomialp-print-ratexpand-sqrt

generalcoeffp(cfs):=b...

coeff(sqrt(2*x+1),x,0);

polynomialp(sqrt(2*x+...

Calculate

block

Run Example
(%i1)factorC(_f,_z):=block([s,n,m,fp,j],fp:1,/* This commented code was meant to use themore robust solver to_poly_solve, but I couldn't understand how to handle multiplicitiesss:args(to_poly_solve(_f,_z)),s:create_list(ss[k][1],k,1,length(ss)),*/s:solve(_f,_z),m:multiplicities,n:length(s),for j:1 thru n do  if lhs(s[j])#0  then fp:fp*(_z-(rhs(s[j])))^m[j], fp:fp*divide(_f,fp)[1],fp);
(%o1) factorC(_f, _z) := block([s, n, m, fp, j], fp : 1, s : solve(_f, _z), 
m : multiplicities, n : length(s), for j thru n 
                                             m
                                              j
do if lhs(s ) # 0 then fp : fp (_z - rhs(s ))  , fp : fp divide(_f, fp) , fp)
           j                              j                            1
(%i2) partfracC(_f,_z):=block([d,fd],d:denom(_f),fd:factorC(d,_z),partfrac(1/fd,_z));
(%o2) partfracC(_f, _z) := block([d, fd], d : denom(_f), fd : factorC(d, _z), 
                                                                       1
                                                              partfrac(--, _z))
                                                                       fd
(%i3) O:partfracC(1/(x^5-1)^4,x);
               4 %i %pi           2 %i %pi             2 %i %pi
               --------           --------           - --------
                  5                  5                    5
(%o3) (41992 %e         + 42160 %e         + 42076 %e
             4 %i %pi                  4 %i %pi         2 %i %pi            4 %i %pi            4 %i %pi
           - --------                  --------         --------          - --------            --------
                5                         5                5                   5                   5
 + 41824 %e           + 42328)/((625 %e         - 625 %e         + 1875 %e           - 1875) (%e         x
 - 1))
           4 %i %pi          2 %i %pi            2 %i %pi            4 %i %pi
           --------          --------          - --------          - --------
              5                 5                   5                   5
 + (1082 %e         + 1018 %e         + 1114 %e           + 1114 %e
                    2 %i %pi           2 %i %pi           4 %i %pi
                    --------         - --------         - --------
                       5                  5                  5
 + 1082)/((- 1250 %e         + 625 %e           + 625 %e          )
    4 %i %pi
    --------
       5           2
 (%e         x - 1) )
        4 %i %pi        2 %i %pi          2 %i %pi          4 %i %pi
        --------        --------        - --------        - --------
           5               5                 5                 5
   28 %e         + 20 %e         + 12 %e           + 20 %e           + 20
 + ----------------------------------------------------------------------
                   2 %i %pi         4 %i %pi     4 %i %pi
                 - --------         --------     --------
                      5                5            5           3
          (625 %e           - 625 %e        ) (%e         x - 1)
               4 %i %pi         2 %i %pi           2 %i %pi           4 %i %pi
               --------         --------         - --------         - --------
                  5                5                  5                  5
 + 1/((- 125 %e         - 125 %e         - 125 %e           - 125 %e
           4 %i %pi                      4 %i %pi          2 %i %pi
           --------                      --------          --------
              5           4                 5                 5
 + 500) (%e         x - 1) ) - (- 1544 %e         - 1880 %e
          2 %i %pi           4 %i %pi
        - --------         - --------
             5                  5
 - 32 %e           - 368 %e           - 956)
            4 %i %pi          2 %i %pi            2 %i %pi            4 %i %pi     2 %i %pi
            --------          --------          - --------          - --------     --------
               5                 5                   5                   5            5
/((- 4375 %e         - 6875 %e         + 6875 %e           + 4375 %e          ) (%e         x - 1))
         4 %i %pi         2 %i %pi          2 %i %pi          4 %i %pi
         --------         --------        - --------        - --------
            5                5                 5                 5
 + (42 %e         + 170 %e         + 42 %e           - 54 %e           + 170)
           4 %i %pi          2 %i %pi           2 %i %pi            4 %i %pi
           --------          --------         - --------          - --------
              5                 5                  5                   5
/((- 625 %e         + 1875 %e         - 625 %e           - 2500 %e           + 1875)
    2 %i %pi
    --------
       5           2
 (%e         x - 1) )
        4 %i %pi       2 %i %pi          2 %i %pi         4 %i %pi
        --------       --------        - --------       - --------
           5              5                 5                5
 - (4 %e         - 4 %e         - 12 %e           + 4 %e           - 12)
         4 %i %pi           2 %i %pi           4 %i %pi           2 %i %pi
         --------         - --------         - --------           --------
            5                  5                  5                  5           3
/((625 %e         - 625 %e           + 625 %e           - 625) (%e         x - 1) )
       2 %i %pi           4 %i %pi         2 %i %pi           2 %i %pi           4 %i %pi
     - --------           --------         --------         - --------         - --------
          5                  5                5                  5                  5
 + %e          /((- 125 %e         - 125 %e         + 500 %e           - 125 %e
           2 %i %pi
           --------
              5           4
 - 125) (%e         x - 1) )
            4 %i %pi           2 %i %pi             2 %i %pi
            --------           --------           - --------
               5                  5                    5
 - (41824 %e         + 42076 %e         + 42160 %e
             4 %i %pi                  4 %i %pi         2 %i %pi            4 %i %pi
           - --------                  --------         --------          - --------
                5                         5                5                   5
 + 41992 %e           + 42328)/((625 %e         - 625 %e         + 1875 %e           - 1875) (x
     4 %i %pi
     --------
        5
 - %e        ))
           4 %i %pi          2 %i %pi            2 %i %pi            4 %i %pi
           --------          --------          - --------          - --------
              5                 5                   5                   5
 + (1114 %e         + 1082 %e         + 1082 %e           + 1114 %e
                    2 %i %pi           2 %i %pi           4 %i %pi
                    --------         - --------         - --------
                       5                  5                  5
 + 1018)/((- 1250 %e         + 625 %e           + 625 %e          )
        4 %i %pi
        --------
           5     2
 (x - %e        ) )
        4 %i %pi        2 %i %pi          2 %i %pi          4 %i %pi
        --------        --------        - --------        - --------
           5               5                 5                 5
   20 %e         + 20 %e         + 20 %e           + 12 %e           + 28
 - ----------------------------------------------------------------------
                    2 %i %pi         4 %i %pi         4 %i %pi
                  - --------         --------         --------
                       5                5                5     3
           (625 %e           - 625 %e        ) (x - %e        )
       4 %i %pi           4 %i %pi         2 %i %pi           2 %i %pi           4 %i %pi
     - --------           --------         --------         - --------         - --------
          5                  5                5                  5                  5
 + %e          /((- 125 %e         - 125 %e         - 125 %e           - 125 %e
               4 %i %pi
               --------
                  5     4
 + 500) (x - %e        ) )
         4 %i %pi         2 %i %pi            2 %i %pi           4 %i %pi
         --------         --------          - --------         - --------
            5                5                   5                  5
 - (32 %e         + 956 %e         + 1544 %e           + 368 %e
                    4 %i %pi          2 %i %pi            2 %i %pi            4 %i %pi
                    --------          --------          - --------          - --------
                       5                 5                   5                   5
 + 1880)/((- 4375 %e         - 6875 %e         + 6875 %e           + 4375 %e          ) (x
     2 %i %pi
     --------
        5
 - %e        ))
          4 %i %pi        2 %i %pi          2 %i %pi           4 %i %pi
          --------        --------        - --------         - --------
             5               5                 5                  5
 + (170 %e         + 42 %e         + 42 %e           + 170 %e           - 54)
           4 %i %pi          2 %i %pi           2 %i %pi            4 %i %pi
           --------          --------         - --------          - --------
              5                 5                  5                   5
/((- 625 %e         + 1875 %e         - 625 %e           - 2500 %e           + 1875)
        2 %i %pi
        --------
           5     2
 (x - %e        ) )
          4 %i %pi        2 %i %pi         2 %i %pi         4 %i %pi
          --------        --------       - --------       - --------
             5               5                5                5
 - (- 4 %e         + 12 %e         + 4 %e           - 4 %e           + 12)
         4 %i %pi           2 %i %pi           4 %i %pi               2 %i %pi
         --------         - --------         - --------               --------
            5                  5                  5                      5     3
/((625 %e         - 625 %e           + 625 %e           - 625) (x - %e        ) )
       4 %i %pi           4 %i %pi         2 %i %pi           2 %i %pi           4 %i %pi
     - --------           --------         --------         - --------         - --------
          5                  5                5                  5                  5
 + %e          /((- 125 %e         - 125 %e         + 500 %e           - 125 %e
               2 %i %pi
               --------
                  5     4
 - 125) (x - %e        ) )
         4 %i %pi         2 %i %pi           2 %i %pi          4 %i %pi
         --------         --------         - --------        - --------
            5                5                  5                 5
   120 %e         + 120 %e         - 132 %e           + 36 %e           + 36
 - -------------------------------------------------------------------------
                4 %i %pi         2 %i %pi            2 %i %pi
                --------         --------          - --------
                   5                5                   5
         (625 %e         + 625 %e         - 1250 %e          ) (x - 1)
        4 %i %pi        2 %i %pi          2 %i %pi         4 %i %pi
        --------        --------        - --------       - --------
           5               5                 5                5
   36 %e         + 36 %e         - 60 %e           + 4 %e           + 4
 + --------------------------------------------------------------------
             4 %i %pi         2 %i %pi            2 %i %pi
             --------         --------          - --------
                5                5                   5             2
      (625 %e         + 625 %e         - 1250 %e          ) (x - 1)
        4 %i %pi          4 %i %pi         2 %i %pi           2 %i %pi           4 %i %pi
        --------          --------         --------         - --------         - --------
           5                 5                5                  5                  5
 - (8 %e        )/((500 %e         - 125 %e         - 125 %e           - 125 %e
                      4 %i %pi
                      --------
               3         5
 - 125) (x - 1) ) + %e
         4 %i %pi         2 %i %pi           2 %i %pi           4 %i %pi
         --------         --------         - --------         - --------
            5                5                  5                  5
/((500 %e         - 125 %e         - 125 %e           - 125 %e           - 125)
        4
 (x - 1) )
(%i4) tex(O);
$${{41992\,e^{{{4\,i\,\pi}\over{5}}}+42160\,e^{{{2\,i\,\pi}\over{5}}}
 +42076\,e^ {- {{2\,i\,\pi}\over{5}} }+41824\,e^ {- {{4\,i\,\pi
 }\over{5}} }+42328}\over{\left(625\,e^{{{4\,i\,\pi}\over{5}}}-625\,e
 ^{{{2\,i\,\pi}\over{5}}}+1875\,e^ {- {{4\,i\,\pi}\over{5}} }-1875
 \right)\,\left(e^{{{4\,i\,\pi}\over{5}}}\,x-1\right)}}+{{1082\,e^{{{
 4\,i\,\pi}\over{5}}}+1018\,e^{{{2\,i\,\pi}\over{5}}}+1114\,e^ {- {{2
 \,i\,\pi}\over{5}} }+1114\,e^ {- {{4\,i\,\pi}\over{5}} }+1082}\over{
 \left(-1250\,e^{{{2\,i\,\pi}\over{5}}}+625\,e^ {- {{2\,i\,\pi}\over{
 5}} }+625\,e^ {- {{4\,i\,\pi}\over{5}} }\right)\,\left(e^{{{4\,i\,
 \pi}\over{5}}}\,x-1\right)^2}}+{{28\,e^{{{4\,i\,\pi}\over{5}}}+20\,e
 ^{{{2\,i\,\pi}\over{5}}}+12\,e^ {- {{2\,i\,\pi}\over{5}} }+20\,e
 ^ {- {{4\,i\,\pi}\over{5}} }+20}\over{\left(625\,e^ {- {{2\,i\,\pi
 }\over{5}} }-625\,e^{{{4\,i\,\pi}\over{5}}}\right)\,\left(e^{{{4\,i
 \,\pi}\over{5}}}\,x-1\right)^3}}+{{1}\over{\left(-125\,e^{{{4\,i\,
 \pi}\over{5}}}-125\,e^{{{2\,i\,\pi}\over{5}}}-125\,e^ {- {{2\,i\,\pi
 }\over{5}} }-125\,e^ {- {{4\,i\,\pi}\over{5}} }+500\right)\,\left(e
 ^{{{4\,i\,\pi}\over{5}}}\,x-1\right)^4}}-{{-1544\,e^{{{4\,i\,\pi
 }\over{5}}}-1880\,e^{{{2\,i\,\pi}\over{5}}}-32\,e^ {- {{2\,i\,\pi
 }\over{5}} }-368\,e^ {- {{4\,i\,\pi}\over{5}} }-956}\over{\left(-
 4375\,e^{{{4\,i\,\pi}\over{5}}}-6875\,e^{{{2\,i\,\pi}\over{5}}}+6875
 \,e^ {- {{2\,i\,\pi}\over{5}} }+4375\,e^ {- {{4\,i\,\pi}\over{5}} }
 \right)\,\left(e^{{{2\,i\,\pi}\over{5}}}\,x-1\right)}}+{{42\,e^{{{4
 \,i\,\pi}\over{5}}}+170\,e^{{{2\,i\,\pi}\over{5}}}+42\,e^ {- {{2\,i
 \,\pi}\over{5}} }-54\,e^ {- {{4\,i\,\pi}\over{5}} }+170}\over{\left(
 -625\,e^{{{4\,i\,\pi}\over{5}}}+1875\,e^{{{2\,i\,\pi}\over{5}}}-625
 \,e^ {- {{2\,i\,\pi}\over{5}} }-2500\,e^ {- {{4\,i\,\pi}\over{5}} }+
 1875\right)\,\left(e^{{{2\,i\,\pi}\over{5}}}\,x-1\right)^2}}-{{4\,e
 ^{{{4\,i\,\pi}\over{5}}}-4\,e^{{{2\,i\,\pi}\over{5}}}-12\,e^ {- {{2
 \,i\,\pi}\over{5}} }+4\,e^ {- {{4\,i\,\pi}\over{5}} }-12}\over{
 \left(625\,e^{{{4\,i\,\pi}\over{5}}}-625\,e^ {- {{2\,i\,\pi}\over{5
 }} }+625\,e^ {- {{4\,i\,\pi}\over{5}} }-625\right)\,\left(e^{{{2\,i
 \,\pi}\over{5}}}\,x-1\right)^3}}+{{e^ {- {{2\,i\,\pi}\over{5}} }
 }\over{\left(-125\,e^{{{4\,i\,\pi}\over{5}}}-125\,e^{{{2\,i\,\pi
 }\over{5}}}+500\,e^ {- {{2\,i\,\pi}\over{5}} }-125\,e^ {- {{4\,i\,
 \pi}\over{5}} }-125\right)\,\left(e^{{{2\,i\,\pi}\over{5}}}\,x-1
 \right)^4}}-{{41824\,e^{{{4\,i\,\pi}\over{5}}}+42076\,e^{{{2\,i\,\pi
 }\over{5}}}+42160\,e^ {- {{2\,i\,\pi}\over{5}} }+41992\,e^ {- {{4\,i
 \,\pi}\over{5}} }+42328}\over{\left(625\,e^{{{4\,i\,\pi}\over{5}}}-
 625\,e^{{{2\,i\,\pi}\over{5}}}+1875\,e^ {- {{4\,i\,\pi}\over{5}} }-
 1875\right)\,\left(x-e^{{{4\,i\,\pi}\over{5}}}\right)}}+{{1114\,e^{
 {{4\,i\,\pi}\over{5}}}+1082\,e^{{{2\,i\,\pi}\over{5}}}+1082\,e^ {- 
 {{2\,i\,\pi}\over{5}} }+1114\,e^ {- {{4\,i\,\pi}\over{5}} }+1018
 }\over{\left(-1250\,e^{{{2\,i\,\pi}\over{5}}}+625\,e^ {- {{2\,i\,\pi
 }\over{5}} }+625\,e^ {- {{4\,i\,\pi}\over{5}} }\right)\,\left(x-e^{
 {{4\,i\,\pi}\over{5}}}\right)^2}}-{{20\,e^{{{4\,i\,\pi}\over{5}}}+20
 \,e^{{{2\,i\,\pi}\over{5}}}+20\,e^ {- {{2\,i\,\pi}\over{5}} }+12\,e
 ^ {- {{4\,i\,\pi}\over{5}} }+28}\over{\left(625\,e^ {- {{2\,i\,\pi
 }\over{5}} }-625\,e^{{{4\,i\,\pi}\over{5}}}\right)\,\left(x-e^{{{4\,
 i\,\pi}\over{5}}}\right)^3}}+{{e^ {- {{4\,i\,\pi}\over{5}} }}\over{
 \left(-125\,e^{{{4\,i\,\pi}\over{5}}}-125\,e^{{{2\,i\,\pi}\over{5}}}
 -125\,e^ {- {{2\,i\,\pi}\over{5}} }-125\,e^ {- {{4\,i\,\pi}\over{5}}
  }+500\right)\,\left(x-e^{{{4\,i\,\pi}\over{5}}}\right)^4}}-{{32\,e
 ^{{{4\,i\,\pi}\over{5}}}+956\,e^{{{2\,i\,\pi}\over{5}}}+1544\,e^ {- 
 {{2\,i\,\pi}\over{5}} }+368\,e^ {- {{4\,i\,\pi}\over{5}} }+1880
 }\over{\left(-4375\,e^{{{4\,i\,\pi}\over{5}}}-6875\,e^{{{2\,i\,\pi
 }\over{5}}}+6875\,e^ {- {{2\,i\,\pi}\over{5}} }+4375\,e^ {- {{4\,i\,
 \pi}\over{5}} }\right)\,\left(x-e^{{{2\,i\,\pi}\over{5}}}\right)}}+
 {{170\,e^{{{4\,i\,\pi}\over{5}}}+42\,e^{{{2\,i\,\pi}\over{5}}}+42\,e
 ^ {- {{2\,i\,\pi}\over{5}} }+170\,e^ {- {{4\,i\,\pi}\over{5}} }-54
 }\over{\left(-625\,e^{{{4\,i\,\pi}\over{5}}}+1875\,e^{{{2\,i\,\pi
 }\over{5}}}-625\,e^ {- {{2\,i\,\pi}\over{5}} }-2500\,e^ {- {{4\,i\,
 \pi}\over{5}} }+1875\right)\,\left(x-e^{{{2\,i\,\pi}\over{5}}}
 \right)^2}}-{{-4\,e^{{{4\,i\,\pi}\over{5}}}+12\,e^{{{2\,i\,\pi
 }\over{5}}}+4\,e^ {- {{2\,i\,\pi}\over{5}} }-4\,e^ {- {{4\,i\,\pi
 }\over{5}} }+12}\over{\left(625\,e^{{{4\,i\,\pi}\over{5}}}-625\,e
 ^ {- {{2\,i\,\pi}\over{5}} }+625\,e^ {- {{4\,i\,\pi}\over{5}} }-625
 \right)\,\left(x-e^{{{2\,i\,\pi}\over{5}}}\right)^3}}+{{e^ {- {{4\,i
 \,\pi}\over{5}} }}\over{\left(-125\,e^{{{4\,i\,\pi}\over{5}}}-125\,e
 ^{{{2\,i\,\pi}\over{5}}}+500\,e^ {- {{2\,i\,\pi}\over{5}} }-125\,e
 ^ {- {{4\,i\,\pi}\over{5}} }-125\right)\,\left(x-e^{{{2\,i\,\pi
 }\over{5}}}\right)^4}}-{{120\,e^{{{4\,i\,\pi}\over{5}}}+120\,e^{{{2
 \,i\,\pi}\over{5}}}-132\,e^ {- {{2\,i\,\pi}\over{5}} }+36\,e^ {- {{4
 \,i\,\pi}\over{5}} }+36}\over{\left(625\,e^{{{4\,i\,\pi}\over{5}}}+
 625\,e^{{{2\,i\,\pi}\over{5}}}-1250\,e^ {- {{2\,i\,\pi}\over{5}} }
 \right)\,\left(x-1\right)}}+{{36\,e^{{{4\,i\,\pi}\over{5}}}+36\,e^{
 {{2\,i\,\pi}\over{5}}}-60\,e^ {- {{2\,i\,\pi}\over{5}} }+4\,e^ {- {{
 4\,i\,\pi}\over{5}} }+4}\over{\left(625\,e^{{{4\,i\,\pi}\over{5}}}+
 625\,e^{{{2\,i\,\pi}\over{5}}}-1250\,e^ {- {{2\,i\,\pi}\over{5}} }
 \right)\,\left(x-1\right)^2}}-{{8\,e^{{{4\,i\,\pi}\over{5}}}}\over{
 \left(500\,e^{{{4\,i\,\pi}\over{5}}}-125\,e^{{{2\,i\,\pi}\over{5}}}-
 125\,e^ {- {{2\,i\,\pi}\over{5}} }-125\,e^ {- {{4\,i\,\pi}\over{5}}
  }-125\right)\,\left(x-1\right)^3}}+{{e^{{{4\,i\,\pi}\over{5}}}
 }\over{\left(500\,e^{{{4\,i\,\pi}\over{5}}}-125\,e^{{{2\,i\,\pi
 }\over{5}}}-125\,e^ {- {{2\,i\,\pi}\over{5}} }-125\,e^ {- {{4\,i\,
 \pi}\over{5}} }-125\right)\,\left(x-1\right)^4}}$$
(%o4)                                false
(%i5) 
Run Example
rat(0.1234);

rat: replaced 0.1234 by 617/5000 = 0.1234
                                     617
(%o1)/R/                             ----
                                     5000
(%i2) rat(0.12345);

rat: replaced 0.12345 by 2469/20000 = 0.12345
                                     2469
(%o2)/R/                             -----
                                     20000
(%i3) rat(0.12345);

rat: replaced 0.12345 by 2469/20000 = 0.12345
                                     2469
(%o3)/R/                             -----
                                     20000
(%i4) mod(12345, 1000)/100000, numer;
(%o4)                               0.00345
(%i5) lastdigits(fnum, lastn):=block([m:10*fnum, ans, n:lastn], /* it doesn't help when lastn is bigger than the total digits in fnum it returns the whole digits in fnum anyway without erroring! and fnum=%pi stuff works only upto 8 digits cause num(rat(fnum)) has somuch only! */ratprint:false, k:rat(fnum), ans:mod(m, (10^-n))/(mod(m, 10)*denom(k)), return(float(ans)));
(%o5) lastdigits(fnum, lastn) := block([m : 10 fnum, ans, n : lastn], 
                                                   - n
                                          mod(m, 10   )
ratprint : false, k : rat(fnum), ans : -------------------, return(float(ans)))
                                       mod(m, 10) denom(k)
(%i6) lastdigits(0.12345, 3);
(%o6)                        2.0251113811259619E-8
(%i7) 
Run Example
P [s1,s2,s3,s4,s5] := block ( [tot: s1+s2+s3+s4+s5] , s1/tot*(if (s1>
1) then P [s1-1,s2,s3,s4,s5] else 1)+(if s2<
=1 then 0 else P [s1,s2-1,s3,s4,s5]*s2/tot)+(if s3<
=1 then 0 else P [s1,s2,s3-1,s4,s5]*s3/tot)+(if s4<
=1 then 0 else P [s1,s2,s3,s4-1,s5]*s4/tot)+(if s5<
=1 then 0 else P [s1,s2,s3,s4,s5-1]*s5/tot) );
(%o1) P                   := block([tot : s1 + s2 + s3 + s4 + s5], 
       s1, s2, s3, s4, s5
s1
--- (if s1 > 1 then P                       else 1)
tot                  s1 - 1, s2, s3, s4, s5
                           P                       s2
                            s1, s2 - 1, s3, s4, s5
 + (if s2 <= 1 then 0 else --------------------------)
                                      tot
                           P                       s3
                            s1, s2, s3 - 1, s4, s5
 + (if s3 <= 1 then 0 else --------------------------)
                                      tot
                           P                       s4
                            s1, s2, s3, s4 - 1, s5
 + (if s4 <= 1 then 0 else --------------------------)
                                      tot
                           P                       s5
                            s1, s2, s3, s4, s5 - 1
 + (if s5 <= 1 then 0 else --------------------------))
                                      tot
(%i2) srt[s1,s2,s3,s4,s5] := cons(s1, sort([s2,s3,s4,s5]));
(%o2)      srt                   := cons(s1, sort([s2, s3, s4, s5]))
              s1, s2, s3, s4, s5
(%i3) P [s1,s2,s3,s4,s5] := block ( [tot: s1+s2+s3+s4+s5] , s1/tot*(if (s1>
1) then arrayapply(P, srt[s1-1,s2,s3,s4,s5]) else 1)+(if s2<
=1 then 0 else arrayapply(P, srt[s1,s2-1,s3,s4,s5])*s2/tot)+(if s3<
=1 then 0 else arrayapply(P, srt[s1,s2,s3-1,s4,s5])*s3/tot)+(if s4<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4-1,s5])*s4/tot)+(if s5<
=1 then 0 else arrayapply(P, srt[s1,s2,s3,s4,s5-1])*s5/tot) );
(%o3) P                   := block([tot : s1 + s2 + s3 + s4 + s5], 
       s1, s2, s3, s4, s5
s1
--- (if s1 > 1 then arrayapply(P, srt                      ) else 1)
tot                                  s1 - 1, s2, s3, s4, s5
                           arrayapply(P, srt                      ) s2
                                            s1, s2 - 1, s3, s4, s5
 + (if s2 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s3
                                            s1, s2, s3 - 1, s4, s5
 + (if s3 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s4
                                            s1, s2, s3, s4 - 1, s5
 + (if s4 <= 1 then 0 else -------------------------------------------)
                                               tot
                           arrayapply(P, srt                      ) s5
                                            s1, s2, s3, s4, s5 - 1
 + (if s5 <= 1 then 0 else -------------------------------------------))
                                               tot
(%i4) P[11,12,12,12,12];
                                    497664
(%o4)                               -------
                                    2232265
(%i5) 
[append,ascii,block,concat,copylist,delete,divsum,first,if,make_random_state,next_prime,second,set_random_state,slength,substring,true] [append,ascii,block,concat,delete,divsum,first,if,make_random_state,next_prime,second,set_random_state,slength,substring,true] [append,atom,block,delete,flatten,if,lambda,load,map,return] [append,block,buildq,emptyp,find_root,first,flatten,floor,kill,last,listp,makelist,not,rest,second,sin] [append,block,buildq,first,return,show,simp] [append,block,declare,do,factor,lsum] [append,block,emptyp,find_root,first,flatten,floor,kill,last,listp,makelist,not,rest,second,sin] [append,block,listify,makelist,primep,return,setify] [bern,bfloat,block,fpprec,makelist,numer,return,sum] [bfloat,bftorat,block,ev,float2bf,makelist,mod,ratepsilon,ratprint,return] [bfloat,bftorat,block,float2bf,makelist,mod,ratepsilon,ratprint,return] [bfloat,binomial,block,distrib,floor,load,sum] [bfloat,block,denom,false,float,mod,ratexpand,ratprint] [bftorat,block,delete,ev,false,float,if,integerp,mod,ratdenom,ratepsilon,ratprint] [bftorat,block,delete,float,if,integerp,mod,rat,ratdenom,ratepsilon,ratprint] [bftorat,block,false,float2bf,fpprec,if,integerp,kill,mod,ratdenom,ratepsilon,ratprint,return] [binomial,block,delta,determinant,do,expand,genmatrix,kron_delta,return] [block,concat,do,kill,makelist,obase,return,stringdisp,true,while] [block,cons,if,sort] [block,cos,flatten,if,li,load,makelist,map,numer,outermap,plot2d,sin,sort,unique] [block,cos,plot2d,quad_qags,sin] [block,display,fpprec,fpprintprec,return] [block,do,float,round] [block,do,indices,lambda,makelist,map,mod,print,sublist_indices] [block,do,makelist,plot2d,while] [block,do,mod,return,while] [block,do,round] [block,endcons,mod] [block,float] [block,genmatrix,if,print,random,return,while] [block,if,load,primep] [block,ifactors,load,mod,next_prime,power_mod,totient] [block,ifactors,load,next_prime] [block,inv_mod,mod,print] [block,inv_mod,print,while] [block,length,ratsimp,sum,tab] [block,load,mod,next_prime,power_mod,primep,totient] [block,load,mod,next_prime,power_mod,totient] [block,load,mod,power_mod,primep,totient] [block,load,mod,power_mod,totient] [block,load,mod,totient] [block,load,next_prime,primep] [block,load,next_prime,totient] [block,load,next_prime] [block,load] [block,plot2d] [block,primep,print] [block,print] [block,return] [block]

Related Help

Help for Block