Re: problems with parameter lumping using ReplaceAll
- To: mathgroup at smc.vnet.net
- Subject: [mg105893] Re: [mg105871] problems with parameter lumping using ReplaceAll
- From: "David Park" <djmpark at comcast.net>
- Date: Wed, 23 Dec 2009 02:43:24 -0500 (EST)
- References: <26848924.1261475774162.JavaMail.root@n11>
Replace only matches the exact pattern and doesn't know or do any algebra. When matching fails the best first step is to look at the FullForm of the expression and the pattern in the rule to see how they differ. In your example you have to write an extended set of rules, and simplify the pattern first. sol // Simplify; % //. {2 V1 - 2 V2 -> 2 w, -2 V1 + 2 V2 -> -2 w, -V1 + V2 -> -w, 2 V3 - 2 V4 -> 2 x, -2 V3 + 2 V4 -> -2 x, -V3 + V4 -> -x} There is another easier way to simplify this using Simplify with Assumptions. That will do some algebra. Simplify[sol, V1 - V2 == w \[And] V3 - V4 == x] David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: sean [mailto:sean_incali at yahoo.com] Hello Group, I have a pretty nasty expression that I'm trying the lump the parameters for. I'm having problems making mathematica perform the following replacement. Like I said it's pretty nasty and hope it pastes ok. sol = {{C[0]->p/(-4 a+4 b)+(Sqrt[l^2-m] vd)/(-4 a+4 b)-Sqrt[u-v-2 Sqrt [l^2-m] q vd-2 Sqrt[l^2-m] r vd]/(-4 a+4 b),M[0]->-(i/(2 V1-2 V2))-j/ (2 V1-2 V2)+Sqrt[s^2-4 t]/(2 V1-2 V2)+V1/(2 V1-2 V2)-V2/(2 V1-2 V2),X [0]->l/(2 V3-2 V4)+Sqrt[l^2-m]/(2 V3-2 V4)},{C[0]->p/(-4 a+4 b)+(Sqrt [l^2-m] vd)/(-4 a+4 b)-Sqrt[u-v-2 Sqrt[l^2-m] q vd-2 Sqrt[l^2-m] r vd]/ (-4 a+4 b),M[0]->i/(-2 V1+2 V2)+j/(-2 V1+2 V2)+Sqrt[s^2-4 t]/(-2 V1+2 V2)-V1/(-2 V1+2 V2)+V2/(-2 V1+2 V2),X[0]->l/(2 V3-2 V4)+Sqrt[l^2-m]/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2-m]/ (-2 V3+2 V4)-V3/(-2 V3+2 V4)+V4/(-2 V3+2 V4)},{C[0]->p/(-4 a+4 b)-(Sqrt [l^2-m] vd)/(-4 a+4 b)+Sqrt[u-v+2 Sqrt[l^2-m] q vd+2 Sqrt[l^2-m] r vd]/ (-4 a+4 b),M[0]->-(i/(2 V1-2 V2))-j/(2 V1-2 V2)+Sqrt[s^2-4 t]/(2 V1-2 V2)+V1/(2 V1-2 V2)-V2/(2 V1-2 V2),X[0]->f/(-2 V3+2 V4)+g/(-2 V3+2 V4)+Sqrt[l^2-m]/(-2 V3+2 V4)-V3/(-2 V3+2 V4)+V4/(-2 V3+2 V4)},{C[0]->p/ (-4 a+4 b)-(Sqrt[l^2-m] vd)/(-4 a+4 b)+Sqrt[u-v+2 Sqrt[l^2-m] q vd+2 Sqrt[l^2-m] r vd]/(-4 a+4 b),M[0]->i/(-2 V1+2 V2)+j/(-2 V1+2 V2)+Sqrt [s^2-4 t]/(-2 V1+2 V2)-V1/(-2 V1+2 V2)+V2/(-2 V1+2 V2),X[0]->f/(-2 V3+2 V4)+g/(-2 V3+2 V4)+Sqrt[l^2-m]/(-2 V3+2 V4)-V3/(-2 V3+2 V4)+V4/ (-2 V3+2 V4)}} sol//. 2 V1-2 V2-> 2w/. 2 V3-2 V4 -> 2x//Simplify If you try it, 2 V1- 2 V2 is only replaced in every other denominator in the solutions. (There are 8 equilibrium points in the sol up there) It also fails to recognize that -V1 + V2 is -w. Similarly, 2 V3-2 V4 -> 2x fails to replace in some of the expressions. It seems like it has to do with - sign in front of the expression that mathematica is trying to make the replacements into. If the expression contains the - sign, it doesn't replace the expression. Question is how do I make the replacements regardless the sign? Thanks much in advance. Sean