Re: Problem with transformation rule of a function

• To: mathgroup at smc.vnet.net
• Subject: [mg53490] Re: [mg53467] Problem with transformation rule of a function
• From: DrBob <drbob at bigfoot.com>
• Date: Fri, 14 Jan 2005 08:54:38 -0500 (EST)
• References: <16858.22033.555637.91757@localhost.localdomain> <200501130812.DAA03785@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Your first attempt fails because M[2][t] doesn't actually appear in the expr's derivative term:

expr = M[1][
t] + M[2][t] + Integrate[M[1][t], t] +
Integrate[M[2][t], t] + D[M[1][t], t] + D[M[2][t], t];
FullForm[expr]

FullForm[Integrate[M[1][t], t] +
Integrate[M[2][t], t] +
M[1][t] + M[2][t] +
Derivative[1][M[1]][t] +
Derivative[1][M[2]][t]]

Look closely, and you'll see where M[2][t] does -- and doesn't -- appear.

The second attempt almost works, but this is what you really want:

expr //. {M[1] -> f, M[2] -> (0 & )}
f[t] + Integrate[f[t], t] + Derivative[1][f][t]

0& is the zero function you meant to use.

Bobby

On Thu, 13 Jan 2005 03:12:10 -0500 (EST), Alain Cochard <alain at geophysik.uni-muenchen.de> wrote:

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

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: List element extraction
• Next by Date: Re: List element extraction
• Previous by thread: Problem with transformation rule of a function
• Next by thread: Re: Problem with transformation rule of a function