HEAD | PREVIOUS |

Two-point Boundary Conditions

$\nabla .\mathit{E}=-{\nabla}^{2}\mathit{\phi}=\mathit{\rho}/{\mathit{\epsilon}}_{0}$ | $(3.1)$ |

Figure 3.1: Electrostatic configuration independent of $y$ and $z$ with
conducting boundaries at ${x}_{1}$ and ${x}_{2}$ where $\mathit{\phi}=0$. This is a
second-order two-point boundary problem.

In a slab geometry where $\mathit{\rho}$ varies
in a single direction (coordinate) $x$, but not in $y$ or $z$, an
ordinary differential equation arises
$\frac{{d}^{2}\mathit{\phi}}{{\mathit{dx}}^{2}}=-\frac{\mathit{\rho}(x)}{{\mathit{\epsilon}}_{0}}.$ | $(3.2)$ |

Figure 3.2: Heat balance equation in cylindrical geometry leads to a
two-point problem with conditions consisting of fixed temperature
at the edge, $r=a$ and zero gradient at the center $r=0$.

A second-order two-point problem also arises from
steady heat conduction. See Fig. 3.2. Suppose a cylindrical reactor
fuel rod experiences volumetric heating from the nuclear reactions
inside it with a power density $p(r)$ (Watts per cubic meter), that
varies with cylindrical radius $r$.
Its boundary, at $r=a$ say, is held at a constant
temperature ${T}_{a}$. If the thermal
conductivity of the
rod is $\mathit{\kappa}(r)$, then the radial heat flux
density (Watts per
square meter) is
$q=-\mathit{\kappa}\frac{dT}{\mathit{dr}}.$ | $(3.3)$ |

