TLDR: Are these polynomials really harmonic polynomials, and how can I generate them?
Long version:
I want to describe an electrostatic potential $\Phi(x,y,z)$ over a source-free volume, by using a polynomial of the form
$$\begin{align} \Phi(x,y,z) &= a_{000} + a_{100} x + a_{010} y + \dots + a_{123}xy^2z^3 + \dots \\ &= \sum_{l,m,n \geq 0}^\infty a_{lmn}x^ly^mz^n \quad . \end{align} $$
The potential is known to me on a grid: I simulated it using a finite element simulation, and I want to find the coefficients $a_{lmn}$ so that I can give a smooth estimate of the potential around the origin. I verified that my potential $\Phi(x,y,z)$ is "benign" in the sense that I can neglect all terms higher than some order $N$. I can somewhat successfully find the coefficients $a_{lmn}$ with a crude fit, but of course the fit-functions $x^ly^mz^n$are not orthogonal in any way, which makes "finding the right order $N$" more important than in should be.
But since the volume that I am interested in is charge free, I know that the total polynomial must satisfy the Laplace equation $\Delta\Phi(x,y,z) = 0$. I want to use this fact to rewrite the polynomial as a sum of smaller polynomials that, on their own, satisfy the Laplace equation and are orthogonal to each other. I believe such polynomials are called harmonic polynomials, and the whole process reminds me of doing multipole expansions, only that instead of sitting far away from the charges that create the potential, I sit between them.
Using horror-inducing Mathematica expressions that transmogrify spherical harmonics to real-valued, cartesian harmonics, I found a set of polynomials $p_{n,m}(x,y,z)$ of degree $n$, with $-n \leq m \leq n$, which as far as I have tested,
- satisfy the Laplace equation,
- are orthogonal over the cube $x,y,z \in [-1;1]$
- are normalizied over the cube $x,y,z \in [-1;1]$
The first of these polynomials are (dropping all normalization factors to make them shorter)
$$\begin{align} p_{0,0}(x,y,z) &= 1\\ \\ p_{1,-1}(x,y,z) &= x\\ p_{1,0}(x,y,z) &= y\\ p_{1,1}(x,y,z) &= z\\ \\ p_{2,-2}(x,y,z) &= xy\\ p_{2,-1}(x,y,z) &= yz\\ p_{2,0}(x,y,z) &= x^2+y^2-2 z^2\\ p_{2,1}(x,y,z) &= xz\\ p_{2,2}(x,y,z) &= x^2-y^2\\ \\ p_{3,-3}(x,y,z) &= -3x^2y+y^3\\ p_{3,-2}(x,y,z) &= xyz\\ p_{3,-1}(x,y,z) &= y(x^2+y^2-4z^2)\\ p_{3,0}(x,y,z) &= z(-3(x^2+y^2)+2z^2)\\ p_{3,1}(x,y,z) &= x(x^2+y^2-4z^2)\\ p_{3,2}(x,y,z) &= (x^2-y^2)z\\ p_{3,3}(x,y,z) &= x^3-3xy^2 \end{align} $$
I vaguely remember encountering similar polynomials when doing multipole expansions of ion optic elements, such as magnetic fields used in particle accelerators. But the generating terms used in ion optics are typically two-dimensional.
I have tried finding how to generate such polynomials in the literature, but found nothing that did not use pretty heavy math. I am not entirely sure that "harmonic polynomials" is really the correct term form them. In any case, how can these polynomials be efficiently generated in a way that ensures that they are orthogonal?