Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5297 > unrolled thread
| Started by | Richard Cangelosi <rick.cangelosi@gmail.com> |
|---|---|
| First post | 2011-09-30 08:04 +0000 |
| Last post | 2011-10-01 07:10 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Richard Cangelosi <rick.cangelosi@gmail.com> |
|---|---|
| Date | 2011-09-30 08:04 +0000 |
| Subject | replace all |
| Message-ID | <j63t61$6eg$1@smc.vnet.net> |
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.
[toc] | [next] | [standalone]
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2011-10-01 07:10 +0000 |
| Message-ID | <j66edp$hek$1@smc.vnet.net> |
| In reply to | #5297 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web