Centered Differences and Discretization I am given the boundary value problem:
$$-u''+\frac{1}{\epsilon}(u^{2}-1)u=0, \,\,\,\,\,\, x\in[-1,1]$$
where $u(-1)=-1$, $u(1)=1$, and $\epsilon$ is a known parameter.
I need to approximate the second derivative using centered differences and then write a discretization of the equation. I don't understand what a discretization is and I'm a little unclear on centered differences. Can someone walk me through this problem?
 A: The idea of discretization is to formulate an 'infinite dimensional'/'continuous' problem as a 'finite dimensional'/'discrete' one. In particular, instead of solving for a function $u:[-1,1] \to \mathbb R$, with a value at every real number in the whole interval $[-1,1]$, we try to solve for the values at discrete points $x_n\in[-1,1]$.
For example, we might take $x_n = -1 + 2n/N$ for $n=0,\cdots,N$ to be $N+1$ equally spaced points in this interval. Then we can let $u_n \approx u(x_n)$ be the function we want to solve for at each of these points. The boundary conditions, for example, are simply $u_0=-1,u_N=1$. Notice that the spacing $\delta=x_{n+1}-x_n=2/N$.
Now we want to approximate the equation for the continuous function $u(x)$ so that it is an approximate relation for the $u_n$. We can apply the equation at a particular point $x_n$, where we find $$-u''(x_n)+F(u_n)=0$$where $F(v)=(v^2-1)v/\epsilon$ - the last bit is easy; the tricky bit is the derivative. This only really exists in the continuous case.

The idea is rooted in the definition of a derivative, or equivalently of Taylor series. For example,
$$f'(x)\approx (f(x+\delta)-f(x))/\delta$$
for small $\delta$.
Using this relationship a couple of times, you can easily show that
$$f''(x) \approx \frac{f(x+\delta)-2f(x)+f(x-\delta)}{\delta^2}$$
Why? Check the Taylor series; $$f(x\pm\delta)=f(x)\pm \delta f'(x) + \frac{1}{2}\delta^2 f''(x)+\cdots$$
Therefore,
$$u''(x_n)\approx\frac{u_{n+1}-2u_n+u_{n-1}}{(2/N)^2}$$
Substituting this in gives an equation involving just the $u_n$, which can be applied for each $n=1,\cdots,N-1$ along with the above boundary conditions; done! The solution is therefore

$u_n\approx u(x_n)$, $x_n=-1+2n/N$, $u_0=-1,u_N=+1$, $$-\frac{u_{n+1}-\cdots}{4/N^2} + \frac{1}{\epsilon}(u_n^2-1)u_n=0\qquad \text{ for }n=1,\cdots,N-1$$


This could then be considered as a recurrence relation analytically, or more typically as a matrix equation for the vector $\mathbf u = (u_0,\cdots,u_n)$ for numerical computations.
