# Three Methods to Solve a Differential Equation With Boundary Conditions

Why do you have a differential equation? It happens quite a bit in physics — so let’s just get to it. Suppose I have a differential equation that looks like this:

Let’s also say that we have the following boundary conditions on the function f:

Yes, I know this isn’t a very exciting differential equation — but I wanted one that was easy to solve. We can do more complicated ones later — and by “we”, I mean “you”.

**Analytical Solution**

It’s possible to get an analytical solution for this differential equation. Since the second derivative is just equal to a function of x, I can integrate (anti-derivative) twice and find an expression for f. Here is what that looks like after the first anti-derivative.

I just used the power rule to take the anti-derivative. Since I don’t have limits of the integration, there is some constant in there — I call that constant, C. Now I can take the anti-derivative again to get the following:

I picked up another constant — I call this one B. I can find the values for both C and B by using the boundary conditions. Let’s look at the function with x = 0.

The only way to satisfy this boundary condition is if B = 0. Now for the other boundary: