# Derivation of finite difference schemes for a boundary value problem.

I have had no experience with differential equations before I was presented with this problem on a homework. The equation is:

$-u'' + \beta u' = 0$

$u(0) = 0$

$u(1) = 1$

I have found the general solution to be $u = \frac{-1}{e^\beta - 1} + \frac{e^{\beta x}}{e^{\beta} - 1}$ and am now asked to derive the central, forward, and backward finite difference schemes (I am only worried about understanding central for now though).

Bear with me now, like I said I have not had any experience with differential equations. From my understanding, the central finite difference yields:

$u''(x) \approx \frac{2u(x) - u(x+h) - u(x-h)}{h^2}$

and therefore $-u'' + \beta u' = 0$ becomes:

$\frac{2u(x) - u(x+h) - u(x-h)}{h^2} + \beta u'(x) = 0$

$2u(x) + u(x + h) - u(x - h) = -\beta u'(x)h^2$

Am I on the right track so far? I am not sure what a complete "finite difference scheme" even is, so when should I stop? I have seen examples where the end result is a large matrix equation - is that required to answer this question?

-

It looks like your overall approach is correct. Your second derivative central difference seems to be off by a sign though, the numerator should be $u(x+h)-2u(x)+u(x-h)$, see http://en.wikipedia.org/wiki/Finite_difference .
You still need to expand the first derivative of $u$ as a finite difference. If the problem is asking for first order central differences as well, you would write $u'(x)\approx \frac{u(x+h/2)-u(x-h/2)}{h}$, or most likely for this problem is wanted $u'(x)\approx \frac{u(x+h)-u(x-h)}{2h}$.
Notice that once you write all derivatives out, you get an equation that involves only $u(x)$, $u(x+h)$ and $u(x-h)$. This is effectively your "scheme" or rule for updating your $u$. If say your $u$ is a function of space, then you can write out a matrix equation. Here's how: if you are on the interval $[0,1]$, then you can write down the vector $[u(0),u(h),u(2h),\ldots,u(1-h),u(1)]$. Since your $u$ satisfies a linear equation involving $u(x)$, $u(x+h)$ and $u(x-h)$, you can think of this equation as an appropriate matrix multiplying the aforementioned vector.
There are multiple central difference formulas, but the simplest and most popular one is what Sam said: $u'(x) = (u(x+h)-u(x-h)) / (2h)$. That's the one I would use unless the question specifies otherwise. – Jitse Niesen Apr 30 '12 at 7:29