# Solving differential equation with initial conditions

I want to solve the following differential equation with initial conditions:

ode = (λ x y[x])/Sqrt[1 - x] + y''[x] == 0
ic = {y[1] == 0, y'[1] == 1}
DSolve[{ode, ic}, y[x], x]


But do not know how to actually solve it. Any suggestion?

• I don't think Mathematica can find a solution to this problem. Are you sure you've stated it correctly? Please use accepted Mathematica syntax... terms using useless parentheses and asterisks (for multiplication) are quite awkward. Also, use y''[x] to be consistent with your other derivatives. Moreover, your list of arguments for DSolve should not have a sublist of initial conditions... just entries. (See the documentation.) Apr 30, 2015 at 15:38
• @ David-G.-Stork there is nothing wrong with (x)  here, just additional parentheses, but correct syntax. You are right with the sublist. I think that's the problem here! Apr 30, 2015 at 15:42

METHOD 1

The easiest and fast way only numerically.

sol = First@
With[{λ = 1},
NDSolve[{z''[x] + (λ*x)/Sqrt[1 - x]*z[x] == 0,
z[999/1000] == 0, z'[999/1000] == 1}, z, {x, -2, 2}]];


METHOD 2

Use by Series.

n = 6;
y = Sum[c[i]*x^i, {i, 0, n}] + O[x]^(n + 1);
ODE = D[y, {x, 2}] + (λ*x)/Sqrt[1 - x]*y == 0;
Y = Normal[y /. Solve[LogicalExpand[ODE], Table[c[i], {i, 1, n}]]] //
Quiet;
Sol2 = Simplify@
First[Y /.
Solve[{Y == 0 /. x -> 1, D[Y, x] == 1 /. x -> 1}, {c[0], c[1]}]];
Plot[{z[x] /. sol, Sol2 /. λ -> 1}, {x, -2, 2},
PlotLegends -> {"NDSolve", "Series"},
PlotStyle -> {Thin, {Thick, Dashed}}] // Quiet


Other way.

sol=First@With[{λ = 1},
NDSolve[{z''[x] + (λ*x)/Sqrt[1 - x]*z[x] == 0,
z[999/1000] == 0, z'[999/1000] == 1}, z, {x, -2, 2}]]; data =
Table[{x, z[x] /. sol}, {x, -2, 2, 0.01}];
k = 5; Sol = Fit[data, Table[x^n, {n, 0, k}], x]

Plot[{z[x] /. sol, Re@Sol}, {x, -2, 2},
PlotLegends -> {"NDSolve", "FitData"},
PlotStyle -> {Thin, {Thick, Dashed}}]


METHOD 3

Analytically. $$y''(x)+A(x) y(x)=0 \tag{1}$$,were A(x) is:$$A(x)=\frac{\lambda x}{\sqrt{1-x}} \tag{2}$$ In order to find general solution of Eq.(1) let us introduce new variable: $$y'=y*z \tag{3}$$ derivative of Eq.(3) $$y''=y'*z+y*z' \tag{4}$$ and substitution from Eq.(3) to Eq.(4) and we have: $$y''=y*z^2+y*z' \tag{5}$$ and substitution from Eq.(5) to Eq.(1) and we have Riccati equation first order and with quadratic nonlinearity: $$z'(x)+z(x)^2+A (x)=0 \tag{6}$$ DSolve can't find solution!!! of this Riccati equation.

As David-G.-Stork mentioned, the first argument of DSolve needs to be a flat list.

Try to give equations and initial conditions in one list like this:

eqs = {(λ  x y[x])/Sqrt[1 - x] + y'[x] == 0, y[1] == 0, y'[1] == 1}
DSolve[eqs, y[x], x]


Still not sure if Mathematica can solf this, but now it's at least syntactically correct.

• The first argument does not need to be a flat list. Consider DSolve[{y''[x] == y[x], {y[0] == 1, y'[0] == 0}}, y, x].... Apr 30, 2015 at 18:11
• This is a first order equation and you provide 2 conditions so it only has solutions for specific values of lambda? Aug 8, 2015 at 17:27