MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: replace all

  • To: mathgroup at
  • Subject: [mg121774] Re: replace all
  • From: A Retey <awnl at>
  • Date: Sat, 1 Oct 2011 03:08:43 -0400 (EDT)
  • Delivered-to:
  • References: <j63t61$6eg$>

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]

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]



  • Prev by Date: HoldForm and Sum
  • Next by Date: Re: How to catch interrupts generated by TimeConstrained?
  • Previous by thread: Re: HoldForm and Sum
  • Next by thread: Re: How to catch interrupts generated by TimeConstrained?