Using NDSolve in Mathematica

We can solve equation 2 numerically using Mathematica is we have two boundary conditions.

First of all define n(x) and k, e.g.

We wish to be able to solve equation 2 for different values of b, define the following function

noting that we are solving equation 2 over the domain (0,1) and that we are setting the boundary conditions of E(x=0)=0 and E'(x=0)=1.  These can be changed in the function to whatever is required for the problem.

If we also apply the boundary that E(x=1)=0 then by plotting E(x=l) for a range of values of b, then when we see the plot cross the x-axis we will have a propagation constant.


Figure 2

Once we have the values of the propagation constant we can use NDSolve again to obtain an interpolation function for E(x) over the region examined.