# Magnetic field due to a finite-length straight wire carrying a constant current

My question: I want to find an expression at any point in space for the magnetic field $$\mathbf B$$ produced by a straight wire of finite length $$L$$ carrying a constant current $$I$$.

I think that we can simplify our analysis by using cylindrical coordinates, and by placing the wire along the $$z$$ axis such that the center of the wire is at the origin; we assume the current flows in the positive $$z$$ direction. So the diagram would be the following:

My attempt: Below I show my procedure which I initially wrote in Microsoft Word. I think it'd be a waste of time to translate it to Latex, but if you ask for it, I'll do it.

Image 1/4:

Image 2/4:

Image 3/4:

Image 4/4:

End of the computations.

Here's a plot in Wolfram Mathematica assuming $$I = 10 \text{ A}$$ and $$L = 10 \text{ m}$$:

Now, there are some reasons why I think my formula for $$\mathbf B$$ could be correct:

• The magnitude of the field is inversely proportional to the perpendicular distance $$\rho_0$$ between the wire and the point $$P$$. So the farther the point is from the wire, the weaker the field, as expected.
• The direction of the field is in accordance with the right-hand rule.
• In the extreme/particular case of an infinite wire, the formula simplifies to the well-known formula obtained from Ampère's law (in magnetostatics i.e. without Maxwell's correction).

However, I'm a bit hesitant because I haven't touched vector calculus nor electromagnetic theory since I took a class about 1.5 years ago; I had to review many mathematical equations to answer this question. So I'm asking you to check my work to see if there're no mistakes.

By the way, I'd be more grateful if you could manage to simplify the general expression I got.

• I do not find any errors here. It is perfect, although I have never tried to find Magnetic field due a finite straight wire using the cylindrical co-ordinates; it is very interesting. Aug 29 at 9:47
• @NikolaAlfredi $z_0$ is the $z$ coordinate of the point $P$ where we're computing the field, while $l$ is the position vector of the differential current segment. The integral is w.r.t. to the variable $z$ ($z$ direction), however this is the same as $l$ (not $z_0$) because they're parallel. Am I still mistaken? Aug 29 at 9:49
• Yes, I removed my comment as soon as I realised my mistake. Aug 29 at 9:51
• Whoops, I just noticed you deleted the first comment and posted another. I'll keep my previous comment in case some else gets confused with my notation. Thanks BTW. Aug 29 at 9:52
• To find the magnetic field due to a finite-length straight wire carrying a constant current has no sense (it violates the continuity equation). See my answer and comments here Magnetic field due to a single moving charge. Aug 29 at 10:04