$2\mathit{\pi}rq=-2\mathit{\pi}r\mathit{\kappa}(r)\frac{dT}{\mathit{dr}}={\int}_{0}^{r}p(r\text{'})2\mathit{\pi}r\text{'}\mathit{dr}\text{'}.$ | $(3.4)$ |

$\frac{d}{\mathit{dr}}\left(r\mathit{\kappa}\frac{dT}{\mathit{dr}}\right)=-rp(r).$ | $(3.5)$ |

${\frac{dT}{\mathit{dr}}|}_{r=0}=0.$ | $(3.6)$ |

Figure 3.3: Multiple successive shots from a cannon can take advantage of
observations of where the earlier ones hit, in order to iterate the aiming
elevation $s$ until they strike the target.

It's as if we are aiming at the point $({x}_{2},{y}_{2})$ with a cannon
located at $({x}_{1},{y}_{1})$ (see Fig. 3.3). We elevate the
cannon so that the cannonball's initial angle is $\mathit{dy}/\mathit{dx}{|}_{{x}_{1}}=s$,
which is our initial guess at the best aim. We shoot. The cannonball
flies over, (within our metaphor, the initial value solution is found)
but is not at the correct height when it reaches ${x}_{2}$ because our
first guess at the aim was imperfect. What do we
do? We see the height at which the cannonball hits, above or below the
target. We adjust our aim accordingly with a new elevation ${s}_{2}$,
$\mathit{dy}/\mathit{dx}{|}_{{x}_{1}}={s}_{2}$, and shoot again. Then we
iteratively refine our aim taking as many shots as
necessary, and improving the aim each time, till we hit the target.
This is the "shooting" method of solving a two-point problem. The
cannonball's trajectory stands for the initial value integration with
assumed initial condition.
One question that is left open in this description is exactly
Figure 3.4: Bisection successively divides in two an interval in which there
is a root, always retaining the subinterval in which a root
lies.

Now we just iterate the above procedure, as
illustrated in Fig. 3.4. At each step we get an interval
of half the length of the previous step, in which we know a solution
lies. Eventually the interval becomes small enough that its extent can
be ignored; we then know the solution accurately enough, and can stop
the iteration.
The wonderful thing about bisection is that it highly
efficient, because it is guaranteed to converge in
"logarithmic time". If we start with an
interval of length $L$, then at the $k$th interation the interval
length is $L/{2}^{k}$. So if the tolerance with which we
need the $s$-value solution is $\mathit{\delta}$ (generally a small length),
the number of iterations we must take before
convergence is
$N={\mathrm{log}}_{2}(L/\mathit{\delta})$. For
example if $L/\mathit{\delta}={10}^{6}$, then $N=20$. This is a quite modest number
of iterations even for a very high degree of refinement.
There are iterative methods of root finding that converge faster than
bisection for well behaved functions. One is "Newton's
method", which may succinctly be stated as
${s}_{k+1}={s}_{k}-f({s}_{k})/{\mathit{df}/\mathit{ds}|}_{{s}_{k}}$. It converges in a
few steps when the starting guess is not too far
from the solution. Unlike bisection, it does not require two starting
points on opposite sides of the root. However, Newton's method (1)
requires derivatives of the function, which makes it more complicated
to code, (2) is less robust, because it takes big steps near
$\mathit{df}/\mathit{ds}=0$, and may even step in the wrong direction and not converge
at all in some cases. Bisection is guaranteed to converge after a
modest number of steps. Robustness is in practice
usually more important than speed.${}^{16}$
In the context of our shooting solution of a two-point problem, the
function $f$ is the error in the boundary value at the second point
$y({x}_{2})-{y}_{2}$ of the inital-value solution $y(x)$ that takes
initial-value $s$ for its derivative at ${x}_{1}$. The bisection generally
adjusts the initial-value $s$ until $|y({x}_{2})-{y}_{2}|$ is less than some
tolerance (rather than requiring some tolerance on $s$).
${\frac{\mathit{dy}}{\mathit{dx}}|}_{n+1/2}=\frac{\mathit{\Delta}y}{\mathit{\Delta}x}=\frac{{y}_{n+1}-{y}_{n}}{{x}_{n+1}-{x}_{n}};$ | $(3.7)$ |

${\frac{{d}^{2}y}{{\mathit{dx}}^{2}}|}_{n}=\frac{\mathit{\Delta}(\mathit{dy}/\mathit{dx})}{\mathit{\Delta}x}=\frac{({\mathit{dy}/\mathit{dx}|}_{n+1/2}-{\mathit{dy}/\mathit{dx}|}_{n-1/2})}{{x}_{n+1/2}-{x}_{n-1/2}},$ | $(3.8)$ |

Figure 3.5: Discrete second derivative at $n$ is the difference between
the discrete derivatives at $n+\frac{1}{2}$ and $n-\frac{1}{2}$. In a
uniform mesh, it is
divided by the same $\mathit{\Delta}x$.

Because the first derivative is the value at $n+1/2$, the second
derivative (the derivative of the first derivative) is the value at a
point mid way between $n+1/2$ and $n-1/2$, i.e. at $n$. Substituting
from the previous equation (3.7) we
get${}^{17}$:
${\frac{{d}^{2}y}{{\mathit{dx}}^{2}}|}_{n}=\frac{({y}_{n+1}-{y}_{n})/\mathit{\Delta}x-({y}_{n}-{y}_{n-1})/\mathit{\Delta}x}{\mathit{\Delta}x}=\frac{{y}_{n+1}-2{y}_{n}+{y}_{n-1}}{\mathit{\Delta}{x}^{2}}.$ | $(3.9)$ |

$\left(\begin{array}{c}\hfill {{d}^{2}y/{\mathit{dx}}^{2}|}_{1}\hfill \\ \hfill :\hfill \\ \hfill {{d}^{2}y/{\mathit{dx}}^{2}|}_{n}\hfill \\ \hfill :\hfill \\ \hfill {{d}^{2}y/{\mathit{dx}}^{2}|}_{N}\hfill \end{array}\right)=\frac{1}{\mathit{\Delta}{x}^{2}}\left(\begin{array}{ccccc}\hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill \end{array}\right)\left(\begin{array}{c}\hfill {y}_{1}\hfill \\ \hfill :\hfill \\ \hfill {y}_{n}\hfill \\ \hfill :\hfill \\ \hfill {y}_{N}\hfill \end{array}\right),$ | $(3.10)$ |

$\frac{{d}^{2}y}{{\mathit{dx}}^{2}}=g(x)$ | $(3.11)$ |

$\left(\begin{array}{ccccccc}\hfill -2\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill -2\hfill \end{array}\right)\left(\begin{array}{c}\hfill {y}_{1}\hfill \\ \hfill {y}_{2}\hfill \\ \hfill :\hfill \\ \hfill {y}_{n}\hfill \\ \hfill :\hfill \\ \hfill {y}_{N-1}\hfill \\ \hfill {y}_{N}\hfill \end{array}\right)=\left(\begin{array}{c}\hfill -2{y}_{L}\hfill \\ \hfill {g}_{2}\mathit{\Delta}{x}^{2}\hfill \\ \hfill :\hfill \\ \hfill {g}_{n}\mathit{\Delta}{x}^{2}\hfill \\ \hfill :\hfill \\ \hfill {g}_{N-1}\mathit{\Delta}{x}^{2}\hfill \\ \hfill -2{y}_{R}\hfill \end{array}\right).$ | $(3.12)$ |

$\mathbf{D}\mathbf{y}=\mathbf{h},$ | $(3.13)$ |

$\mathbf{y}={\mathbf{D}}^{-1}\mathbf{h}.$ | $(3.14)$ |

$(-1\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}1\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}0\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}\dots )(\mathbf{y})={y}_{2}-{y}_{1}=\mathit{\Delta}x({\mathit{dy}/\mathit{dx}|}_{1}).$ | $(3.15)$ |

