kill(all)$

maxima : programming how to use freeof ,linearp,quadraticp,version 1.0
peter.vlasschaert@gmail.com,09/06/2022

use : freeof,matchdeclare,lambda,defmatch,and,or,ordergreat,ratsimp.

→ linearp : a*x+b, assume a≠ 0

matchdeclare (a, lambda ([e], e#0 and freeof(x, e)))$
matchdeclare (b, freeof(x))$

rem :matchdeclare(v1,freeof(x),v2,freeof(x)) or matchdeclare([v1,v2],freeof(x))
rem :matchdeclare(v,true), v = any expression in place v
rem :matchdeclare([v1,v2],true)

defmatch (linearp, a*x + b,x);

p1:linearp (3*x + (y + 1)*x + y^2,x);

rem : first : matchdeclare → second : defmach

check : "→ p1"

p1a:ratsimp(expand(3*x + (y + 1)*x + y^2),x);

rem : ratsimp(expr,var1,var2,..........)

→ quadraticp: a1*x^2+b1*x+c1 ,assume a1≠0 ,b1 may be zero

matchdeclare (a1, lambda ([e], e#0 and freeof(x^2, e)))$
matchdeclare (b1, lambda ([e], e=0 or  freeof(x, e)))$
matchdeclare (c1, freeof(x))$

defmatch (quadraticp, a1*x^2 + b1*x+c1);

p2:quadraticp(3*x + (y + 1)*x + y^2+x^2);

p3:quadraticp( y^2+x^2);

check : "→ p2"

ordergreat(x)$

p1:3*x + (y + 1)*x + y^2+x^2;

p1a:ratsimp(p1,x^2,x);

problem : result impact ordergreat ?
-----------------------------------------------

quadraticp( y^2+x^2);

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