# Magnetic field of a solenoid

I'm a bit confused with the equation for a long solenoid. The usual derivation has us consider a rectangular loop enclosing N number of currents over the length L through it. So by Ampere's law one gets B=μNI/L.

The currents and the loop look like this right?
---------
| . . . . |
---------
x x x x

However, why doesn't one also consider the magnetic field contribution from the x's also? So that the sum will be B=2μNI/L? In fact one can find an infinite number of these loops each giving B and the magnetic field will sum to infinity. Which clearly is nonsense.

It's like Gauss's Law for charges, I have +q and -q seperated symmetrically. I ask what's the magnitude of the electric field at a distance r from both charges. I enclose each with a Gaussian surface and I find the field from each of them +q/r² and -(-q/r²); the double negatives to take direction into consideration. Later I also have to add the fields together to get 2q/r², and not say q/r² is what's actually there just from taking one Gaussian surface.

I hope someone can enlighten me. Thank you!

Last edited: