kill(all)$

maxima :appendix : study of polynomial properties,version 1.0
peter.vlasschaert@gmail.com,31/01/2021

ref:
==
-------------------------------------------------------------------------------------------------------------------
https://stackoverflow.com/questions/35855762/coefficients-of-polynomials-maxima
https://maths.cnam.fr/Membres/wilk/MathMax/help/Maxima/maxima_39.html
-------------------------------------------------------------------------------------------------------------------
=>  programming example 'use lambda'

given : polynomial variables both (x,y)
----------------------------------------------------

p1 : 4*y^8 - 3*x^5 + x^2 + 1$

hipow:works on expression('lopow')

p1a:hipow(p1,x);

p1b:hipow(p1,y);

lmax : works on list ('lmin')

p1c:lmax([p1a,p1b]);

→ variables of the polynomial(=expression)

p1d:listofvars(p1);

(p)redicate : example  : integerp,evenp,oddp,.........
----------------------------------------------------------------------
result : true or false

p1e:map(integerp,[p1a,p1b,p1d]);

function : degree(expression=polynomial(x,y))  
--------------------------------------------------------------------------------------
result : if expression = integer                                → 0
             if expression = polynomial two variables → integer ≠ 0
---------------------------------------------------------------------------------------
see :(p)redicate

reason : how to put 'lambda' inside function degree( combination with map,see above)

use : lambda & map
================

f: lambda ([x], x^2);/* math : f(x) → x^2 */

f(a);                /* math :f(a) → a^2 */

map(f,[a,b,c,d,e]);  /* evaluation : all elements of the list */

use: function
==========

f1(x,y):=''p1;

[f1(a,b),f1(2,3)];

use :degree function
================

degree(p) := if integerp(p) then 0 else 
            lmax(map (lambda([u], hipow(p,u)),listofvars(p)))$

relation between f ,'above'  x^2 → hipow(p,u)

degree(p1);

degree(2);

steps:

map :  1e) step

=> first        sequence : u:x  → hipow(p,x)
     second  sequence : u:y  → hipow(p,y)

lmax :  2e) step

 lmax(hipow(p,x),hipow(p,y))

mydegree
========

f2(pp,uu):=hipow(pp,uu);

makelist(f2(p1,listofvars(p1)[k]),k,1,length(listofvars(p1)));
    ;

→ mydegree1 , function :outside

mydegree1(pp):= block([],
if integerp(pp)  then  0 else  
(q1:makelist(f2(pp,listofvars(pp)[k]),k,1,length(listofvars(pp))),
lmax(q1))        
)$

mydegree1(p1);

mydegree1(2);

→ mydegree2 , function :inside

mydegree2(pp):= block([],
if integerp(pp)  then  0 else      
(f3(pp,uu):=hipow(pp,uu),   
makelist(f3(pp,listofvars(pp)[k]),k,1,length(listofvars(pp))),
lmax(q1))        
)$

mydegree2(p1);

mydegree2(2);

info:

programming :simple    : map       &  lambda,without block
programming :complex : makelist & function, with     block

reason :document to understand : lambda ,'maxima' , instruction.

mydegree3(pp):=
if integerp(pp)  then  0 else      
(f3(pp,uu):=hipow(pp,uu),   
q1:makelist(f3(pp,listofvars(pp)[k]),k,1,length(listofvars(pp))),
lmax(q1))$     

rem : mydegree3(pp), without block

mydegree3(p1);

mydegree3(2);

example polynomial : 4*y^8 - 3*x^5 + x^2 + 1+6*z^9 .
========================================

------------------------------------------------------------------------------

q11 : 4*y^8 - 3*x^5 + x^2 + 1+6*z^9$

[x,y,z]
--------

q12 : listofvars(q11);

q13:mydegree3(q11);

coef:  z^9, max degree
--------------------------------

q14:ratcoef(q11,z^q13);

-----------------------------------------------------------------------------