       Re: Problem with transformation rule of a function

• To: mathgroup at smc.vnet.net
• Subject: [mg53478] Re: Problem with transformation rule of a function
• From: Paul Abbott <paul at physics.uwa.edu.au>
• Date: Thu, 13 Jan 2005 03:59:51 -0500 (EST)
• Organization: The University of Western Australia
• References: <16858.22033.555637.91757@localhost.localdomain> <cs5asu\$3r1\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <cs5asu\$3r1\$1 at smc.vnet.net>,
Alain Cochard <alain at geophysik.uni-muenchen.de> wrote:

> I define an expression:
>
>      In:= expr=M[t] + M[t] + Integrate[M[t],t] +
>      Integrate[M[t],t] + D[M[t],t] + D[M[t],t];
>
>      Out= Integrate[M[t], t] + Integrate[M[t], t] + M[t] +
>      M[t] +
>
>      >    (M)'[t] + (M)'[t]
>
> and then I try 2 transformation rules on this expression:
>
>      In:= vers1=expr/.{M[t]->f[t], M[t]->0}
>
>      Out= f[t] + Integrate[f[t], t] + (M)'[t] + (M)'[t]
>
> In this first one, I get the output I expect for the function and
> integration terms, but not for the derivative ones.
>
>      In:= vers2=expr/.{M->f, M->0}
>
>      Out= 0[t] + f[t] + Integrate[0[t], t] + Integrate[f[t], t] + f'[t]

f is a (pure) function but 0 is not. In other words 0[x] is not 0. The
zero function is (0 &) or, alternatively, Function[t,0]. If you enter

(0 &)[x]

or

Function[t,0][x]

you get 0.

> In this second version, I get these 0[t] terms for the function and
> integration terms, with which I further have to deal with to achieve
> what I want:
>
>      In:= %/.{0[t]->0}
>
>      Out= f[t] + Integrate[f[t], t] + f'[t]
>
>
> I would first like to understand why the derivation and integration
> terms are not treated in an identical way, and then I would like to
> know if there is a more elegant way to do what I want in a single
> step.

Writing

expr/.{M->f, M-> (0 &)}

is an elegant way to do what you want in a single step.

Cheers,
Paul

--
Paul Abbott                                   Phone: +61 8 6488 2734
School of Physics, M013                         Fax: +61 8 6488 1014
The University of Western Australia      (CRICOS Provider No 00126G)
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au
AUSTRALIA                            http://physics.uwa.edu.au/~paul

```

• Prev by Date: Re: Mathematica is not very clever
• Next by Date: Re: Re: easy question about random numbers
• Previous by thread: Re: Problem with transformation rule of a function
• Next by thread: Re: Problem with transformation rule of a function