$(-\frac{3}{2}\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}2\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}-\frac{1}{2}\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}0\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}\dots )(\mathbf{y})=-\frac{1}{2}({y}_{3}-{y}_{2})+\frac{3}{2}({y}_{2}-{y}_{1})=\mathit{\Delta}x({\mathit{dy}/\mathit{dx}|}_{1}).$ | $(3.16)$ |

$\mathit{Ay}+\mathit{By}\text{'}+C=0,$ | $(3.17)$ |

$\left[A(1\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}0\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}0\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}\dots )+\frac{B}{\mathit{\Delta}x}(-\frac{3}{2}\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}2\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}-\frac{1}{2}\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}0\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}\dots )\right](\mathbf{y})=-C.$ | $(3.18)$ |

Figure 3.6: Periodic boundary conditions apply when the independent
variable is, for example, distance around a periodic domain.

A final type of boundary condition worth discussing is called
"periodic". This expression means that the end of the $x$-domain is
considered to be connected to its beginning. Such a situation arises,
for example, if the domain is actually a circle in two-dimensional
space. But it is also sometimes used to approximate an infinite
domain. For periodic boundary conditions it is usually convenient to
label the first and last point 0 and $N$. See Fig. 3.6. They are the same point; so
the values at ${x}_{0}$ and ${x}_{N}$ are the same. There are then $N$
different points and the discretized differential equation must be
satisfied at them all, with the differences wrapping round to the
corresponding point across the boundary. The resulting matrix equation
is then
$\left(\begin{array}{ccccccc}\hfill -2\hfill & \hfill 1\hfill & \hfill \dots \hfill & \hfill 0\hfill & \hfill \dots \hfill & \hfill 0\hfill & \hfill 1\hfill \\ \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill :\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill :\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill :\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill :\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 1\hfill & \hfill -2\hfill & \hfill 1\hfill \\ \hfill 1\hfill & \hfill 0\hfill & \hfill \dots \hfill & \hfill 0\hfill & \hfill \dots \hfill & \hfill 1\hfill & \hfill -2\hfill \end{array}\right)\left(\begin{array}{c}\hfill {y}_{1}\hfill \\ \hfill {y}_{2}\hfill \\ \hfill :\hfill \\ \hfill {y}_{n}\hfill \\ \hfill :\hfill \\ \hfill {y}_{N-1}\hfill \\ \hfill {y}_{N}\hfill \end{array}\right)=\left(\begin{array}{c}\hfill {g}_{1}\mathit{\Delta}{x}^{2}\hfill \\ \hfill {g}_{2}\mathit{\Delta}{x}^{2}\hfill \\ \hfill :\hfill \\ \hfill {g}_{n}\mathit{\Delta}{x}^{2}\hfill \\ \hfill :\hfill \\ \hfill {g}_{N-1}\mathit{\Delta}{x}^{2}\hfill \\ \hfill {g}_{N}\mathit{\Delta}{x}^{2}\hfill \end{array}\right),$ | $(3.19)$ |

$\frac{d}{\mathit{dr}}\left(r\mathit{\kappa}\frac{dT}{\mathit{dr}}\right)=r\mathit{\kappa}\frac{{d}^{2}T}{{\mathit{dr}}^{2}}+\frac{d(r\mathit{\kappa})}{\mathit{dr}}\frac{dT}{\mathit{dr}},$ | $(3.20)$ |

