Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: Rule Writing for x and 1/x

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg828] Re: [mg785] Rule Writing for x and 1/x
  • From: Richard Mercer <richard at seuss.math.wright.edu>
  • Date: Mon, 24 Apr 1995 02:52:13 -0400

 >   Is there a way to write a single rule in MMA which will
>  turn J/s into W and s/J into 1/W?
>  

>     {J/s->W} only works for case#1.
>  

Yes, of course, but what's the point?
What could be simpler than just using two rules?

Perhaps your real question is "Why doesn't {J/s->W}
work the way I want on s/J?"

The answer to this question is that Mathematica's
replacement rules are very literal-minded, and do not attempt to search for all  
mathematically equivalent forms. There are good reasons for this, although it  
produces some frustrations.

For the record, here's one way to do it, probably the best way!
Actually it is silly, just burying the two rules inside a single rule.

myrule = fr_ :> (fr /. {J/s->W,s/J->1/W});
{J/s,s/J} /. myrule
    1
{W, -}
    W

Richard Mercer


  • Prev by Date: PowerExpand/InverseTrig snafu
  • Next by Date: a plug for Block, Re: mg[758]
  • Previous by thread: Re: Rule Writing for x and 1/x
  • Next by thread: Re: Rule Writing for x and 1/x