Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

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?

share|improve this question

4 Answers 4

up vote 9 down vote accepted

The problem - Genericity of soutions

The problem we encounter here is that DSolve can return only a general 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 intial 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 tric 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

share|improve this answer
    
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. –  LCFactorization Aug 22 at 10:50
    
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. –  LCFactorization Aug 22 at 10:56
1  
You get the special solution $e^x$ by taking the limit $c \rightarrow \infty$ of the general solution $e^x+\frac{1}{c-x}$. –  Stephen Luttrell Aug 22 at 13:10
    
@StephenLuttrell This is a useful observation however the problem that DSolve yields generic solutions remains. –  Artes Aug 22 at 13:14

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

share|improve this answer

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} *)
share|improve this answer

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}
*)
share|improve this answer

Your Answer

 
discard

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.