$\begin{array}{ccc}\hfill \frac{d}{\mathit{dr}}\left(r\mathit{\kappa}\frac{dT}{\mathit{dr}}\right)& \multicolumn{2}{c}{=({r}_{n+1/2}{\mathit{\kappa}}_{n+1/2}\frac{{T}_{n+1}-{T}_{n}}{\mathit{\Delta}r}-{r}_{n-1/2}{\mathit{\kappa}}_{n-1/2}\frac{{T}_{n}-{T}_{n-1}}{\mathit{\Delta}r})\frac{1}{\mathit{\Delta}r}}\\ \hfill & \hfill =\frac{1}{\mathit{\Delta}{r}^{2}}[\hspace{0.5em}{r}_{n+1/2}{\mathit{\kappa}}_{n+1/2}& \mathrm{\hspace{0.5em}\hspace{0.5em}}{T}_{n+1}\hfill \\ \hfill & \hfill \mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}-({r}_{n+1/2}{\mathit{\kappa}}_{n+1/2}+{r}_{n-1/2}{\mathit{\kappa}}_{n-1/2})& \mathrm{\hspace{0.5em}\hspace{0.5em}}{T}_{n}\hfill \\ \hfill & \hfill \mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}+{r}_{n-1/2}{\mathit{\kappa}}_{n-1/2}& \mathrm{\hspace{0.5em}\hspace{0.5em}}{T}_{n-1}\hspace{0.5em}].\hfill \end{array}$ | $(3.21)$ |

$2\mathit{\pi}{r}_{n+1/2}{\mathit{\kappa}}_{n+1/2}{\frac{\mathit{dT}}{\mathit{dr}}|}_{n+1/2}-2\mathit{\pi}{r}_{n-1/2}{\mathit{\kappa}}_{n-1/2}{\frac{\mathit{dT}}{\mathit{dr}}|}_{n-1/2}=-{\int}_{{r}_{n-1/2}}^{{r}_{n+1/2}}p2\mathit{\pi}r\text{'}\mathit{dr}\text{'}.$ | $(3.22)$ |

$\begin{array}{ccc}\hfill \frac{d}{\mathit{dr}}\left(r\mathit{\kappa}\frac{dT}{\mathit{dr}}\right)& \multicolumn{2}{c}{=({r}_{n}{\mathit{\kappa}}_{n}\frac{{T}_{n+1}-2{T}_{n}+{T}_{n-1}}{\mathit{\Delta}{r}^{2}}+\frac{{r}_{n+1}{\mathit{\kappa}}_{n+1}-{r}_{n-1}{\mathit{\kappa}}_{n-1}}{2\mathit{\Delta}r}\frac{{T}_{n+1}-{T}_{n-1}}{2\mathit{\Delta}r})}\\ \hfill & \hfill =\frac{1}{\mathit{\Delta}{r}^{2}}[\hspace{0.5em}({r}_{n+1}{\mathit{\kappa}}_{n+1}/4+{r}_{n}{\mathit{\kappa}}_{n}-{r}_{n-1}{\mathit{\kappa}}_{n-1}/4)& \mathrm{\hspace{0.5em}\hspace{0.5em}}{T}_{n+1}\hfill \\ \hfill & \hfill -2{r}_{n}{\mathit{\kappa}}_{n}& \mathrm{\hspace{0.5em}\hspace{0.5em}}{T}_{n}\hfill \\ \hfill & \hfill +(-{r}_{n+1}{\mathit{\kappa}}_{n+1}/4+{r}_{n}{\mathit{\kappa}}_{n}+{r}_{n-1}{\mathit{\kappa}}_{n-1}/4)& \mathrm{\hspace{0.5em}\hspace{0.5em}}{T}_{n-1}].\hfill \end{array}$ | $(3.23)$ |

$\frac{d}{\mathit{dr}}\left(r\frac{dy}{\mathit{dr}}\right)+\mathit{rg}(r)=0$ | $(3.24)$ |

We write down the finite difference equation at a generic position: ${\frac{\mathit{dy}}{\mathit{dr}}|}_{n+1/2}=\frac{{y}_{n+1}-{y}_{n}}{\mathit{\Delta}}.$ Substituting this into the differential equation, we get

$\begin{array}{ccc}\multicolumn{1}{c}{-{r}_{n}{g}_{n}=\frac{d}{\mathit{dr}}{\left(r\frac{\mathit{dy}}{\mathit{dr}}\right)}_{n}}& =\hfill & ({r}_{n+1/2}{\frac{\mathit{dy}}{\mathit{dr}}|}_{n+1/2}-{r}_{n-1/2}{\frac{\mathit{dy}}{\mathit{dr}}|}_{n-1/2})\frac{1}{\mathit{\Delta}}\hfill \\ \multicolumn{1}{c}{}& =\hfill & ({r}_{n+1/2}\frac{{y}_{n+1}-{y}_{n}}{\mathit{\Delta}}-{r}_{n-1/2}\frac{{y}_{n}-{y}_{n-1}}{\mathit{\Delta}})\frac{1}{\mathit{\Delta}}\hfill \\ \multicolumn{1}{c}{}& =\hfill & ({r}_{n+1/2}{y}_{n+1}-2{r}_{n}{y}_{n}+{r}_{n-1/2}{y}_{n-1})\frac{1}{{\mathit{\Delta}}^{2}}.\hfill & \hfill \hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}\hspace{1em}(3.25)\end{array}$ |

