+
Separation of Variables in Cartesian Coordinates
Developed by J. D. McDonnell  Published July 16, 2016
This set of exercises will guide the student through solving Laplace's equation for the electric potential in Cartesian coordinates via separation of variables. They will perform numerical integration and produce plots of the electric potential for situations with nontrivial boundary conditions.
Subject Areas  Electricity & Magnetism and Mathematical/Numerical Methods 

Level  Beyond the First Year 
Available Implementation  IPython/Jupyter Notebook 
Learning Objectives 
Students who complete this set of exercises will
 be able to use separation of variables to solve Laplace's equation in Cartesian coordinates in two dimensions (**Exercise 1**),
 be able to use separation of variables to solve Laplace's equation in Cartesian coordinates in three dimensions (**Exercise 2**),
 be able to supplement an analytical solution with numerical methods, such as numerical integration (**Exercises 1 and 2**),
 and be able to produce and analyze visualizations for the electric potential (**Exercises 1 and 2**).

Time to Complete  90 min 
These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).
### Exercise 1: A TwoDimensional Case
As a "warmup", consider the following twodimensional situation. A squared 'c'shaped "slot" is set up, where the two parallel horizontal pieces extend from $x=0$ to $x\to \infty$, and the vertical connecting piece sits at $x=0$ and extends from $y=0$ to $y=a$. Both horizontal pieces are grounded, and the vertical piece is held to a potential $V(x=0,y) = V_0(y)$, where $V_0(y)$ is a function to be specified.
![](images/SepVarCartesian/RectangularC.png)
First, set up the solution of Laplace's equation with the specified boundary conditions. Generally, it will be an *infinite series*.
Your solution, which must be quite generic until we specify $V_0(y)$, should include an integral in terms of $V_0(y)$. For simple forms of $V_0(y)$, the integral can be done by hand. But for "interesting" forms of $V_0(y)$, it is valuable to evaluate this integral with numerical techniques.
It will be impossible to evaluate *every* term in an infinite series  you must choose a sufficient number of terms to keep. In each example below, experiment to see how many terms are necessary to capture the solution. You might try $N=5, N=10, N=20\ldots$.
For each of the $V_0(y)$ functions specified below, (1) evaluate your solutions for $V(x,y)$ numerically; (2) produce a *contour plot* of $V(x,y)$; and (3) describe your solution in physical terms  for example, does the behavior of the potential match your expectations?
 $V_0(y) = 6.0\sin\left(\frac{3\pi y}{a}\right)$. **Note**: This example can be easily evaluated by hand, as a way of checking your numerical method.
 $V_0(y) = y^2 + ay$. **Note**: This example *can* also be evaluated by hand...
 $V_0(y) = \sinh(y  \frac{a}{2})$.
### Exercise 2: A ThreeDimensional Case
For a threedimensional case, the same overall scheme allows us to solve Laplace's equation in Cartesian coordinates.
Consider a semiinfinite "pipe": at $x=0$ there is a rectangular plate held at a potential (to be specified later) $V(x=0, y,z) = V_0(y,z)$. Four infinitely long plates are joined to the four edges of the first plate, each extending from $x=0$ to $x\to\infty$. The four infinitely long plates are grounded.
![](images/SepVarCartesian/RectangularPipe.png)
Dimensions of the semiinfinite "pipe":
 From $x=0$ to $x\to\infty$.
 From $y=0$ to $y=a$.
 From $z=0$ to $z=b$.
Again, set up the solution of Laplace's equation with the specified boundary conditions. Generally, it will be an *infinite series*. Similarly to the twodimensional case, you will encounter integrals in terms of $V_0(y,z)$, but now they are double integrals over **both** $y$ and $z$!
For each of the $V_0(y,z)$ functions specified below, (1) evaluate your solutions for $V(x,y,z)$ numerically; (2) produce a *contour plot* of $V(x,y,z)$, in different cross sections for constant $z$; and (3) describe your solution in physical terms  for example, does the behavior of the potential match your expectations?
 $V_0(y,z) = y$.
 $V_0(y,z)=4y^2 + 4ay  z^2 + bz + \frac{3}{4}ab\, yz$.
 $V_0(y,z)=\sinh\left(\left(y\frac{a}{2}\right)\,\left(z\frac{b}{2}\right)\right)$.
Download Options
Share a Variation
Did you have to edit this material to fit your needs? Share your changes by
Creating a Variation
Credits and Licensing
J. D. McDonnell, "Separation of Variables in Cartesian Coordinates," Published in the PICUP Collection, July 2016.
The instructor materials are ©2016 J. D. McDonnell.
The exercises are released under a Creative Commons AttributionNonCommercialShareAlike 4.0 license