# DSolve cannot solve for certain branches of the solution

Could somebody please tell me, why I am always getting an error message when trying to run the following code:

DSolve[y'[x] == c*(d - y[x]) - b*(d - y[x])*y[x] && y[0] == y0, y, x]


The error message:

DSolve::bvfail: For some branches of the general solution, unable to solve the
conditions.

-

I can offer a small workaround. Your problem is equvalent to

sol=FullSimplify[DSolve[{y'[x] == A0 + A1 y[x] + A2 y[x]^2, y[0] == y0}, y[x], x]]


By expanding and comparing with your variables:

y'[x] == c d - (c + b d) y[x] + b y[x]^2
y'[x] == A0 + A1 y[x] + A2 y[x]^2


We can get your formulation by the substitution:

PowerExpand[FullSimplify[sol /. {A0 -> c d, A1 -> -(c + b d) , A2 -> b}]]


You can check now by direct substitution that this is indeed solution to your differential equation.

==== Edit: answering "why does not work?" question ===

I can try to guess the trouble of your formulation - I think it is in your choice of parameters. As Sjoerd C. de Vries in his answer noticed a general solution leads to

DSolve[y'[x] == c*(d - y[x]) - b*(d - y[x])*y[x], y, x]


Now Solve cannot "solve" your initial value problem:

Using Reduce you can arrive to a complex conditions set for the solution:

Which looks glorious ;-) but not simple. With a bit different formulation above (via A0, A1, A2) you do not run into this problem - Solve can handle easily your initial condition. This is rather a rare case - you were lucky to hit exactly problematic choice of parameters. This was some quick thinking - it's subject to verification.

-
Thank you very much for your great idea! I will use this workaround, but do you by any chance have any idea why I get the error message? I did forget to mention that if I take a piece of paper and a pencil, I get the solution of the equation within 3 minutes. –  Rieux May 6 '12 at 21:43
Thank you very much for the quick reply –  Rieux May 7 '12 at 0:37

The equation doesn't have a solution for arbitrary values of y0. Let's see what happens if we leave away the boundary condition:

sol = DSolve[{y'[x] == c*(d - y[x]) - b*(d - y[x])*y[x]}, y, x][[1, 1]]

(* ==>
y ->  Function[{x}, (d E^(c x + c C[1]) +
c E^(b d x + b d C[1]))/(E^(c x + c C[1]) +
b E^(b d x + b d C[1]))
]
*)

y[0] /. sol


(* ==> (d E^(c C[1]) + c E^(b d C[1]))/(E^(c C[1]) + b E^(b d C[1])) *)


so only for these specific values of y0 do you get a solution. Let's try it for C[1]=1:

DSolve[{y'[x] == c*(d - y[x]) - b*(d - y[x])*y[x],
y[0] == (d E^c  + c E^(b d ))/(E^c  + b E^(b d ))}, y,
x] // FullSimplify

Solve::ifun :  "Inverse functions are being used by Solve,
so some solutions may not be found; use Reduce for
complete solution information.>>"

(*
==> {{y ->
Function[{x}, (
d E^(c x + (c (-b d + Log[E^c]))/(c - b d)) +
c E^(b d x + (b d (-b d + Log[E^c]))/(c - b d)))/(
E^(c x + (c (-b d + Log[E^c]))/(c - b d)) +
b E^(b d x + (b d (-b d + Log[E^c]))/(c - b d)))]}}
*)


So, indeed you get a solution now.

-
Hi dear Sjoerd! Thank you very much for the explanation, it would have never occured to me to spare the boundary condition. However, looking at it a bit closer came the next question, which was that the solution was a continuous function of C[1], so I could not see why Mathematica still had problems with finding the right one. Then I realized, that unfortunately it was a bounded function of C[1]. Now I understand what caused the problem, but still I would ask sg else, namely I cannot understand what Mathematica needs Inverse Functions even with correct parameters for. –  Rieux May 6 '12 at 23:58
Because however I am not entirely sure I still suppose that the solution is an injective function of C[1] for any given x value, so after finding a suitable C[1] there is not supposed to be any lost solution. Or does this notification of inverse functions refer to sg else? –  Rieux May 7 '12 at 6:59
@Rieux You might want to read this piece of MMA help text about branch cuts –  Sjoerd C. de Vries May 7 '12 at 10:46
Thank you for the link! –  Rieux May 7 '12 at 12:51