It is convenient (and improves matrix conditioning) to divide this equation through by ${r}_{n}/{\mathit{\Delta}}^{2}$, so that the $n$th equation reads

$\left(\frac{{r}_{n+1/2}}{{r}_{n}}\right){y}_{n+1}-2{y}_{n}+\left(\frac{{r}_{n-1/2}}{{r}_{n}}\right){y}_{n-1}=-{\mathit{\Delta}}^{2}{g}_{n}$ | $(3.26)$ |

$\frac{{r}_{n\pm 1/2}}{{r}_{n}}=\frac{n\pm 1/2}{n}=1\pm \frac{1}{2n}.$ | $(3.27)$ |

$\mathit{\Delta}{\mathit{dy}/\mathit{dx}|}_{0}=-\frac{1}{2}({y}_{2}-{y}_{1})+\frac{3}{2}({y}_{1}-{y}_{0})=(-\frac{3}{2}\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}2\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}-\frac{1}{2}\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}0\mathrm{\hspace{1em}\hspace{1em}\hspace{1em}}\dots )(\mathbf{y})=0.$ | $(3.28)$ |

$\left(\begin{array}{ccccccc}\hfill -\frac{3}{2}\hfill & \hfill 2\hfill & \hfill -\frac{1}{2}\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 1-\frac{1}{2}\hfill & \hfill -2\hfill & \hfill 1+\frac{1}{2}\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 1-\frac{1}{2n}\hfill & \hfill -2\hfill & \hfill 1+\frac{1}{2n}\hfill & \hfill 0\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill \ddots \hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 1-\frac{1}{2(N-1)}\hfill & \hfill -2\hfill & \hfill 1+\frac{1}{2(N-1)}\hfill \\ \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill 0\hfill & \hfill -2\hfill \end{array}\right)\left(\begin{array}{c}\hfill {y}_{0}\hfill \\ \hfill {y}_{1}\hfill \\ \hfill :\hfill \\ \hfill {y}_{n}\hfill \\ \hfill :\hfill \\ \hfill {y}_{N-1}\hfill \\ \hfill {y}_{N}\hfill \end{array}\right)=-{\mathit{\Delta}}^{2}\left(\begin{array}{c}\hfill 0\hfill \\ \hfill {g}_{1}\hfill \\ \hfill :\hfill \\ \hfill {g}_{n}\hfill \\ \hfill :\hfill \\ \hfill {g}_{N-1}\hfill \\ \hfill 0\hfill \end{array}\right)$ | $(3.29)$ |

Figure 3.7: Example of the result of a finite difference solution for
$y$ of eq. (3.24) using a matrix of the form of
eq. (3.29). The source $g$ is purely
illustrative, and is plotted in the figure. The boundary points at
the ends of the range of solution are $r=0$, and $r=N\mathit{\Delta}=4$. A
grid size $N=25$ is used.

$\frac{{d}^{2}y}{{\mathit{dx}}^{2}}=f(x)$ |

on the $x$-domain $[0,1]$, spanned by an equally spaced mesh of $N$ nodes, with Dirichlet boundary conditions $y(0)={y}_{0}$, $y(1)={y}_{1}$. When you have got it working, obtain your personal expressions for $f(x)$, $N$, ${y}_{0}$, and ${y}_{1}$ from

- Your code in a computer format that is capable of being executed.
- The expressions of your problem $f(x)$, $N$, ${y}_{0}$, and ${y}_{1}$
- The numeric values of your solution ${y}_{j}$.
- Your plot.
- Brief commentary ($<300$ words) on what problems you faced and how you solved them.

2. Save your code and make a copy with a new name. Edit the new code so that it solves the ODE

$\frac{{d}^{2}y}{{\mathit{dx}}^{2}}+{k}^{2}y=f(x)$ |

on the same domain and with the same boundary conditions, but with the extra parameter ${k}^{2}$. Verify that your new code works correctly for small values of ${k}^{2}$, yielding results close to those of the previous problem. Investigate what happens to the solution in the vicinity of $k=\mathit{\pi}$. Describe what the cause of any interesting behavior is. Submit the following as your solution:

- Your code in a computer format that is capable of being executed.
- The expressions of your problem $f(x)$, $N$, ${y}_{0}$, and ${y}_{1}$
- Brief description ($<300$ words) of the results of your investigation and your explanation.
- Back up the explanation with plots if you like.

HEAD | NEXT |