Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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?

share|improve this question
Sixth question and you still haven't noticed there are code formatting guidelines ? .. – Sektor Apr 6 '14 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 '14 at 21:25
here – Sektor Apr 6 '14 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 '14 at 21:31
@Lawerance Regarding the formatting, "Markdown" is the name/keyword you would like to feed to search engine. – Silvia Aug 18 '14 at 14:15
up vote 7 down vote accepted

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.

  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}}] }]

enter image description here

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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.