Differentiate w.r.t. squared variable
Temporarily replace x^2
by y
and then revert the change:
D[x^4 + 2 x^2 + 6 /. x -> Sqrt[y], y] /. y -> x^2
(* 2 + 2 x^2 *)
For the general case, furthermore use Simplify
to replace Sqrt[x^2]
in the final result by x
:
Simplify[D[x^3 /. x -> Sqrt[y], y] /. y -> x^2, Assumptions -> x > 0]
(* (3 x)/2 *)
From @swish's comment (but using Dt
):
myD[f_,x_]:=FullSimplify[Dt[f]/Dt[x]]
myD[x^3, x^2]
(* (3 x)/2 *)
myD[x^4 + 2 x^2 + 6, x^2]
(* 2 (1 + x^2) *)
If you need to specify constants, I would recommend the following:
myD[f_, x_, cons : OptionsPattern[Dt]] :=
FullSimplify[Dt[f, cons]/Dt[x, cons] ]
myD[1/Sqrt[x^2 y^4 + m^4], y^3, Constants -> {x, m}]
(* -((2 x^2 y)/(3 (m^4 + x^2 y^4)^(3/2))) *)