RE: Approximate
- To: mathgroup@smc.vnet.net
- Subject: [mg12189] RE: [mg12102] Approximate
- From: Ersek_Ted%PAX1A@mr.nawcad.navy.mil
- Date: Fri, 1 May 1998 03:08:40 -0400
John Pinson wrote: ---------- |My use of Mathematica yields expressions with literal parameters that |run on for pages. But I know that two or three of the terms in these |expressions dominate the rest because I know that (e.g.) p1/p2>>p3/p4. |How can I tell Mathematica this and get it to automatically drop p3/p4 |from p1/p2 + p3/p4, and p3 from p1 p4/p2 + p3, and (p2 p3)^2 from (p1 |p4)^2 + (p2 p3)^2, and p2/p1 from p2/p1 + p4/p3, and 1 from p1 p4/p2/p3 |+ 1, et al.? | he following should work. In[1]:= expr={ p1/p2+p3/p4, p1*p4/p2+p3, (p1*p4)^2+(p2*p3)^2, p2/p1+p4/p3+x, p1*p4/p2/p3+1+x}; In[2]:= rules={ p3/p4+p1/p2->p1/p2, p1*p4/p2+p3->p1*p4/p2, (p1*p4)^2+(p2*p3)^2->(p1*p4)^2, p2/p1+p4/p3->p4/p3, p1*p4/p2/p3+1->p1*p4/p2/p3}; In[3]:= expr//.rules Out[3]= {p1/p2, (p1*p4)/p2, p1^2*p4^2, p4/p3 + x, (p1*p4)/(p2*p3) + x} Note: If you use In[3]:= expr/.rules only one replacement will be made. You are about to enter the world of pattern matching. There are some tricks of the trade here. Write back when you start having trouble. Ted Ersek