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
  • $\begingroup$ 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. $\endgroup$
    – Aky
    Mar 30, 2014 at 12:48
  • $\begingroup$ @kuba I eliminated all subscripts and expressed my function in term of two variables instead of six. $\endgroup$
    – shadraws
    Mar 30, 2014 at 12:59
  • $\begingroup$ 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. $\endgroup$
    – Wouter
    Mar 30, 2014 at 13:05
  • $\begingroup$ @Wouter I can't exactly understand what you means with protect, at least in terms of code. $\endgroup$
    – shadraws
    Mar 30, 2014 at 13:26
  • $\begingroup$ With 'protect from' I just mean 'but not multiply' the terms etc. $\endgroup$
    – Wouter
    Mar 30, 2014 at 14:31

1 Answer 1


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.

  • $\begingroup$ is this what you're after? $\endgroup$
    – Kuba
    Mar 30, 2014 at 19:03
  • $\begingroup$ 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. $\endgroup$
    – shadraws
    Mar 30, 2014 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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