# How can I check that the general solution obeys the original differential equation?

For example: I solved the following differential equation:

y''[x] == (λ x^(3/4) y[x])/Sqrt[1-x]


that 0<x<1 with the following method:

sol = DSolve[z''[x] == λ*x^(3/4)* z[x]/Sqrt[x], z[x], x]
y[x_] = z[x] /. sol[[1]] /. x -> x - 1


and obtained this general solution:

(2/3)^(8/9) Sqrt[-1 + x] λ^(2/9)
BesselI[-(4/9), 8/9 (-1 + x)^(9/8) Sqrt[λ]] C[1] Gamma[5/
9] + (-1)^(4/9) (2/3)^(8/9) Sqrt[-1 + x] λ^(2/9)
BesselI[4/9, 8/9 (-1 + x)^(9/8) Sqrt[λ]] C[2] Gamma[13/9]


How can I check that the general solution obeys the original differential equation ?

• After doing sol = DSolve[z''[x] == λ*x^(3/4)* z[x]/Sqrt[x], z, x][[1]] (note the second argument!), try y''[x] == (λ x^(3/4) y[x])/Sqrt[1-x] /. y -> z[# - 1] & /. sol. Jun 19, 2015 at 10:54

You can check that a differential equation is solved correctly by plugging it in to the original equation and seeing that it holds. For your case:

sol = DSolve[z''[x] == λ*x^(3/4)*z[x]/Sqrt[x], z[x], x]
f[x_] := sol[[1, 1, 2]]


so f[x] is the candidate function. Now verify that:

FullSimplify[D[f[x], {x, 2}]] == FullSimplify[λ*x^(3/4)*f[x]/Sqrt[x]]


Since this returns True, you know you have the right answer.

• I don't know that my method is true. Jun 19, 2015 at 11:15
• This ODE says: there is a function whose 2cnd derivative is equal to the right hand side. Call it f[x]. The verification line takes the second derivative of this f[x] and shows that it is the same as the right-hand side. Hence it is an answer to the ODE. Jun 19, 2015 at 11:19
• What is sol[[1, 1, 2]] in your answerd? Jun 19, 2015 at 12:35
• It's the 1,2,1 part of the variable sol, which is assigned as the calculated solution to the ODE. After running the code above, type f[x] to see it displayed. It is what you called the "general solution" in your question. Jun 19, 2015 at 13:26

In this example, the solution is verified by substitution.

equation = y''[x]-x*y[x]-x == 0;
sol = DSolve[equation, y, x]
FullSimplify[equation /. sol]


{ True }

You can also check numerically. An example, we have a differential equation:

$$y''(x)-x y(x)-x=0$$

General solution is:

$$\left\{y(x)\to c_1 \text{Ai}(x)+c_2 \text{Bi}(x)-\pi \text{Ai}(x) \text{Bi}'(x)+\pi \text{Ai}'(x) \text{Bi}(x)\right\}$$

On the right side of the differential equation we have zero , so:

 sol = First@DSolve[y''[x] - x*y[x] - x == 0, y[x], x]
Y = y[x] /. sol;
DE = D[Y, {x, 2}] - x*Y - x;
N@Table[DE /. {C[1] -> a, C[2] -> b, x -> c},
{a, 1, 3}, {b, 1, 3}, {c, 1, 3}] // MatrixForm


Almost here are zeros.Check OK.

• What you have is not Euler's beta function, but the incomplete beta function. Jun 26, 2015 at 15:40