# How to apply chain rule to a differential equation

There is a simple differential equation $$y''(x) + (\varepsilon - x^2) y(x) = 0$$. If one uses the new variable $$x^2 = s$$, using the chain rule, this differential equation becomes $$4 s y''(s) + 2 y'(s) + (\varepsilon - s) y(s) = 0$$. Now, I want to do it in Mathematica. I define the differential equatrion as

diff[x_] := y''[x] + (ε - x^2) y[x];

Simplify[diff[x] /. x^2 -> s]


But, it does not work. How can I figure it out?

deq = y''[x] + (epsilon - x^2) y[x];

deq /. {y -> (y[#^2] &)} /. x -> Sqrt[s]
(*(epsilon - s) y[s] + 4 s y''[s] + 2 y'[s]*)


Another option is to use the package MoreCalculus by Kuba

<< MoreCalculus
diff[x_] := y''[x] + (epsilon - x^2) y[x] == 0;
DChange[diff[x], {x^2 == s}, {x}, {s}, y[x]]


$$\epsilon y(s)+4 s y''(s)+2 y'(s)=s y(s)$$

• Worth mentioning that DChange` is the only function contained in that package at the moment. – probably_someone Feb 25 '20 at 21:19