       Re: Simplification with constraints

• To: mathgroup at smc.vnet.net
• Subject: [mg72063] Re: [mg72040] Simplification with constraints
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Sun, 10 Dec 2006 04:49:17 -0500 (EST)
• References: <200612091109.GAA28038@smc.vnet.net>

```On 9 Dec 2006, at 20:09, Vladimir wrote:

> Suppose we have a constraint:
>
> a*a+b*b+c*c+d*d==1
>
> What is the most elegant and general way to simplify any expression
> considering above constraint for simplification?
>
> For (just a simple) example:
>
> In[]:=simplify[b*b+c*c+d*d]
>
> should give:
>
> Out[]=1-a*a
>
> --
> thanks in advance,
>
1. The faster method.  Use PolynomialReduce directly:

Last[PolynomialReduce[b*b + c*c + d*d, 1 - (a*a + b*b + c*c + d*d),
{b, c, d, a}]]

1 - a^2

2. The slower but easier to use and understand method:

Use the Variable Order Independent version of Simplify due to Adam
Strzebonski (which he once posted on this list and which I have re-
posted at least twice)

VOISimplify[vars_, expr_, assum_:True] :=
Module[{perm, ee, best},
perm = Permutations[vars];
ee = (FullSimplify @@ ({expr, assum} /. Thread[vars -> #])) & /
@ perm;
best = Sort[Transpose[{LeafCount /@ ee, ee, perm}]][];
best[] /. Thread[best[] -> vars]]

VOISimplify[{a, b, c, d}, b*b + c*c + d*d, a*a + b*b + c*c + d*d == 1]

1 - a^2

Andrzej Kozlowski

```

• Prev by Date: Re: Simplification with constraints
• Next by Date: RE: how-to show a contourplot together with a point grid
• Previous by thread: Simplification with constraints
• Next by thread: Re: Simplification with constraints