5

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?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257

1 Answers1

8

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 -> 
   Function[{x}, 
     (E^(-Sqrt[a] x) (E^(2 Sqrt[a] L) + E^(2 Sqrt[a] x)) C[1])/(1 + E^(2 Sqrt[a] L))], 
 Y -> 
   Function[{x}, 
    (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)))]}
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55