       Re: [Q] Implementing identities as rules

• To: mathgroup at smc.vnet.net
• Subject: [mg18653] Re: [mg18608] [Q] Implementing identities as rules
• From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
• Date: Thu, 15 Jul 1999 01:45:44 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```The natural way seems to be just a slight variation of your own approach:

In:=

f = Function[{x, y}, Exp[x^2 + y^2]];

In:=
D[f[x, y], x]
Out=
2    2
x  + y
2 E        x

In:=
%2 /. Exp[a_^2 + b_^2] :> HoldForm[f][a, b]
Out=
2 x f[x, y]

In:=
ReleaseHold[%]
Out=
2    2
x  + y
2 E        x

--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp

----------
>From: "Kevin Jaffe" <kj0 at mailcity.com>
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net
>Subject: [mg18653] [mg18608] [Q] Implementing identities as rules
>Date: Tue, Jul 13, 1999, 2:01 PM
>

>
>
> During symbolic manipulations it often important to be able to use
> both sides of an identity or definition.  For example, let f be a
> function defined by
>
> In:= f = Function[{x, y}, Exp[x^2 + y^2]];
>
> Its partial derivative with respect to x is:
>
> In:= D[f[x, y], x]
>
>             2    2
>            x  + y
> Out= 2 E        x
>
> Now, I want to recast this result in the form 2 x f[x, y], i.e. I want
> to revert to the "left-hand side" of the original definition of f[x,
> y].  How does one do this in Mathematica?  I know that if I try the
> rule
>
>
> In:= %2 /. Exp[a_^2 + b_^2] :> f[a, b]
>
>              2    2
>             x  + y
> Out= 2 E        x
>
>
> I get the original expression, because when the pattern is replace,
> f[a, b] is immediately evaluated to reproduce the original expression.
> (I know that the replacement occurs because if instead I use a rule
> whose right hand side cannot be evaluated further
>
> In:= %2 /. Exp[a_^2 + b_^2] :> g[a, b]
>
> Out= 2 x g[x, y]
>
> I get the desired result.)
>
> Is there a way to instruct Mathematica not to evaluate the expression
> after the replacement has been made?
>
> Thanks,
>
> kj0 at mailcity.com
>
>
> Get your FREE Email at http://mailcity.lycos.com
> Get your PERSONALIZED START PAGE at http://my.lycos.com

```

• Prev by Date: Re: Rationalizing the denominator
• Next by Date: Re: How to import 3D STL or IGES File to M-ma?
• Previous by thread: Re: [Q] Implementing identities as rules
• Next by thread: Re: [Q] Implementing identities as rules