How can I code and solve the following differential equation in Mathematica:
$$\frac{\mathrm{d}}{\mathrm{d}x}\left(x^2 e^{2ax}\right) \frac{\mathrm{d}y}{\mathrm{d}x} + b x^2 y=0,$$
where $a$ and $b$ are constants?
Clear["Global`*"]
eqn = D[x^2*E^(2*a*x), x]*y'[x] + b*x^2*y[x] == 0
(* b x^2 y[x] + (2 E^(2 a x) x + 2 a E^(2 a x) x^2) y'[x] == 0 *)
Solving for y
as a pure function (facilitates substitution into the original equation)
sol = DSolve[eqn, y, x][[1]]
(* {y -> Function[{x},
E^((b (E^(-2 a x) + 2 E^2 ExpIntegralEi[-2 - 2 a x]))/(4 a^2)) C[1]]} *)
Verifying that the solution satisfies the equation,
eqn /. sol // Simplify
(* True *)
y[x]
is then
y[x] /. sol
(* E^((b (E^(-2 a x) + 2 E^2 ExpIntegralEi[-2 - 2 a x]))/(4 a^2)) C[1] *)
where ExpIntegralEi
is the exponential integral function and C[1]
is an arbitrary constant