Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5306
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: replace all |
| Date | 2011-10-01 07:10 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j66edp$hek$1@smc.vnet.net> (permalink) |
| 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
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
replace all Richard Cangelosi <rick.cangelosi@gmail.com> - 2011-09-30 08:04 +0000 Re: replace all A Retey <awnl@gmx-topmail.de> - 2011-10-01 07:10 +0000
csiph-web