MathGroup Archive 1998

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

Search the Archive

RE: Approximate




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




  • Prev by Date: subscript subtleties II
  • Next by Date: Re: Plotting w/o artifacts at discontinuities
  • Prev by thread: subscript subtleties II
  • Next by thread: Re: Plotting w/o artifacts at discontinuities