DSolve not finding solution I expected

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


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.


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