Re: replace all
- To: mathgroup at smc.vnet.net
- Subject: [mg121774] Re: replace all
- From: A Retey <awnl at gmx-topmail.de>
- Date: Sat, 1 Oct 2011 03:08:43 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j63t61$6eg$1@smc.vnet.net>
Am 30.09.2011 10:04, schrieb Richard Cangelosi: > Can anyone help with a replace all question. I defined a nonlinear > pde in my notebook > > pde = D[ u[z,t], t] - D[ u[z,t], {z,2}] == beta r[ u[z,t] ]; > > and I would like to do a replace all where I replace u with a > perturbation series > > u[z,t] = u_0 + epsilon u_1[z,t] + O[epsilon]^2 > > It appears that Mathematica ignores u in the partials and will only > replace u in the argument of r. If such replacements don't do what you expect the general rule is to look at FullForm of the expression: In[1]:= pde=D[u[z,t],t]-D[u[z,t],{z,2}]==beta r[u[z,t]]; In[2]:= FullForm[pde] Out[2]//FullForm= Equal[Plus[Derivative[0,1][u][z,t],Times[-1,Derivative[2,0][u][z,t]]],Times[beta,r[u[z,t]]]] this is not nice to read, but it makes clear why your replacement doesn't work: there are no u[z,t] but only Derivatives[___][u][z,t] in those terms. There is another general trick when you want to replace functions in an expression that also has derivatives of those functions: do the replacement without specifying arguments, as here: pde /. u -> Function[{z, t}, Subscript[u, 0] + \[Epsilon] Subscript[u, 1][z, t] + O[epsilon]^2] hth, albert