The neutral charge density for our example solution to Poisson's
equation will be
As an exercise to show to the grader, copy the code ``poisson.m'' from Appendix C to your octave directory, and complete the program by replace ``...'' on the line labelled ``CODE INSERTION # 1'' with a code fragment to evaluate in the column vector dr the distance between each sampling point in r and the center of the cell,
[R(1,1)/2; R(2,2)/2; R(3,3)/2]=diag(R)'/2
ones(prod(S),1)*diag(R)'and use a similar procedure to what you used to compute G2. Feel free to type ones(prod(S),1)*diag(R)' at the command prompt to see the value of this expression. Finally, note that in octave, ``sqrt(A)'' creates an object of the same dimensions as ``A'' and with elements equal to the square root of each corresponding element of ``A''.
To verify your code fragment, run ``poisson.m''. This octave program
will use the distances which you compute in dr to evaluate
,
and
according to Eq. (6). The program then checks
your distributions by integrating each of these functions by a simple
Riemann sum
,
where the volume per sample point is
. For these tests, your results should be good to at least 3
decimal places. Finally, to aid in debugging, the program will plot
the charge density in three perpendicular planes passing through the
center of your cell. Each of these should appear as a positive
Gaussian with a noticeable negative ripple as you move away from the
main peak.