2

In maxima, I have an expression that is simplified to an expression similar to the form of:

tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);

A typical simplification by hand would be to distribute the exponential term while leaving the $c$ and $d$ factored. However, I can't seem to coerce maxima to produce this form of the expression.

distrib(tmp) or expand(tmp) produces $c d e^{-b t} - c d e^{-a t}$

factor(tmp) produces: $-c d (e^{b t} - e^{a t}) e^{-b t - a t}$

factor(distrib(tmp)) produces the same expression as factor alone $-c d (e^{b t} - e^{a t}) e^{-b t - a t}$

Is there a way to coerce maxima into simplifying tmp into the desired form of $c d (e^{-b t} - e^{-a t})$ ? I realize the equivalence is trivial to keep track of in this case, but this pattern is often useful within more complex expressions as well.

rj8
  • 25

2 Answers2

3

The following will do what you desire

ev(factor(ev(tmp, t = -t)), t = -t)
Bill Dubuque
  • 282,220
  • that still produces cd(%e^(at)−%e^(bt))%e^(−bt−a*t). Maxima must be doing some implicit reordering before running the command. If I split it into two commands "factor(ev(tmp, t=-t)); ev(%, t=-t);" it works. Kind of a kluge, but I'm glad something works. – rj8 Jan 03 '14 at 05:51
  • Yes I ran it as two commands too. – Bill Dubuque Jan 03 '14 at 06:01
  • I have a similar problem. How do I declare a function to be multi-linear and alternating? I am trying to simplify some determinant identities, and maxima will only let me make it linear in the first argument. – user44197 Jan 03 '14 at 15:16
  • @user44197 You can probably use TELLSIMP to work around that. There are also some share packages that do multilinear algebra, e.g. ATENSOR. – Bill Dubuque Jan 03 '14 at 15:24
  • @Bill Dubuque Thanks. BTW I liked your analysis of primes of the form 3811111 – user44197 Jan 03 '14 at 15:29
0

Use gcfac instead of factor

(%i1) tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);
                             a t     b t    (- b t) - a t
(%o1)                 c d (%e    - %e   ) %e
(%i2) load("scifac")$
(%i3) gcfac(expand(tmp));
                                   - b t     - a t
(%o3)                       c d (%e      - %e     )

You can also use collectterms

(%i1) tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);
                             a t     b t    (- b t) - a t
(%o1)                 c d (%e    - %e   ) %e
(%i2) e:expand(tmp);
                                 - b t         - a t
(%o2)                      c d %e      - c d %e
(%i3) collectterms(e,c,d);
                                   - b t     - a t
(%o3)                       c d (%e      - %e     )

You can use the box statement. We use it in a way similar to the answer that uses the substitution t by -t: box(-t) isn't recognized as negative exponent anymore. It can be written in one compound statement. The intermediate result after applying ratsubst may look like a little bit scary:

(%i1) tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);
                             a t     b t    (- b t) - a t
(%o1)                 c d (%e    - %e   ) %e

(%i2) rembox(factor(expand(ratsubst(box(-t),-t,tmp))));
                                   - b t     - a t
(%o2)                      c d (%e      - %e     )

Here are two other ways how you can use the box statements. Both avoid ratsubst but are more complicate in specifying the expressions you want to box.

(%i1) tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);
                             a t     b t    (- b t) - a t
(%o1)                 c d (%e    - %e   ) %e

reveal shows us that tmpis a product of 4 factors.

(%i2) reveal(tmp,2);
(%o2)                           c d Sum(2) Expt

In this situation one can use the substpart command to put a box around the 3rd and 4th factor of the product. The variable piece is a global variable that contains the part of the expression specified by the access path ([3,4])in the substpart command.

(%i3) substpart(box(piece),tmp,[3,4]);
                         """""""""""""""""""""""""""""""""
                         "   a t     b t    (- b t) - a t"
(%o3)                c d "(%e    - %e   ) %e             "
                         """""""""""""""""""""""""""""""""

Then one expands the the expression. c and d will not be multiplied into the box.

(%i4) expand(%);
                                """""""""""""""""""
                                "  - b t     - a t"
(%o4)                       c d "%e      - %e     "
                                """""""""""""""""""

% references the last ouput. After expansion the box will be removed by rembox.

(%i5) rembox(%);
                                   - b t     - a t
(%o5)                       c d (%e      - %e     )

One can do this with one statement:

(%i6) rembox(expand(substpart(box(piece),tmp,[3,4])));
                                   - b t     - a t
(%o6)                       c d (%e      - %e     )

Here is another method based on the box statement that will work

(%i1) tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);
                             a t     b t    (- b t) - a t
(%o1)                 c d (%e    - %e   ) %e
(%i2) subst([(-a*t)=box((-a*t)),(-b*t)=box((-b*t))],expand(tmp));
                               """""""         """""""
                               "- b t"         "- a t"
                               """""""         """""""
(%o2)                    c d %e        - c d %e
(%i3) kill(all);
(%o0)                                done
(%i1) tmp : c * d * (exp(a*t) - exp(b*t)) * exp(-a*t-b*t);
                             a t     b t    (- b t) - a t
(%o1)                 c d (%e    - %e   ) %e
(%i2) expand(%);
                                 - b t         - a t
(%o2)                      c d %e      - c d %e
(%i3) subst([(-a*t)=box((-a*t)),(-b*t)=box((-b*t))],%);
                               """""""         """""""
                               "- b t"         "- a t"
                               """""""         """""""
(%o3)                    c d %e        - c d %e
(%i4) factor(%);
                                 """""""     """""""
                                 "- b t"     "- a t"
                                 """""""     """""""
(%o4)                     c d (%e        - %e       )
(%i5) rembox(%);
                                   - b t     - a t
(%o5)                       c d (%e      - %e     )

We can do it in one statement.

(%i6) rembox(factor(subst([(-a*t)=box((-a*t)),(-b*t)=box((-b*t))],expand(tmp))));
                                   - b t     - a t
(%o6)                       c d (%e      - %e     )
miracle173
  • 11,359