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
    For a linear equation, you can always normalize after the fact. – march Oct 23 at 14:27
up vote 8 down vote accepted

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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