MathGroup Archive 2006

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

Search the Archive

Re: Simplification with constraints


Not very elegant but...

conSimplify[expr_, cons_]:=Module[{sub,
        var=Cases[cons, _Symbol?(!NumericQ[#]&), Infinity]},
      sub=Last/@(Solve[cons, #]&/@var);
      Sort[expr/.sub,
          LeafCount[#1]<LeafCount[#2]&]//First];

cons=a*a+b*b+c*c+d*d==1;

expr=#.#&/@Subsets[{a,b,c,d},{3}]

{a^2 + b^2 + c^2, a^2 + b^2 + d^2, a^2 + c^2 + d^2, b^2 + c^2 + d^2}

conSimplify[#,cons]&/@expr

{1 - d^2, 1 - c^2, 1 - b^2, 1 - a^2}


Bob Hanlon

---- Vladimir <vladimir347 at yahoo.com> 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
> 


  • Prev by Date: Re: Problem with text rendering on Linux.
  • Next by Date: Re: Simplification with constraints
  • Previous by thread: RE: Simplification with constraints
  • Next by thread: SphericalPlot3D