In my last
blog post, we discussed 3D charge configurations that have sharp edges. Reader Rich Heart commented on it and asked whether
Mathematica can calculate the force between two charged cubes, as done by Bengt Fornberg and Nick Hale and in the appendix of Lloyd N. Trefethen's
book chapter.
The answer to the question from the post is: Yes, we can; I mean, yes,
Mathematica can.
Actually, it is quite straightforward to treat a more general problem than two just-touching cubes of equal size:
We can deal with two cubes of different edge lengths L1 L2
We can calculate the force for any separation
X, where
X is the distance between the two cube centers (including the case of penetrating cubes; think plasma)
We will use a method that can be generalized to higher-dimensional cubes without having to do more nested integrals
Instead of calculating the force between the two cubes, we will calculate the total electrostatic energy of the system of the two cubes. The force is then simply the negative gradient of the total energy with respect to
X. The electrostatic energy (in appropriate units) is given by:
(In the following calculations, we will skip the constant [with respect to
X] prefactors Q1 L1-3 Q2 L2-3 or Q1 Q2 if not needed.)
Approaching this integral head-on doing one integral after another is possible, but a very tedious and time-consuming operation. Instead, to avoid having to carry out a nested six-dimensional integral, we remember the Laplace transform of 1 / √s.