kill(all)$

maxima : find automatic variables ,constant,%e,%i into expression,version 1.0
peter.vlasschaert@gmail.com,15/01/2022

ref :https://maths.cnam.fr/Membres/wilk/MathMax/help/Maxima/maxima_6.html#IDX165

keywords : Maxima
listconstvars(expr),listdummyvars(expr),listofvars(expr),lfreeof (list, expr),freeof(expr,var)

→ 1e)  step : true or false condition, default

predicate  :

p1:[listconstvars,listdummyvars,listofvars];

change option :

option :      listconstantvars:true
listconstvars : true →  listofvars to include %e, %pi, %i, "and"  variables declared

declare(a,integer);

declare(b,constant);

→ option : changed,listconstvars 

listconstvars:true;

example 1:

p2a:sin(a)+%e^x+y+%gamma+3.14159*c+%i;/*Euler-Mascheroni constant =%gamma */

p2a1:print("listdummyvars(p2a),error")$

rem : %i = sqrt(-1)

p2b:float(p2a);

result:

p2a1:listofvars(p2a);

→ option : changed,listconstvars 

listconstvars:false;/* default value*/

option :      listconstantvars:true
listconstvars : true →  listofvars to include  variables declared

example 2:

use : p2a

p3a:listofvars(p2a);

rem : all condition are the same : p1,"Default values"

example 3: will include dummy variables

listdummyvars; /*default*/

p3a: 'sum(f(i)+f(x[i])+c^a+exp(1)+%e^y, i, 0, n);

p3a1:listofvars(p3a);

rem : i = dummy variable,included,automatic check first sum 'p3a'
rem : listconstvars "see %i9" = false, "declared c,a "include,see above

listconstvars:true;/*default*/

p3a2:listofvars(p3a);

example 4: will exclude dummy variables

listdummyvars; /*default*/
listconstvars;

listdummyvars:false; /*set :true*/

p4:listofvars(p3a);

rem : dummy=i ,not in the list p4

example 5: without ' in front "p3a"

p5:sum(f(i)+f(x[i])+c^a+exp(1)+%e^y, i, 0, n);

p5a:listofvars(p5);

rem : same result "p4"

Calculus : Expression

example 6: differentation, with' in front

p6:'diff(y,x,m)+y*'diff(y,x,3)+%e^z+c;

p6a:listofvars(p6);

check : other ones for true or false

p6b:listconstvars;

general : option false by default

p6c:listconstvars:false;

result:

p6d:listofvars(p6);

rem : %e ,excluded

example 7: differentation, without ' in front

p7:diff(y(x),x,m)+y*diff(y(x),x,3)+%e^z+c;

p7a:listofvars(p7);

example 8: integral equation

p8:y(x)= x^a+c+%e^x+'integrate(x*t*y(t),t,a,b);

listdummyvars;

→ lhs,p8

p8a1:listofvars(lhs(p8));

→ rhs,p8

p8a2:listofvars(rhs(p8));

listdummyvars:true;

→ lhs,p8

p8b1:listofvars(lhs(p8));

→ rhs,p8

p8b2:listofvars(rhs(p8));

→ global :equation

p8b3:listofvars(p8);

rem : y , "function" : y(x),y(t)
         b , problem integration values

→ second step :check 

1e) values p1
2e) check always both sides : lhs,rhs
3e) sum ,product inside , part in maxima command, zero also use args(=analysis)
4e) Calculus: problem : values for the integration boundary
5e) integral equations :  ? ,see above

rem : makelist yourself ,declared variables.

→ thrid step :lfreeof (list, expr);

example 9: freeof.lfeeof

p9:p8;

p9a:lfreeof([%e,x,a,v,y(t)],p9);

p9b:lfreeof([v],p9);

p9c:freeof(p9,v);

p9d:freeof(rhs(p9),d);

reF:https://maths.cnam.fr/Membres/wilk/MathMax/help/Maxima/maxima_6.html#IDX153

Function: freeof (x_1, ..., x_n, expr)

    freeof (x_1, expr) Returns true if no subexpression of expr is equal to x_1 or if x_1 occurs only as a dummy variable in expr, or if x_1 is neither the noun nor verb form of any operator in expr, and returns false otherwise.

    freeof (x_1, ..., x_n, expr) is equivalent to freeof (x_1, expr) and ... and freeof (x_n, expr).

    The arguments x_1, ..., x_n may be names of functions and variables, subscripted names, operators (enclosed in double quotes), or general expressions. freeof evaluates its arguments.

    freeof operates only on expr as it stands (after simplification and evaluation) and does not attempt to determine if some equivalent expression would give a different result. In particular, simplification may yield an equivalent but different expression which comprises some different elements than the original form of expr.

    A variable is a dummy variable in an expression if it has no binding outside of the expression. Dummy variables recognized by freeof are the index of a sum or product, the limit variable in limit, the integration variable in the definite integral form of integrate, the original variable in laplace, formal variables in at expressions, and arguments in lambda expressions. Local variables in block are not recognized by freeof as dummy variables; this is a bug.

    The indefinite form of integrate is not free of its variable of integration. 

(%i1) expr: z^3 * cos (a[1]) * b^(c+d);
                                 d + c  3
(%o1)                   cos(a ) b      z
                             1
(%i2) freeof (z, expr);
(%o2)                         false
(%i3) freeof (cos, expr);
(%o3)                         false
(%i4) freeof (a[1], expr);
(%o4)                         false
(%i5) freeof (cos (a[1]), expr);
(%o5)                         false
(%i6) freeof (b^(c+d), expr);
(%o6)                         false
(%i7) freeof ("^", expr);
(%o7)                         false
(%i8) freeof (w, sin, a[2], sin (a[2]), b*(c+d), expr);
(%o8)                         true

→freeof evaluates its arguments. 

(%i1) expr: (a+b)^5$
(%i2) c: a$
(%i3) freeof (c, expr);
(%o3)                         false

→freeof does not consider equivalent expressions. Simplification may yield an equivalent but different expression. 

(%i1) expr: (a+b)^5$
(%i2) expand (expr);
          5        4       2  3       3  2      4      5
(%o2)    b  + 5 a b  + 10 a  b  + 10 a  b  + 5 a  b + a
(%i3) freeof (a+b, %);
(%o3)                         true
(%i4) freeof (a+b, expr);
(%o4)                         false
(%i5) exp (x);
                                 x
(%o5)                          %e
(%i6) freeof (exp, exp (x));
(%o6)                         true

→A summation or definite integral is free of its dummy variable. An indefinite integral is not free of its variable of integration. 

(%i1) freeof (i, 'sum (f(i), i, 0, n));
(%o1)                         true
(%i2) freeof (x, 'integrate (x^2, x, 0, 1));
(%o2)                         true
(%i3) freeof (x, 'integrate (x^2, x));
(%o3)                         false