How to make a change of variable $y=x^2$ in the differential operator $\frac{d^2}{d y^2}$?

I have this differential operator $$\frac{d^2}{d y^2}\qquad (1)$$ I want to make a change of variable $$y=x^2$$ in $$(1)$$ so that I get this differential operator $$\frac{1}{4 x^2} \frac{d^2 }{d x^2}-\frac{1}{4 x^3}\frac{d}{d x} \qquad (2)$$

How can I ask Mathematica to do this?

• May 20 at 18:33
• Do you want the result to be a function you can apply to an expression? May 20 at 18:34
• @MichaelE2 No, I want to apply this operator to a function. May 20 at 20:20
• From a programming point of view, doesn't "apply this operator" mean you want the operator to be function that takes a function as an argument and returns the desired derivative? By "function" do you mean $f$ or an expression like $f(y)$? These are different, both in mathematics and in coding. Please give paradigm of how you want the code to work, in terms of input and output code. TeX/math is confusing. (Btw, don't you mean $f(x^2)$ in (2)?) May 20 at 21:05
• @MichaelE2 I meant exactly what Alexi 's answer says. May 20 at 22:12

Try this:

Clear[f];
D[f[y], {y, 2}] /. f -> (f[#^(1/2)] &) /. y -> x^2 //
Simplify[#, x > 0] & // Expand

(*  -(Derivative[1][f][x]/(4 x^3)) + (f^\[Prime]\[Prime])[x]/(4 x^2)  *)


Have fun!

• Shouldn't the correct answer have f'[x^2] etc.? May 20 at 21:22
• @MichaelE2 No, the result is correct. May 20 at 22:13
• @Phys96 Why does $f(y)$ become $f(x)$, when $y$ is replaced by $x^2$? That seems quite wrong. May 20 at 22:15
• @MichaelE2 I will write in detail later, maybe it is my bad in writing the question, Indeed, here, we apply the change of variable $y=f(x)=x^2$ May 21 at 6:51
• @MichaelE2 I think that formally you are right. Implicitly, f(x) is another function, not equal to f(y). This may later cause errors in calculations. Correctly would be to introduce a different function g(x)=f(x^2) and formulate everything for the latter: D[f[y], {y, 2}] /. f -> (g[#^(1/2)] &) /. y -> x^2. May 21 at 8:47

Here's a counterexample to show that (1) applied to f[y] is not equivalent to (2) applied to f[x] under the substitution y == x^2, as it was stated in the OP in a previous edit and claimed in a comment:

Block[{f = Cos},
{D[f[y], {y, 2}] /. y -> x^2,
1/(4 x^2) D[f[x], {x, 2}] - 1/(4 x^3) D[f[x], x] // Simplify,
1/(4 x^2) D[f[x^2], {x, 2}] - 1/(4 x^3) D[f[x^2], x] // Simplify
} // Simplify]