Inhomogeneous magnetic field If $B=C\hat{z}+f(y)\hat{y}$ is an inhomogeneous magnetic field where $C$ is a constant, how is it possible to find out what the function $f(y)$ is?
 A: Let us consider Gauss' Law. This is given by:
$\nabla \cdot B=0$, where $B$ is the magnetic field vector.
We can work this out, recall that $\nabla = \partial_x e_x + \partial_y e_y +\partial_z e_z$ therefore the standard inner product gives:
$\nabla \cdot B = \partial_x B_x + \partial_y B_y + \partial_z B_z = \partial_y f(y) + \partial_z C = \partial_y f(y)=0$.
Therefore we get by integration that $f(y)=f(x,z)$, so with that I mean that $f(y)$ has no dependence on $y$ and it could only be a constant or a function of $x,z$ or one of them.
The reason why it is inhomogeneous is because of the $x,z$ dependence. Since this is given we can rule out the possibility that $f=constant$, so we have $f=f(x,z)$.
Edit: The question is a bit tricky since it asks you to calculate a function $f(y)$ which depends clearly on $y$ but then it also states that the magnetic field has to be inhomogeneous. When we say that $f(y)$ is constant, this means that $B$ is not inhomogeneous but when we say $f(y)=f(x,z)$ this contradicts that $f$ is a function of $y$. So something weird must be going on!
Hope this helps a bit!
