File: rducon.dmo

package info (click to toggle)
maxima 5.6-17
  • links: PTS
  • area: main
  • in suites: woody
  • size: 30,572 kB
  • ctags: 47,715
  • sloc: ansic: 154,079; lisp: 147,553; asm: 45,843; tcl: 16,744; sh: 11,057; makefile: 7,198; perl: 1,842; sed: 334; fortran: 24; awk: 5
file content (55 lines) | stat: -rw-r--r-- 2,336 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-*-MACSYMA-*-*/
if properties(reduce_consts) = [] then load(rducon)$
/* We begin by illustrating REDUCE_CONSTS on a very simple example, EXP1.
   But first, we need to establish a database of constants:              */
declare([b,con,a,mu,tau,alpha,beta],constant);
exp1:p*q+a/b*r;
reduce_consts(exp1);
/* Remember that the definitions of all generated constants are kept in
   CONST_EQNS .                                                          */
const_eqns;
/* For the next examples, lets reinitialize CONST_EQNS for convenience,
   and change the prefix for generated constants to "ZZZ" :             */
const_eqns:[]$
const_prefix:'zzz;
const_counter:1$
exp2:5/4*b*(c*t+u*v)/(r-s)/mu^(1/3);
reduce_consts(exp2);
const_eqns;
/* Observe that the constant ZZZ1 was not found as mu^(1/3) because of the
   internal form in which MACSYMA stores quotients.

   Next, we have an expression which contains a power easily expressed in
   terms of ZZZ1.  Lets see what REDUCE_CONSTS does to it.                */
exp3:alpha*mu^(2/3)*(u+v*t);
reduce_consts(exp3);
const_eqns;
/* Since mu^(2/3) = mu*mu^(-1/3), REDUCE_CONSTS took advantage of that fact
   and generated a more optimal means of computing ZZZ3.  For other types of
   constant expressions, REDUCE_CONSTS attempts to find ways of computing
   them in terms of the existing database of constant definitions.

   While REDUCE_CONSTS generally reduces the size of the expression it
   operates on, it will not do this if there are no constant subexpressions
   to remove:                                                              */
exp4:mu^(-t/3)*u*kappa;
reduce_consts(exp4);
/* For another example, note that because MACSYMA has already declared %PI
   to be a constant, REDUCE_CONSTS also knows about this fact:            */
exp5:(s-v)/(alpha-%pi);
reduce_consts(exp5);
const_eqns;
/* REDUCE_CONSTS also knows how to collapse out portions of a sum which
   are constant:                                                        */
exp6:r*t-alpha+beta;
reduce_consts(exp6);
const_eqns;
/* And it knows that scalar functions of constant expressions are
   constants:                                                     */
const_eqns:[]$
const_prefix:'q$
const_counter:1$
exp7:f*cos(alpha+beta);
reduce_consts(exp7);
const_eqns;
remove([b,con,a,mu,tau,alpha,beta],constant);