2 if properties(reduce_consts) = [] then load(rducon)$
3 /* We begin by illustrating REDUCE_CONSTS on a very simple example, EXP1.
4 But first, we need to establish a database of constants: */
5 declare([b,con,a,mu,tau,alpha,beta],constant);
8 /* Remember that the definitions of all generated constants are kept in
11 /* For the next examples, lets reinitialize CONST_EQNS for convenience,
12 and change the prefix for generated constants to "ZZZ" : */
16 exp2:5/4*b*(c*t+u*v)/(r-s)/mu^(1/3);
19 /* Observe that the constant ZZZ1 was not found as mu^(1/3) because of the
20 internal form in which MACSYMA stores quotients.
22 Next, we have an expression which contains a power easily expressed in
23 terms of ZZZ1. Lets see what REDUCE_CONSTS does to it. */
24 exp3:alpha*mu^(2/3)*(u+v*t);
27 /* Since mu^(2/3) = mu*mu^(-1/3), REDUCE_CONSTS took advantage of that fact
28 and generated a more optimal means of computing ZZZ3. For other types of
29 constant expressions, REDUCE_CONSTS attempts to find ways of computing
30 them in terms of the existing database of constant definitions.
32 While REDUCE_CONSTS generally reduces the size of the expression it
33 operates on, it will not do this if there are no constant subexpressions
35 exp4:mu^(-t/3)*u*kappa;
37 /* For another example, note that because MACSYMA has already declared %PI
38 to be a constant, REDUCE_CONSTS also knows about this fact: */
39 exp5:(s-v)/(alpha-%pi);
42 /* REDUCE_CONSTS also knows how to collapse out portions of a sum which
47 /* And it knows that scalar functions of constant expressions are
52 exp7:f*cos(alpha+beta);
55 remove([b,con,a,mu,tau,alpha,beta],constant);