18
$\begingroup$

Try to solve the following ODE via DSolve

$$ \left\{\begin{aligned} y'(x)+2 y(x) e^x-y(x)^2 &= e^{2 x}+e^x \\ y'(0) &=1 \end{aligned}\right. $$

The expected solution is $y(x)=e^x$, but Mathematica produces the message:

DSolve::bvfail: For some branches of the general solution, the given boundary conditions lead to an empty solution

Note: $y(x)=e^x$ is obviously a special solution to the original ODE and satisfies the initial/boundary value condition which can be easily verified by substituting it into the ODE.

Additionally, it is easy to deduct that: $y'(0)=1\Leftrightarrow y(0)=1$ for this ODE;

How to handle it?

$\endgroup$
3
  • 1
    $\begingroup$ I see no reason to worry. There is no problem in letting the constant of Integration C[1] go to infinity. Infinity is just one point in the complex plane. Then the general solution collapses into the "expected" simple exponential. $\endgroup$ Commented Mar 8, 2016 at 11:55
  • 1
    $\begingroup$ The command of Maple 2018 dsolve({diff(y(x), x)+2*y(x)*exp(x)-y(x)^2 = exp(2*x)+exp(x), (D(y))(0) = 1}, y(x)) performs y(x) = exp(x). $\endgroup$
    – user64494
    Commented Jul 22, 2022 at 21:59
  • $\begingroup$ this differential equation is artificial or it comes from some modelling problem? $\endgroup$
    – Black Mild
    Commented Jul 25, 2022 at 7:25

5 Answers 5

21
$\begingroup$

The problem - Genericity of solutions

The problem we encounter here is that DSolve can return only a generic solution however that general solution cannot satisfy such an initial condition as y'[0] == 1. The issue is related to an arbitrary choice of constants of integration i.e. such constants that are specific to certain types of a differential equations DSolve tries to solve during the integration process.

DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x, y'[0] == 1}, y[x], x]
DSolve::bvnul: For some branches of the general solution, the given boundary conditions 
 lead to an empty solution. >>

{}

Solving the ODE without the initial condition we will see that the general solution excludes exceptional ones:

y[x_, c_] = y[x] /. First @ DSolve[{ y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x},
                                    y[x], x] /. C[1] -> c
 E^x + 1/(c - x)

Namely there is no constant c reducing the general solution to E^x however putting e.g. y'[0] == 2 we will find a solution:

DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x, y'[0] == 2}, y[x], x]// First
 {y[x] -> (-1 - E^x + E^x x)/(-1 + x)}

This is quite similar issue to one we can find here: Solving a differential equation with initial conditions.

The problem cannot be fixed changing the variables in the ODE to :

y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x /. 
{y[x] -> z[x] + E^x, y'[x] -> z'[x] + E^x} // Simplify
z[x]^2 == z'[x]
DSolve[{z'[x] == z[x]^2, z'[0] == 0}, z[x], x]
DSolve::bvnul: For some branches of the general solution, the given boundary conditions 
lead to an empty solution. >>

{}

Remedy

Introducing an initial condition in a general symbolic way we can find also the special solution:

f[x_, c_] = z[x] /. DSolve[{z'[x] == z[x]^2, z'[0] == c}, z[x], x]
 { -(Sqrt[c]/(-1 + Sqrt[c] x)), -(Sqrt[c]/(1 + Sqrt[c] x))}
f[x, c] /. Solve[D[f[x, c] == 0], c]
{ 0, 0}

I.e. we get the special solution y[x] == E^x.

we can see that the same trick can work also in the original equation.

Alternatively the general solution can be reparametrized in a different way:

E^x + c/(1 - x)

yields also the special solution although this excludes e.g. E^x - 1/x

$\endgroup$
4
  • $\begingroup$ Can we know how the DSolve works? Is the general solution, $y(x)=e^x+\dfrac{1}{c-x}$, correct? Since $y(x)=e^x$ is obviously a special solution to the ODE, which can be easily verified. $\endgroup$ Commented Aug 22, 2014 at 10:50
  • 1
    $\begingroup$ I mean since $y(x)=e^x$ is a special solution to the ODE, then the ODE with initial condition is not incompatible and the current solving approach DSolve uses may be inappropriate. $\endgroup$ Commented Aug 22, 2014 at 10:56
  • 4
    $\begingroup$ You get the special solution $e^x$ by taking the limit $c \rightarrow \infty$ of the general solution $e^x+\frac{1}{c-x}$. $\endgroup$ Commented Aug 22, 2014 at 13:10
  • $\begingroup$ @StephenLuttrell This is a useful observation however the problem that DSolve yields generic solutions remains. $\endgroup$
    – Artes
    Commented Aug 22, 2014 at 13:14
9
$\begingroup$

In V13.1, the new DSolve option IncludeSingularSolutions -> True yields the sought-after solution:

DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x, y'[0] == 1}, 
 y[x], x, IncludeSingularSolutions -> True]

DSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution.

