On 3/30/07, Dave Gee <aspiceq at yahoo.co.uk> wrote:
>
> I have a question about getting expressions into their shortest, most readable form.
>
> I am solving a system of equations and pasting the resulting expression into a C program. What I ideally want is the expression that is shortest to read, but also takes the minimum number of floating point multiplies to evaluate
> (R3 + R2 + R1 ) R5 + ( R3 + R2 + R1 ) R4 + ( R2 + R1 ) R3
>
> But from inspection this simplifies to
>
> ( R1 + R2 + R3 ).( R3 + R4 + R5 ) - ( R3 . R3 )
I'm not aware of any Maxima function or package that will be this
clever. The best I can suggest is choosing which manipulations to do
yourself, but using Maxima to apply them. For example:
ex: (R3 + R2 + R1 ) * R5 + ( R3 + R2 + R1 ) * R4 + ( R2 + R1 ) * R3 $
factor(ex+R3^2)-R3^2 => (R3+R2+R1)*(R5+R4+R3)-R3^2
or
substpart(factor(piece),ex,[1,2]) => (R3+R2+R1)*(R5+R4)+(R2+R1)*R3
which actually has the same number of additions and multiplications as
the other form.
-s