I'm trying to replace variables outside of certain functions. More precisely, in the standard ones like Sin
substitution should work while in undefined BC
and u
(and all their derivatives) should not, and it always should work outside of any functions.
I checked 71691 and 33025 but found no suitable advice.
From this:
-x1 BC[x1, x2, x3, t1, t2] Sin[x2]^2 u[x1, x2, x3, t1, t2] + D[BC[x1, x2, x3, t1, t2],x1,x1]
With a substitution like {x1->x1[t1,t2], x2->x2[t1,t2]}
I would like to get this:
-x1[t1,t2] BC[x1, x2, x3, t1, t2] Sin[x2[t1,t2]]^2 u[x1, x2, x3, t1, t2] + D[BC[x1, x2, x3, t1, t2],x1,x1]
Derivative is of course written with upper indices in the code. I'm trying (according to the previous answers) this:
EQ = -x1 BC[x1, x2, x3, t1, t2] Sin[x2]^2 u[x1, x2, x3, t1, t2] + D[BC[x1, x2, x3, t1, t2],x1,x1];
EQPOS = Join[Position[EQ, BC[__]], Position[EQ, u[__]]];
EQPOSED = MapAt[ReplaceAll[#, {x1 -> EX1, x2 -> EX2, x3 -> EX3}] &, EQ, EQPOS] /. {x1 -> x1[t1, t2], x2 -> x2[t1, t2], x3 -> x3[t1, t2]} /. {EX1 -> x1, EX2 -> x2, EX3 -> x3}
As you can see this method fails to work with derivatives.
Join[Position[EQ, BC[__] | Derivative[__][BC][__]], Position[EQ, u[__] | Derivative[__][u][__]]]
$\endgroup$