Download MuPAD from SciFace

MuPAD Pro Computing Essentials - Examples 

Example 10.1 - To Produce Polynomials

Suppose that we need to obtain all the polynomials of the form 



for fixed n and k=0..n. Here is a procedure producing such polynomials in the list form. 

shortPolynomials := proc(n: Type::NonNegInt)

local allPoly, k, part1, part2,
      part3, mylist, polyresult;
begin
   //--------------- internal procedure -------------
   nOverK := proc(n: Type::NonNegInt,
                  k:Type::NonNegInt)
   local result;
   begin
      if k<=n then
         result:=n!/(k!*(n-k)!);
         return(result)
      else
         return(NIL)
      end;
   end: //-------------------------------------------
   allPoly :=[];
   for k from 0 to n do
      part1 := [1, [n,0]];
      part2 := [nOverK(n,k),[k,n-k]];
      part3 := [1,[0,n]];
      mylist := [part1,part2,part3];
      polyresult:=poly(mylist,[x,y]);
      allPoly := allPoly.[polyresult]
   end;
   return(allPoly)
end:


shortPolynomials(5)
 
[poly(x^5 + 2*y^5, [x, y]), 
 poly(x^5 + 5*x*y^4 + y^5, [x, y]), 
 poly(x^5 + 10*x^2*y^3 + y^5, [x, y]), 
 poly(x^5 + 10*x^3*y^2 + y^5, [x, y]), 
 poly(x^5 + 5*x^4*y + y^5, [x, y]), 
 poly(2*x^5 + y^5, [x, y])]
  
TOP