# Using DSolve to find y[x] for a second-order differential equation

Excuse me can you help me on solving the following differential equation by Mathematica ?!

$$d^2y[x]/dx^2-(1/(x+a))*dy[x]/dx+(m*x+L)y[x]=0$$

i had try on it as following :

ode=D[y[x],{x,2}]-1/(x+a)*D[y[x],x]+(m*x+L)*y[x]==0
DSolve[ode,y[x],x]


it gives me strange output :

{{y[x] -> DifferentialRoot[Function[{\[FormalY], \[FormalX]},
{(\[FormalX] + a)*(L + \[FormalX]*m)*\[FormalY][\[FormalX]] -
Derivative[1][\[FormalY]][\[FormalX]] +
(\[FormalX] + a)*Derivative[2][\[FormalY]][
\[FormalX]] == 0, \[FormalY][0] == C[1],
Derivative[1][\[FormalY]][0] == C[2]}]][x]}}

• Related: (65169), (81375) – Michael E2 Jan 10 at 18:07
• Have you looked up DifferentialRoot in the documentation? It usually means DSolve could not put the solution in terms of elementary functions or standard special functions. – Michael E2 Jan 10 at 18:11
• yes , i saw it ,,, but i need another way to solve this equation ?? how can i solve it ??? what command should i use? – Aya Jan 10 at 18:22

Clear["Global*"]


Use a numeric technique.

First, include some arbitrary initial conditions.

ode = {D[y[x], {x, 2}] - 1/(x + a)*D[y[x], x] + (m*x + L)*y[x] == 0,
y[0] == y0, y'[0] == yp0};

sol = ParametricNDSolve[ode, y, {x, -5, 5}, {m, a, L, y0, yp0}];

Manipulate[
Plot[y[m, a, L, y0, yp0][x] /. sol, {x, -5, 5}],
{{m, 1}, -5, 5, 0.1, Appearance -> "Labeled"},
{{a, 1}, -5, 5, 0.1, Appearance -> "Labeled"},
{{L, 1}, -5, 5, 0.1, Appearance -> "Labeled"},
{{y0, 0}, -5, 5, 0.1, Appearance -> "Labeled"},
{{yp0, 1}, -5, 5, 0.1, Appearance -> "Labeled"}]


An analytic solution may be available for specific values of the parameters. For example,

ode2 = ode /. {m -> 1, a -> 1, L -> 1, y0 -> 0, yp0 -> 1}

(* {(1 + x) y[x] - Derivative[1][y][x]/(1 + x) + (y^\[Prime]\[Prime])[x] == 0,
y[0] == 0, Derivative[1][y][0] == 1} *)

sol2 = DSolve[ode2, y, x][[1]]

(* {y -> Function[{x}, -(((-1)^(
1/3) (AiryAiPrime[(-1)^(1/3) + (-1)^(1/3) x] AiryBiPrime[(-1)^(1/3)] -
AiryAiPrime[(-1)^(
1/3)] AiryBiPrime[(-1)^(
1/3) + (-1)^(1/3) x]))/(-AiryAiPrime[(-1)^(1/3)] AiryBi[(-1)^(
1/3)] + AiryAi[(-1)^(1/3)] AiryBiPrime[(-1)^(1/3)]))]} *)


Verifying the solution

ode2 /. sol2 // Simplify

(* {True, True, True} *)

Plot[y[x] /. sol2, {x, -5, 5},
PlotPoints -> 50, MaxRecursion -> 5,
WorkingPrecision -> 20]


• Many thanks , but you mean that this differential equation does not have solution except when m=1,L=1,a=1<y0=0 and yp0=1 ??? – Aya Jan 10 at 19:11
• No, I said that analytic solutions may be available and that {m -> 1, a -> 1, L -> 1, y0 -> 0, yp0 -> 1} is an example. There may be other cases with an analytic solution. There are numerous case with a numeric solution as shown in the Manipulate. – Bob Hanlon Jan 10 at 19:51
• yes i saw this , but i need a general solution ,, How can i get it please ? – Aya Jan 10 at 20:03
• If Mathematica gives you a DifferentialRoot` solution, it means it couldn't find anything better and that a general analytic solution in all likelihood doesn't exist. – Sjoerd Smit Jan 10 at 20:07