Numerical Integration


To solve equation 2 numerically we can convert this differential equation into a difference equation.  We only concern ourselves with the value of E at discrete points.


Figure 3

By letting Dx->0, we can approximate E(x) to any required accuracy.

Defining

(32) 

(33) 


Figure 4

The derivative of E at the point halfway between i and i+1 is approximated by

(34) 

However, as we are only concerned about quantities evaluated on the grid points, we can make the following approximation

(35) 

The second derivative at E at the ith point is given by

(36) 

Therefore, we can write equation 2 in the form

(37) 

Solving for Ei+1

(38) 

If we know the value of Ei-1 and Ei then we can evaluate E at any subsequent point, provided Dx gives convergence.  Alternatively one can use E and E' at any point and then make use of Euler's approximation

(39) 

If we have a symmetric form of n(x) then we can use

(40) 

(41) 
It is then necessary to try different values of b until E->0 as x->.

If n(x) is not symmetric and stays finite then one can pick E0=1 arbitrarily and then one must vary E1 and b.  This can be very computationally expensive.