       Re: Rule Writing for x and 1/x

• To: mathgroup at christensen.cybernetics.net
• To: mathgroup at christensen.cybernetics.net
• Subject: [mg838] Re: [mg785] Rule Writing for x and 1/x
• From: Allan Hayes <hay at haystack.demon.co.uk>
• Date: Tue, 25 Apr 1995 02:19:24 -0400

```D Reece writes

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

Here is one solution

In:=
{s/J,J/s}//.{a:(s/J) |(J/s)  :> (a/.J->s W)}
Out=
1
{-, W}
W

But for complicated expressions you might find it better to use
AlgebraicRules, or my package AlgebraicRulesExtended (on
MathSource).

In:=
{Sin[5 + a s^2/J],Sqrt[J]/s/ b, s/J, J/s}/.
AlgebraicRulesExtended[ J/s == W]
Out=
a s   Sqrt[s W]  1
{Sin[5 + ---], ---------, -, W}
W       b s     W

Or, if you prefer J to s

In:=
{Sin[5 + a s^2/J],Sqrt[J]/s/ b, s/J, J/s}/.
AlgebraicRulesExtended[ J/s == W,{s,J}]
Out=
a J       W      1
{Sin[5 + ---], ---------, -, W}
2    b Sqrt[J]  W
W

Allan Hayes
hay at haystack.demon.co.uk

```

• Prev by Date: Re: Linearization of a system of differential equations
• Next by Date: Math -> Frame (MIF)?
• Previous by thread: Re: Rule Writing for x and 1/x
• Next by thread: How can I make a complicated Fit.