Can someone explain to me why Mathematica is ignoring the replacement rules in the following code:

eq = D[ψ[x, y], y] D[ψ[x, y], {y, 2}, {x}] - D[ψ[x, y], x] D[ψ[x, y], {y, 3}] == D[ψ[x, y], {y, 4}];
eq1 = eq /. {ψ[x, y] -> x^α f[η[x, y]], η[x, y] -> y x^-β}
eq2 = eq1 /. {α -> 1/2, β -> 1/2}

Basically, I have a fourth order PDE and I want to define a similarity transformation to reduce it to a third-order ODE. Previously when I ran this, the second command was outputting something in terms of the function f and the variable \eta. However, when I now run this it is just ouputting the exact thing as eq. I don't understand the issue at all. I have tried using various clear commands, but that doesn't seem to be the issue.

As an aside, these are three lines of code in a larger notebook. However, even when I copy and past them into a different notebook the issue persists.

  • $\begingroup$ ReplaceAll works on the full form of an expression, not on what is displayed. To see the full form, use: FullForm. $\endgroup$ Commented Mar 8 at 19:41
  • $\begingroup$ Look at result of InputForm@eq. Your replacement patterns do not exist in eq. $\endgroup$
    – Edmund
    Commented Mar 8 at 19:42
  • $\begingroup$ Does that mean I need to substitute this into the equation and actually calculate the new derivatives by hand? $\endgroup$
    – Mjoseph
    Commented Mar 8 at 19:42
  • $\begingroup$ Yesterday though it was outputting something in terms of the function f. And then when I gave it specific values of alpha and beta it was also putting that in without issue. $\endgroup$
    – Mjoseph
    Commented Mar 8 at 19:43
  • $\begingroup$ Did you try eq1 = eq /. {\[Eta] -> Functon[{x, y}, y x^-\[Beta]], \[Psi] -> Function[{x, y}, x^\[Alpha] f[\[Eta][x, y]]]}? $\endgroup$
    – user64494
    Commented Mar 8 at 19:47

1 Answer 1


You have to replace the functions, not the expressions, in order to get the derivatives, too. The variables in derivatives are always local, a feature ignored in standard math notation.

    eq1 = eq //. 
       {\[Psi] :> Function[{x,y} ,(x^\[Alpha] f[\[Eta][x, y]]], 
        \[Eta] :> Function[{x, y}, y x^-\[Beta]]}

$$x^{2 \alpha -3 \beta -1} \left((\alpha -2 \beta ) f'\left(y x^{-\beta }\right) f''\left(y x^{-\beta }\right)-\alpha f\left(y x^{-\beta }\right) f^{(3)}\left(y x^{-\beta }\right)\right)=x^{\alpha -4 \beta } f^{(4)}\left(y x^{-\beta }\right)$$

Alternatively all derivatives have to be replaced separately.

  • $\begingroup$ Thank you so much for the help! That works perfectly. Do you know what would've caused this to previously work and then suddenly stop working after editing the code above these lines? Or should it never have worked in the first place? $\endgroup$
    – Mjoseph
    Commented Mar 8 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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