Re: Simplification with constraints
- To: mathgroup at smc.vnet.net
- Subject: [mg72062] Re: [mg72040] Simplification with constraints
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 10 Dec 2006 04:49:15 -0500 (EST)
- Reply-to: hanlonr at cox.net
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 >