Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have defined my function in this way

w = f[r,Θ] ;

After some calculations i obtained my results with respect to the previous function. For instance:

Set[lapla1, -(1/(2 μ)) (1/r D[w r, {r, 2}] - 1/r^2 (D[w, {Θ, 2}] + Cot[Θ] D[w, {Θ, 1}]))] // ExpandAll

In this moment i don't need to work with the previous function $w$, instead i need to keep my previous result, multiply lapla1 by $r$ and work with a new $w$

w = f[r, Θ]/r ;

I'm trying to use pure functions to accomplish this, however i don't know if i'm proceeding correctly.

Set[lapla11,lapla1*r /. f -> (f[#, #2]/r &) // ExpandAll ]


When you make this transformation, the term $\frac{1 }{rμ }\frac{\partial f}{\partial r}$ must disappear from lapla1. This is the only way i found to prove it

Set[lapla12, -(r/(2 μ)) (1/r D[w/r r, {r, 2}] - 1/r^2 (D[w/r, {Θ, 2}] + Cot[Θ] D[w/r, {Θ, 1}]))] // ExpandAll
share|improve this question
If I understand your problem correctly, an immediate solution would be use SetDelayed instead of Set in the expression Set[lapla1, ...] // TrigExpand // ExpandAll. Then when you change $w_1$ the change would reflect next time you evaluated lapla1. That said, this isn't a great way to write code - perhaps you should make lapla1 a function of $w_1$. Also note that the single quote ' isn't a valid character for a variable name, assuming that's what you're going for in the last command. –  Aky Mar 30 at 12:48
@kuba I eliminated all subscripts and expressed my function in term of two variables instead of six. –  shadraws Mar 30 at 12:59
I understand that you want to multiply lapla1 with (ra*rb) but 'protect" the terms including an 'f[]' from this multiplication. Your code works, except that you apply the replacement rule outside the Set statement instead of inside. Same goes for the first use of ExpandAll. –  Wouter Mar 30 at 13:05
@Wouter I can't exactly understand what you means with protect, at least in terms of code. –  shadraws Mar 30 at 13:26
With 'protect from' I just mean 'but not multiply' the terms etc. –  Wouter Mar 30 at 14:31

1 Answer 1

up vote 1 down vote accepted

If you want the term $\frac{\partial f}{\partial r}$ to disappear you need to introduce new function which would be:

w2 = f[r, θ] r

which means that you have to make a substitution f -> w2/r, this way:

lapla1 /. f -> (w2[#, #2]/# &) // Simplify // ExpandAll 

enter image description here

If you once used f or w, don't change theirs definitions, use a new one, you will less likely make a mistake.

share|improve this answer
is this what you're after? –  Kuba Mar 30 at 19:03
The answer looks more easier than i thought. Thank you very much @Kuba. In order to get the result i was expecting, I didn't define a new variable, instead i use the previous one for w lapla1*r /. f -> (f[#, #2]/# &) // Simplify // ExpandAll // TraditionalForm Regarding to your advise, in this case is ease to see the new definition, however i'll take it into account for future. –  shadraws Mar 30 at 19:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.