MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Simplification with constraints


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,
> Vladimir
>
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}]][[1]];
       best[[2]] /. Thread[best[[3]] -> 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