# [Maxima] how to make results more compact?

ZINTEL Gerhard gerhard.zintel at faurecia.com
Tue Jan 9 03:13:25 CST 2007

```Hello Stavros,

>> EQ1: Zo*C*L+Zo*A*L-Zo*D*K+Zo*B*K-Zo*C*J-Zo*A*J-Zo*D*I+Zo*B*I+B*L-D*J
>>
>> Now I know the most compact form would be
>>
>> EQ2: Zo * ((C+A)*(L-J) + (B-D)*(K+I)) + B*L - D*J
>>
>> How to make MAXIMA finding EQ2 from EQ1?
>
> If you were able to analyze your expression manually, then you must
> have followed some strategy which allowed you to master this
> combinatorial blowup, which may be based on a priori knowledge of the
> form of the result.  You should be able to program this strategy in
> Maxima.  For example, if every term is of the form (v1+v2)*(v3-v4),
> then you could try divide'ing the expression by all possible (vm+vn)
> etc.

In my mind the algorithm seems very simple - at least when doing it by hand.

Goal is to reduce the overall number of multiplications and summations of an
expression to its minimum. This is always preferable if you want to use a
result of MAXIMA as code fragment in a computer program. (MAXIMA is surely
often used for this?!)

The algorithm seems to be straight forward (at least for that kind of
combinatorial blow-up I used as an example at the end of my posting
http://www.math.utexas.edu/pipermail/maxima/2007/004416.html )

The following should do it.

1. counting which variable appears most often (Zo in my example)

2. factor out this variable; you would get a system like
Zo*[...] + [...]

3. Repeat steps 1, 2 in each part [...] recursively as long as you are
able to factor out further variables; you'll get something like Zo
(a(b+c) + d(-b-c) + e( ... ) + ... ) + ( ... )

4. Substitute all inner summes like (a+b) by a new variable; with e.g.
X=(b+c)
this would lead to something like
Zo (a X - d X + e( ... ) + ... ) + ( ... )

5. Now repeat steps 1 to 4 until the result doesn't change any more.

That should do the trick. Up to now I don't have any knowledge about how to
program this algorithm in MAXIMA. But that may change in future.

Maybe there is someone on the list who is also interested in that subject
and could help me to start.

Thanks
Gerhard

This electronic transmission (and any attachments thereto) is intended
solely for the use of the addressee(s). It may contain confidential or
legally privileged information. If you are not the intended recipient of
this message, you must delete it immediately and notify the sender.
Any unauthorized use or disclosure of this message is strictly prohibited.
Faurecia does not guarantee the integrity of this transmission and shall
therefore never be liable if the message is altered or falsified nor for any
virus, interception or damage to your system.
```