Consider the following equation $$ y''(x) = -2e^{-y}. $$

The following code

DSolve[y''[x] == -2 Exp[-y[x]], y[x], x] //FullSimplify


{{y[x] -> Log[(2 (-1 + Cosh[Sqrt[C[1]] (x + C[2])]))/C[1]]}, 
 {y[x] -> Log[(2 (-1 + Cosh[Sqrt[C[1]] (x + C[2])]))/C[1]]}}

(They the same solution. Let's ignore that first.) If I impose an initial condition $y(0) = 0$ then Mathematica fails to return a solution

DSolve[{y''[x] == -2 Exp[-y[x]], y[0] == 0}, y[x], x]

with the error message

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

But a solution does exist. One can choose $C[1] = 1$ and $C[2] = \cosh^{-1}(3/2)$ in the solution and verify that $y(0) = 0$.

Any idea why is this the case?

  • $\begingroup$ So you're mainly interested in the reason why bvfail pops up, rather than a workaround, right? $\endgroup$
    – xzczd
    Feb 3, 2019 at 4:16
  • 2
    $\begingroup$ Basically, you are asking why DSolve behaves as it does, and only Wolfram, Inc. can answer that. Suffice it to say that DSolve fails at solving many seemingly simple ODEs. By the way, it also is strange that the two solutions are identical. $\endgroup$
    – bbgodfrey
    Feb 3, 2019 at 4:54
  • 1
    $\begingroup$ @bbgodfrey Actually v9.0.1 only gives one solution for the first code piece. The warning is the same though. $\endgroup$
    – xzczd
    Feb 3, 2019 at 5:57
  • $\begingroup$ @xzczd I am also interested into a workaround if it is not human looking at the solution of the general form, doing some calculations and imposing a constraint on C[1] and C[2] $\endgroup$
    – user58955
    Feb 3, 2019 at 7:03
  • $\begingroup$ @xzczd Yes I am mainly interested in why bvfail pops up $\endgroup$
    – user58955
    Feb 3, 2019 at 7:04

2 Answers 2


If you differentiate the ode you get y'''[x]==-y'[x] Exp[-y[x]]==-y'[x] y''[x].

Mathematica can handle this "equivalent" ode and evaluates a unique solution

Y = DSolveValue[{y'''[x] == -y'[x] y''[x],y[0]==0}, y, x]
(*Function[{x}, 2 Log[Cosh[(x Sqrt[C[1]])/Sqrt[2]]]]*)

The solution depends on one parameter C[1]. C[1] is choosen to fullfill the boundary condition

 Y''[0] == 1 (*Y''[0] ==Exp[-0]*)
 (* C[1]==1*) 
 Y/. %
 (*Function[{x}, 2 Log[Cosh[(x Sqrt[1])/Sqrt[2]]]]*)

As you can see no additional boundary condition can be required! This solution has slope Y'[0]==0


I assume because you are under-specifying the conditions, MMa cannot solve for two unknowns with only one equation. Are you sure that your choices of C[1] and C[2] give a unique solution to the problem. There are some instances where MMa can satisfy one condition by solving for one of the constants and leave the other unevaluated, but evidently not in this case. MMa finds a solution if you specify two conditions such as

DSolve[{y''[x] == -2 Exp[-y[x]], y[0] == 0, y'[0] == 0}, y[x], 
  x] // FullSimplify


There are inverse function warnings, but we get a solution.

  • $\begingroup$ it is certainly not unique. I thought Mathematica could output a solution with only one free constant C[1]... I guess I had overestimated DSolve... $\endgroup$
    – user58955
    Feb 3, 2019 at 15:23
  • $\begingroup$ It really is the fact that you can't solve for two unknowns with one equation whether DSolve is trying or not. For this case if you look at your solution with no conditions, you will see that there is no way to make y[0]==0 by assigning only one of the constants. I have seen DSolve do exactly what you are trying to do on other deq's when it made sense. $\endgroup$
    – Bill Watts
    Feb 3, 2019 at 18:42
  • $\begingroup$ y[0]==0 imposes a condition between C[1] and C[2]. I thought DSolve could solve that condition, plug it back into the general solution to kill one of the constants $\endgroup$
    – user58955
    Feb 4, 2019 at 7:04
  • $\begingroup$ That is one big ask, especially since it has no idea which constant you would like to keep. $\endgroup$
    – Bill Watts
    Feb 4, 2019 at 7:33

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.