       Re: Problem with transformation rule of a function

• To: mathgroup at smc.vnet.net
• Subject: [mg53488] Re: [mg53467] Problem with transformation rule of a function
• From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
• Date: Fri, 14 Jan 2005 08:54:35 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```>-----Original Message-----
>From: Alain Cochard [mailto:alain at geophysik.uni-muenchen.de]
To: mathgroup at smc.vnet.net
>Sent: Thursday, January 13, 2005 9:12 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg53488] [mg53467] Problem with transformation rule of a function
>
>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]
>
>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.
>
>AC
>
>

Alain,
To understand why vers1 one doesn't work we have to note

In:= D[M[t], t] // FullForm
Out//FullForm= Derivative[M][t]

So vers2 seems to be more appropriate.  The drawback is that Matematica
doesn't know that 0[t] === 0 for all t.

Telling that with your second substitution is completely ok, so

In:= expr /. {M -> f, M -> 0} /. 0[t] -> 0
Out= f[t] + Integrate[f[t], t] + Derivative[f][t]

You may however make a definition in general for (e.g. integer) constant
functions (telling Mathematica what you mean with 0[t]):

In:= Unprotect[Integer]

In:= x_Integer[_] := x

In:= Protect[Integer]

In:= expr /. {M -> f, M -> 0}
Out= f[t] + Integrate[f[t], t] + Derivative[f][t]

--
Hartmut Wolf

```

• Prev by Date: Re: Re: Mathematica is not very clever
• Next by Date: Re: Mathematica Graphics output in an ASP.NET WebApplication
• Previous by thread: Re: Problem with transformation rule of a function
• Next by thread: size of typeset boxes