From: fajar on

Hi all,

I'm new to MuPAD and symbolic computation.

I have this coming from previous computation:

a + b -2*c

How can I convert that into:

(a - c) + (b - c) ?


Another example: Given

a*b + a*c - 2*a*d + b*c - 2*b*d - 2*c*d + 3*d^2

How can I convert that into:

(a-d)*(b-d) + (a-d)*(c-d) + (b-d)*(c-d) ?


I tried 'simplify', 'collect', 'factor', and 'factorout' but did not
work.



Thanks

Fajar
From: Walter Roberson on
fajar wrote:

> I'm new to MuPAD and symbolic computation.
>
> I have this coming from previous computation:
>
> a + b -2*c
>
> How can I convert that into:
>
> (a - c) + (b - c) ?


I have never used MuPad, but I know from the documentation that MuPad
operates fairly similarly to Maple. In Maple, it would not be possible
to make the conversion you wish. Maple would automatically note that the
operator joining the two subexpressions ('+') was associative with the
operators inside the subexpressions ('-') and would convert it to a
single summation, collecting any constants and common terms as it did
so. The result would be the original expression again.

What would be possible in Maple would be to convert it into a expression
that printed out almost exactly the same way as your preferred form, but
was internally not exactly the same in all respects. For example it
would be possible in Maple to convert it into

'a - c' + 'b - c'

where the ' indicates a delayed computation. (Maple would use the term
"unevaluated".) Expressions that contain unevaluated terms in Maple have
to be treated fairly carefully or else Maple will end up doing an
evaluation and thus ending up collapsing the expression again.