# Solving a differential equation with initial conditions

I want to get a solution to an ordinary differential equation with imposed initial conditions. I'm confused about why my following code doesn't work:

Remove["Global*"]

eqn = {x g - x v[x] v'[x] - v[x]^2 == 0};
inicond = {v[0] == 0, v'[0] == 0};
eqnlist = Join[eqn, inicond];

DSolve[eqnlist, v[x], x]

{}


Can anyone help me?

-
Sixth question and you still haven't noticed there are code formatting guidelines ? .. –  Sektor Apr 6 at 20:34
@Sektor I know the guidelines, but it seems hard to find the resources to learn the code as you edited. –  Lawerance Apr 6 at 21:25
here –  Sektor Apr 6 at 21:28
@Sektor Do you know what kind of language is this? I am going to find some youtube tutorials of it. –  Lawerance Apr 6 at 21:31

Overdetermined systems of differential equations can have any solutions only if they satisfy certain compatibility conditions, therefore in general one shouldn't expect that any solutions necessarily exist. For differential equations of the first order one can impose initial conditions in the form of values of unknown functions (at certain points for ODEs) but on the other hand for certain initial conditions there are no solutions and this is the case we encounter here.
However we can solve the equation without any initial conditions:

DSolve[{g x - v[x]^2 - x v[x] v'[x] == 0}, v[x], x]

{{v[x] -> -(Sqrt[ 2 g x^3 + 3 C[1]]/(Sqrt[3] x))},
{v[x] -> Sqrt[ 2 g x^3 + 3 C[1]]/(Sqrt[3] x)}}


We can see two families of symbolic solutions which immediately show why we cannot impose the condition for x == 0, e.g. v[0] == 0, nonetheless we can impose e.g. v[1] == c, and now treating c and g as variables determining different solutions we'll take a closer look:

dsol[c_, g_] = v[x] /. DSolve[{g x - v[x]^2 - x v[x] v'[x] == 0, v[1] == c}, v[x], x]

 { -(Sqrt[ 3 c^2 - 2 g + 2 g x^3]/(Sqrt[3] x)),
Sqrt[ 3 c^2 - 2 g + 2 g x^3]/(Sqrt[3] x)}


plotting them by choosing various arguments of c and g, e.g.

GraphicsColumn[
Plot[ #, {x, -4, 4}, Evaluated -> True, PlotStyle -> Thick, ImageSize -> 600,
AspectRatio -> Automatic, PlotLegends -> "Expressions",
PlotRange -> {{-4, 4}, {-4, 4}}] & /@ {
Table[ dsol[1, g],    {g, {-2, 0, 2}}],
Table[ dsol[c, -1/2], {c, {-2, 0, 2}}] }]


We can see that some solutions can be continued in the complex plane after reaching appropriate values e.g. Sqrt[ 13 - x^3]/( Sqrt[3] x) becomes complex when x exceeds 13^(1/3)`.

-