[Date Index]
[Thread Index]
[Author Index]
Re: Easy simplification with Mathematica?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg111173] Re: Easy simplification with Mathematica?
*From*: "David Park" <djmpark at comcast.net>
*Date*: Thu, 22 Jul 2010 05:45:37 -0400 (EDT)
If you are new to Mathematica, then I think both of these are somewhat
tricky. You might receive answers that are more transparent.
The problem with expr1 is that Mathematica will automatically recombine your
desired answer to the initial form. The only way to only way to stop that is
to put the two terms in a HoldForm. One method for doing that is to use
substitution rules and some temporary variables.
expr1 = a + b - 2 c;
expr1 /. {a -> x + c, b -> y + c}
% /. {x -> HoldForm[a - c], y -> HoldForm[b - c]}
x + y
(a - c) + (b - c)
You would have to use ReleaseHold if you wanted to do further calculations
with this expression.
The second expression is a little more tricky. I think the simplest approach
is to again introduce temporary variables representing the factors, and then
use the GroebnerBasis routine to obtain a simple expression in terms of
these variables, and then substitute back.
expr2 = a b + a c - 2 a d + b c - 2 b d - 2 c d + 3 d^2;
expr2 /. {a -> x + d, b -> y + d, c -> z + d};
GroebnerBasis[%, {x, y, z}] // First
% /. {x -> a - d, y -> b - d, z -> c - d}
x y + x z + y z
(a - d) (b - d) + (a - d) (c - d) + (b - d) (c - d)
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
From: fajar [mailto:fajar96te at yahoo.com]
Hi all,
I'm new to symbolic computation.
I have this coming from previous computation:
a + b -2*c
How can I convert that expression, with Mathematica, 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 expression, with Mathematica, into:
(a-d)*(b-d) + (a-d)*(c-d) + (b-d)*(c-d) ?
Thanks
Fajar
Prev by Date:
**Re: how to create a mathematica package**
Next by Date:
**Re: Brillouin function for a Ferromagnet**
Previous by thread:
**Re: Easy simplification with Mathematica?**
Next by thread:
**Problem when importing individual frames from an AVI file**
| |