# How can I calculate numerically an electrical potential distribution from an electric field distribution?

I want to calculate the unknown electrical potential distribution $\phi(x)$ (notice this is a function of $x$) from a known electric field distribution $\boldsymbol{E}(x)$ using the Poisson equation,

$$-\frac{\partial^2 \phi}{\partial x^2} = \frac{\partial\boldsymbol{E}}{\partial x}$$

I would like to do this numerically, but I am not sure about the procedure I need to follow to get $\phi(x)$.

Because I have numerical data for $\boldsymbol{E}(x)$ I first integrated the Poisson equation once,

$$\int \frac{\partial^2 \phi(x)}{\partial x^2} dx = \int \frac{\partial\boldsymbol{E}(x)}{\partial x} dx$$

to get, $$\frac{\partial \phi(x)}{\partial x} = -\boldsymbol{E}(x) + C$$

This would imply that all I need to do to find $\phi(x)$ is to integrate the numerical data I have for $\boldsymbol{E}(x)$. This is easily done using the trapezium rule but it will give a constant value, not a distribution! Basically I don't understand how to convert $\boldsymbol{E}(x)$ to $\phi(x)$ numerically, where I have numerical data for $\boldsymbol{E}(x)$. Do you have suggestions on how I can do this?

• Hi, this is a relatively basic problem in numerics. You consider a discrete version of the Poisson equation, which leads to a linear system of equations. I suggest you read this: en.wikipedia.org/wiki/Discrete_Poisson_equation and then ask any specific questions about this source here. Commented May 29, 2013 at 5:02
• @Lagerbaer This is what I have done (although in a slightly modified way). I have implemented a finite-difference which solves the Poisson equation in terms of Electric field (from the charge dist.), $$\frac{\partial \boldsymbol{E}}{\partial x}=\rho/\epsilon$$ For my application the Poisson equation is only one in a set if 3 coupled equations. The nature of the problem requires I solve it it terms of electric field. But I would also like to convert the result to look at the potential profile. Do you have suggestions on how I can do that? Commented May 29, 2013 at 5:30
• Are you in one dimension only? Then you can just integrate. You say that that would give you only a constant, but you carelessly omitted the integration limits from your integrals. You start from some reference point $x_0$ and integrate up to the point $x$ you're interested in, $\phi(x) = \int_{x_0}^x E(x') dx'$ Commented May 29, 2013 at 5:32
• @Lagerbaer I think that could be the answer, a cumulative integration. Could you show me the mathematics behind the equation your wrote? Commented May 29, 2013 at 5:47
• That's just the very basics of an integral. Instead of the indefinite integral that you initially used, you use the definite integral from some reference point $x_0$ to the point of interest $x$, see en.wikipedia.org/wiki/Integral here Commented May 29, 2013 at 14:49

The basic equation of electrostatic is $$\mathbf{E}=-\nabla\varphi$$ not $$\frac{\partial\varphi}{\partial x}=-\mathbf{E}+C$$ It follows from a simple principle that the work electric field does when moving a charge from point A to point B does not depend on the path between A and B, otherwise, we would have a perpetuum mobile. Potential is by definition is amount of this work. Therefore in order to get potential you have to integrate the force electric field creates at a test charge on any path that is convenient for you when you move this charge from $\infty$ to the point of interest.
So let's say you have a path that is described by a function $\mathbf{x}\left(t\right)$ such as $$\left\|\frac{\mathrm{d}\mathbf{x}}{\mathrm{d} t}\right\|=1$$ In this case $$\varphi\left(\mathbf{x}_0\right)=-\int^{\mathbf{x}_0}_\infty\mathbf{E}\cdot \frac{\mathrm{d}\mathbf{x}}{\mathrm{d} t}\, \mathrm{d}t$$
If $\mathbf{E}$ is know, we want to find $-\nabla\phi = \mathbf{E}$, then like you wrote in the first equation, but rather we have all $x$, $y$, $z$ second partial derivatives. The following expression is obtained by taking divergence on both sides: $$-\Delta \phi = -\left(\frac{\partial^2 \phi}{\partial x^2} + \frac{\partial^2 \phi}{\partial y^2} + \frac{\partial^2 \phi}{\partial z^2}\right) = \nabla \cdot \mathbf{E}.\tag{1}$$ The equation you wrote pre-suppose that $\phi$ and $\mathbf{E}$ are both separable, which is not true for general domain (please see my answer here to see why the shape of the domain is related to the separability).
Now equation (1) is Poisson equation, for a bounded domain of interest $\Omega$, we can formulate a Neumann boundary value problem: \left\{\begin{aligned} -\Delta \phi &= \nabla \cdot \mathbf{E} \quad \text{in }\Omega, \\ \nabla \phi\cdot \mathbf{n}&= -\mathbf{E} \cdot \mathbf{n}\quad \text{on }\partial \Omega. \end{aligned}\tag{2}\right. This equation (2) is well-posed when certain compatibility condition is assumed, then you can use whichever numerical method that suits your needs (finite element, finite differences, finite volume, Fourier, layer potential, etc).