# How to solve coupled differential equations numerically?

I've just started a project, trying to do simulation of electrodynamics using the well-known Maxwell equations: $$\nabla \cdot \mathbf E = \rho \\ \; \\ \nabla \cdot \mathbf B = 0 \\ \; \\ \nabla \times \mathbf E = -\frac{\partial \mathbf B}{\partial t} \\ \; \\ \nabla \times \mathbf B = \mathbf J + \frac{\partial \mathbf E}{\partial t} \\ \; \\$$ Once I setted up the project, I was going to see how could I simulate the equations, but they are coupled. For example: $$\nabla \cdot \mathbf E = \frac{\partial E^1}{\partial x_1} + \frac{\partial E^2}{\partial x_2} + \frac{\partial E^3}{\partial x_3} = \rho$$ This equations depends on $$E^1$$, $$E^2$$ and $$E^3$$, which we have to find with the others equations. It is possible to write individual equations for each field component, to then integrate numerically? Is there any other better method? I'm new to all of this, so any help would be appreciated.

Note: I would use C as the language of the project, if that could help.

• Why not use something others have already developed: dealii.org/developer/doxygen/deal.II/group__vector__valued.html Commented Jun 12, 2023 at 15:42
• Commented Jun 12, 2023 at 16:41
• To add a bit more context to Wolfgang's comment, the numerical simulation of PDEs is one of the most well-studied and widely practiced applications of numerical analysis, functional analysis, and scientific computing in the last century. As in the analysis of PDEs, different equations often require different tools to simulate. There are a wide variety of frameworks, methods, and software packages out there and for nontrivial problems. It is almost certainly a better use of your time to use an existing library then go from there, especially in a low-level language like C. Commented Jun 12, 2023 at 23:41

2. Re-write Gauss's Law for electrostatics as Poisson's equation and solve for the scalar potential, ignoring all the other equations. Note that the approximation $$\vec{E} = - \nabla \phi$$ is only a good approximation for slowly varying $$\vec{E}$$. As a result this approach is suitable if you're interested in the slowly varying (near electrostatic/megnetostatic) behavior of electromagnetic fields. In this case you aren't really solving for the magnetic field at all, only the electric field. This is an elliptic PDE and methods for solving Poisson's equation are readily available.