DSolve::bvnr: For some branches of the general solution, the given boundary conditions do not restrict the existing freedom in the general solution.

(*  {{y[x] -> E^x}}  *)
$\endgroup$
2
  • 2
    $\begingroup$ Nice! And you mean V13.1. $\endgroup$
    – Greg Hurst
    Commented Jul 22, 2022 at 12:31
  • $\begingroup$ @GregHurst Thanks, I thought I did, but when I checked the documentation for DSolve, the last update indicated is V13.0 and no "show changes" button. So I thought I was probably wrong. In my uncertainty, I wrote V13 and left off the minor number. (Actually, randomly checking "updated" commands in "Summary of New Features in 13.1," I see that DSolve is not alone in having mixed messages.) $\endgroup$
    – Michael E2
    Commented Jul 22, 2022 at 13:35
5
$\begingroup$

Quite often a differential equation may be viewed as an algebraic problem. In such a view, the integration constant C[1] might naturally be viewed as an element of the projective line. But in the natural Mathematica point of view, the constant is taken to belong to an affine subspace, namely the real number line. One could approach finding a solution by taking C[1] to belong to the projective space, via C[1] -> a/b, or by taking it to belong to a different affine subspace, say via C[1] -> 1/C[1].

In both approaches below, we solve the general differential equation, remap C[1], and solve the boundary condition for C[1].

Here is an approach via the projective line, replacing C[1] by the ratio a/b. A potential pitfall here is that a and b are defined only up to a constant of proportionality, but it turns out Solve can handle it in this case.

ysol = First @ DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x}, y[x], x] /.
  C[1] -> a/b // Simplify
Solve[D[y[x] /. ysol, x] == 1 /. x -> 0, {a, b}]
ysol /. First[%]

(*
  {y[x] -> E^x + b/(a - b x)}

  Solve::svars: Equations may not give solutions for all "solve" variables. >>
  {{b -> 0}}

  {y[x] -> E^x}
*)

A better way perhaps is to take a different affine subspace by moving some finite point to infinity. The replacement C[1] -> 1/C[1] moves 0 to infinity (so we lose the solution where the original C[1] == 0). In this formulation there is just one constant to solve for, and at least in this case Solve gets the multiplicity right.

ysol = First @ DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x}, y[x], x] /.
  C[1] -> 1/C[1] // Together
Solve[D[y[x] /. ysol, x] == 1 /. x -> 0, C[1]]
ysol /. First[%]

(*
  {y[x] -> (-E^x - C[1] + E^x x C[1])/(-1 + x C[1])}

  {{C[1] -> 0}, {C[1] -> 0}}

  {y[x] -> E^x}
*)

Update -- General solution comprising all solutions

If we take an even less familiar route and move a non-real, complex number, such as I, to infinity, we can get the solution(s) for all valid initial (real) values for y'[x], which must be at least 1.

ysol = First@ DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x}, y[x], x] /.
  C[1] -> 1/(C[1] - I) // Together;
Csol = Solve[D[y[x] /. ysol, x] == c /. x -> 0, C[1]];
gensol = {y -> Function @@ #} & /@ Thread[{x, y[x] /. ysol /. Csol // Simplify}]

{y[0], y'[0]} /. gensol // Simplify               (* initial values *)

y[x] /. gensol /. c -> 1                          (* OP's desired solution *)

(*
  {{y -> Function[x, (-Sqrt[-1 + c] + E^x (1 + Sqrt[-1 + c] x))/(1 + Sqrt[-1 + c] x)]},
   {y -> Function[x, (Sqrt[-1 + c] + E^x - Sqrt[-1 + c] E^x x)/(1 - Sqrt[-1 + c] x)]}}

  {{1 - Sqrt[-1 + c], c}, {1 + Sqrt[-1 + c], c}}  (* initial values *)

  {E^x, E^x}                                      (* OP's desired solution *)
*)

Generically, there are two distinct solutions for each initial value for y'[0], but they coincide for y'[0] == 1.

$\endgroup$
4
$\begingroup$

An extended comment that is too long for the comment section.

Amplifying on the comment by Stephen Luttrell:

eqn = y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x;

The generic solution

solnG = DSolve[eqn, y[x], x][[1, 1]]

y[x] -> E^x + 1/(-x + C[1])

Verifying that the generic solution satisfies the equation

eqn /. NestList[D[#, x] &, solnG, 1] // Simplify

True

Obtaining the special solution requested

solnS = (y[x] -> Limit[y[x] /. solnG, C[1] -> Infinity])

y[x] -> E^x

As expected, the special solution satisfies the equation

eqn /. NestList[D[#, x] &, solnS, 1] // Simplify

True

The requested boundary condition is inherent to the special solution

solnS /. x -> 0

y[0] -> 1

$\endgroup$
4
$\begingroup$

Another remedy is to take the limit as y'[0] -> 1:

sol = DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x, y'[0] == a}, y[x], x];

Limit[y[x] /. sol, a -> 1]

(* {E^x, E^x} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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