[Date Index]
[Thread Index]
[Author Index]
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[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.
>
>Thanks in advance,
>AC
>
>
Alain,
To understand why vers1 one doesn't work we have to note
In[2]:= D[M[1][t], t] // FullForm
Out[2]//FullForm= Derivative[1][M[1]][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[15]:= expr /. {M[1] -> f, M[2] -> 0} /. 0[t] -> 0
Out[15]= f[t] + Integrate[f[t], t] + Derivative[1][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[28]:= Unprotect[Integer]
In[29]:= x_Integer[_] := x
In[30]:= Protect[Integer]
In[31]:= expr /. {M[1] -> f, M[2] -> 0}
Out[31]= f[t] + Integrate[f[t], t] + Derivative[1][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**
| |