# Why is the application of Ampere's law on H field incorrect in this situation?

A very long cylindrical bar magnet with radius $r$ has a magnetization vector $\mathbf{M}$ as in the figure.

To find the magnetic field $\mathbf{B}$ outside the magnet, I apply Ampere's law as follows: $$\int\mathbf{H} \cdot \mathbf{dl} = 2\pi r H = I_{free} = 0 \rightarrow \mathbf{H} = 0$$ where $$\mathbf{H} =\frac{1}{\mu_0}\mathbf{B} - \mathbf{M}\tag1$$ Because $\mathbf{M}=0$ outside, $$\mathbf{B} = \mu_0 (\mathbf{H} + \mathbf{M}) = 0 \text{ outside,}$$ which is obviously wrong.

Could you explain to me why I cannot apply Ampere's law to the $\mathbf{H}$ field to find $\mathbf{B}$ in this problem?

The problem is that Ampere's law only tells you how part of $\mathbf{H}$ behaves, what we call the solenoidal part. Unlike $\mathbf{B}$, which is purely solenoidal because $\nabla\cdot\mathbf{B}=0$ (see: Helmholtz deomposition), $\mathbf{H}$ has a divergenceful part. To see whence that comes, take the divergence of both sides of your Equation (1), to get $$\nabla\cdot\mathbf{H} = -\nabla\cdot\mathbf{M}. \tag2$$ What Equation (2) implies is that divergences in the magnetization $\mathbf{M}$ act like negative charges in the $\mathbf{H}$ field. What I mean here is the formula in Equation (2) is, fundamentally, the same as $$\nabla\cdot\mathbf{E} = \frac{\rho}{\epsilon_0}$$ with $\mathbf{E} \rightarrow \mathbf{H}$ and $\epsilon_0^{-1}\rho \rightarrow -\nabla\cdot\mathbf{M}$. So, just as we can write $$\mathbf{E}_{\mathrm{div}}(\mathbf{x}) = \frac{1}{4\pi\epsilon_0} \int \frac{\mathbf{x}-\mathbf{x}'}{\left|\mathbf{x}-\mathbf{x}'\right|^3} \rho(\mathbf{x}') \operatorname{d}^3 x'$$ for the divergenceful part of $\mathbf{E}$ using Coulomb's law, we can also write $$\mathbf{H}_{\mathrm{div}}(\mathbf{x}) = -\frac{1}{4\pi} \int \frac{\mathbf{x}-\mathbf{x}'}{\left|\mathbf{x}-\mathbf{x}'\right|^3} \nabla'\cdot\mathbf{M}(\mathbf{x}') \operatorname{d}^3 x'.$$ Because of this we define the quantity $\rho_H = -\nabla\cdot \mathbf{M}$, which is the density of $H$-charge.
In this problem, you have two circular surface charge densities on either end of the magnet. Where does that come from? Well, in the bulk of the magnet you have $\nabla\cdot\mathbf{M}=0$. If you have some closed surface where $\mathbf{M}$ changes discontinuously, though, you will have a surface density of $H$-charge. The formula for that is $$\sigma_H = \hat{n}\cdot \left(\mathbf{M}_{\mathrm{out}} -\mathbf{M}_{\mathrm{in}}\right),$$ where $\hat{n}$ is the outward pointing normal vector to the surface, $\mathbf{M}_{\mathrm{out}}$ is the magnetization just outside of the surface, and $\mathbf{M}_{\mathrm{in}}$ is the magnetization just inside.
Punchline: the total $\mathbf{H}$ field here will be the same as the electric field from two charged discs that have the surface charge density given above.
Another approach centers around taking the curl of both sides of Equation (1) to get $$\nabla\times \mathbf{B}=\mu_0(\nabla\times\mathbf{H}+\nabla\times\mathbf{M})$$ which, with $\nabla\times\mathbf{H}=0$, gives $$\nabla\times \mathbf{B}=\mu_0\nabla\times\mathbf{M},$$ which says $\mathbf{B}$ is produced by bound currents. Like with $H$-charge or bound charge in electric polarization, the quantity $\nabla\times \mathbf{M}$ is a bound current density called $\mathbf{J}_{\mathrm{bound}}$.
In the case given in the question, the bound currents form a uniform sheet current around the side of the magnet. Just like how a discontinuous change in $\mathbf{M}$ across a surface implies a surface $H$-charge, it also implies a surface bound current density $\mathbf{K}_{\mathrm{bound}}$ given by $$\mathbf{K}_{\mathrm{bound}} = -\hat{n}\times \left(\mathbf{M}_{\mathrm{out}}-\mathbf{M}_{\mathrm{in}}\right).$$ So, in the picture in the question, the uniform sheet current is circulating around the side of the cylinder counter-clockwise if we look down on the cylinder with the magnetization pointing at us.