I want to use DSolve to solve a differential equation while imposing a boundary condition and normalization.

How can I do that?

Let's take for example a simple heat-equation: $y''[x]=a y[x]$. Easy to solve:

DSolve[y''[x] == a y[x], y[x], x]

I can also impose a no-flux condition at position L, $\nabla \rho|_L=0$

DSolve[{y''[x] == a y[x], y'[L] == 0}, y[x], x]

but I cannot (or don't know how to) impose a normalization condition, $\int_0^L\rho(x)dx=1$

DSolve[{y''[x] == a y[x], y'[L] == 0, Integrate[y[x], {x, 0, L}] == 1},

When I evaluate the above expression, I obtain the following error:

There are fewer dependent variables than equations, so the system is overdetermined"

But that is something I can do by hand. What is the problem? Is it a bug or am I misunderstanding something?

  • 1
    $\begingroup$ For a linear equation, you can always normalize after the fact. $\endgroup$
    – march
    Commented Oct 23, 2018 at 14:27

1 Answer 1


You can solve your problem by introducing a second ode (defining the antiderivative):

sol = 
  DSolve[{y''[x] == a y[x], Y'[x] == y[x], y'[L] == 0, Y[L] == 1}, {y, Y}, x][[1]]

{y -> 
     (E^(-Sqrt[a] x) (E^(2 Sqrt[a] L) + E^(2 Sqrt[a] x)) C[1])/(1 + E^(2 Sqrt[a] L))], 
 Y -> 
    (E^(-Sqrt[a] x) 
      (Sqrt[a] E^(Sqrt[a] x) +Sqrt[a] E^(2 Sqrt[a] L + Sqrt[a] x) - 
         E^(2 Sqrt[a] L) C[1] + E^(2 Sqrt[a] x) C[1])) /
      (Sqrt[a] (1 + E^(2 Sqrt[a] L)))]}

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.