# Already integrated formula of magnetic field for a finite line?

I was looking for a formula to simulate a magnetic field due to a straight finite line. The closest to what I wanted to find was in these lecture notes (formula 9.11.2 page 9-50), \begin{align} \mathbf{B}&=\int d\mathbf{B}\\ &=\int_{-L/2}^{L/2}\frac{\mu_0Iy}{4\pi\left[(x-x')^2+y^2\right]^{3/2}}dx'\hat{\mathbf{k}}\\ &=-\frac{\mu_0Iy}{4\pi}\left[\frac{(x-L/2)}{\left[(x-L/2)^2+y^2\right]^{1/2}}-\frac{(x+L/2)}{\left[(x+L/2)^2+y^2\right]^{1/2}}\right]\hat{\mathbf{k}} \end{align} Is there the same thing for a 3d point? I'm looking for $B_x$, $B_y$ and $B_z$.

In principle, you could use exactly the same steps as are in those notes to derive the full 3D expression. You would have to substitute $\vec{r} = x \hat{\imath} + y \hat{\jmath} + z \hat{k}$ in step 2, and then follow the logic through from there.
However, an easier way to find the result for point out of the chosen plane is to exploit the rotational symmetry of the situation. The quantity $y$ can be seen to be standing in for the distance from the $x$-axis; we can call this $\rho = \sqrt{y^2 + z^2}$. The vector $\hat{k}$ is a little trickier, but it can be seen to be a unit vector that is at right angles to both $\hat{\imath}$ and the field point vector $\vec{r}$. To find this, we can take a cross product: $$\vec{v} = \hat{\imath} \times \vec{r} = \hat{\imath} \times (x \hat{\imath} + y \hat{\jmath} + z \hat{k}) = y \hat{k} - z \hat{\jmath}$$ and so $$\hat{v} = \frac{\vec{v}}{|\vec{v}|} = \frac{y \hat{k} - z \hat{\jmath}}{\sqrt{y^2 + z^2}} = \frac{y}{\rho} \hat{k} - \frac{z}{\rho} \hat{\jmath}$$ Taking your above formula for $\vec{B}$ and substituting $y \to \rho$ and $\hat{k} \to \hat{v}$ gives us the magnetic field at an arbitrary point $(x,y,z)$. (Do be careful here, though; the $y$ in the expression for $\hat{v}$ should remain as $y$, and not be substituted for $\rho$.) Note that $B_x = 0$ everywhere; this makes sense, because each $d\vec{B}$ must be at right angles to its corresponding current element, and all current elements here point in the $x$-direction.
The resulting expression, by the way, can be expressed a little more naturally in cylindrical coordinates (with the symmetry axis being chosen to lie along the $x$-axis.) The question seemed more interested in the Cartesian components, so I didn't include this expression.