kill(all)$

tutorial : sum and products ,version 1.0
peter.vlasschaert@gmail.com,19/11/2018

load packages.

load(lrats)$

products
========

Function: genfact (<x>, <y>, <z>)
=>  Returns the generalized factorial, defined as `x (x-z) (x - 2 z)
     ... (x - (y - 1) z)'.  Thus, when <x> is an integer, `genfact (x,
       x, 1) = x!' and `genfact (x, x/2, 2) = x!!'.

sample: x*(x-1)*(x-(y-1)*z) = x*(x-1)*(x-(2-1)*1) = x*(x-1)*x(x-2)

p1:genfact (3,2, 1);

3 ! = 3*2*1 = 6

Theory : 
=======

p2:product(x-k, k, 0, 'n);

p2a:part(p2,1);

matchdeclare(k,true);

p2b:args(p2);

p2c:subst([n=2],p2)=ev(product(x-k,k,0,n),n=2);
p2d:subst([n=2],p2)=ev(product(x-v,v,p2b[3],p2b[4]),v=p2b[2],n=2);

Stirling numbers :s[n,m]
====================
-----------------------------------------------------------------------
F : (x)*(x-1)*.......(x-n+1) = sum(s[n,m]*x^m,m,1,n)
------------------------------------------------------------------------

start : p2c or p2d 
==============
--------------------------------------------
example :  n =3 for , F 'above'
--------------------------------------------

p3:ratsimp(p2d);

p3a:rhs(p3) =subst([n=3],sum(s[n,m]*x^m,m,1,n));

p3b:ev(rhs(p3a),sum)=lhs(p3a);

s[n,m] : ?
========

p3c1:coeff(p3b,x^3);
p3c2:coeff(p3b,x^2);
p3c1:coeff(p3b,x^1);

 use : command   'makelist'
syntax 'for' : for i:init thru m step n do (.......)

m:3;

for i:1 thru m do
 (  pn1:makelist(coeff(p3b,x^i),i,1,m))$

pn1;

for i:1 thru m do
 (  pn2:makelist(rhs(coeff(p3b,x^i)),i,1,m),
    pn3:makelist(lhs(coeff(p3b,x^i)),i,1,m))$    

pn3=pn2;

Factorial 
========

=>  F1 : (x)*(x-1)*.......(x-n+1) 

Maxima : 'command  !' ?
------------------------------------

p4:3!;

mefac : ?
--------------

1e)  mefac[1]  ?

p4a:x-n+1;
p4a1:subst([n=1],p4a);

p4b:mefac[1]:p4a1;

2e)  mefac[n] ?

mefac[n]:=''p4a*mefac[n-1];

mefac[3];

3e)  mefac[i] ?  i=1,2,3

p4c:listarray(mefac);

4e)   find : 3! =6

p4d:ev(p4c[3],x=m);

sum
====
---------------------------------------------
ss[n] = 1*2+2*3+......+n*(n+1)
use : m , dummy
--------------------------------------------

ss(n):= sum(m*(m+1),m,1,n);

p5:n*(n+1);

p5a:ss(1);

s1[1]:p5a;

p5b:s1[n]:= ''p5+s1[n-1];

p5b1:s1[5];

listarray(s1);

for i:1 thru 5  do(pn4:makelist(s1[n],n,1,5))$

pn4;

 load packages
==============

load(simplify_sum);

p6:sum(k*(k+1), k, 1, n), simpsum;

 =>  ratsimp

p61:ratsimp(p6);

 =>  factor

p62:factor(p61);

p6a:ev(p62,n=5);

use : to put element  to list:  Maxima ' Command' : endcons
------------------------------------------------------------------------------------------

first : make empty list.
==================

pn5:[];

second : add  all elements one by one   ( by use for 'loop' )
================================

for i:1 thru 5 do ( pn5:endcons(ev(p6,n=i),pn5))$

pn5;

rest(pn5);

member(8,%);

member(10,pn5);

p6b:pn5[5];

rem : % connected with result before.

also : first ,second,thrid,fourth,fifth ................
--------------------------------------------------------------------

p6c1:first(pn5);

p6c2:fifth(pn5);

check :  p5b1  ? p6a, with 'is' , Maxima
================================
result : ?  true or false

is(p5b1=p6a);

why : p5b1 = p6a  => result : true

'---------------------------------------------------------------------------------------------------------------------------'