Calculus – Computing Complex Elliptic Integral

calculuscylindrical coordinatesdefinite integralselliptic integralsintegration

Yesterday I tried to find an expression to predict the behaviour of Magnetic Field due a circular loop at any point in the space, in cylindrical co-ordinates. At the end, I am stuck with some integrals.

Diagram:

enter image description here


Process:

Initially I found out the position vector of a fixed point $\displaystyle P(\rho_0, \phi_0 , z_0)$ : $\displaystyle \vec{r_0} = \rho_0 \hat{\rho_0} + z_0 \hat{z}$

And a general point on loop $\displaystyle O(\rho, \phi , 0)$ : $\displaystyle \vec{r} = \rho \hat{\rho} \implies \displaystyle \vec{r^{'}} = \rho_0 \hat{\rho_0} + z_0 \hat{z} – \rho \hat{\rho} $

As the angle between $\displaystyle \hat{\rho} \ \text{and} \ \hat{\rho_0} $ is $ (\phi – \phi_0) $ we can derive: $\displaystyle \hat{\rho} = \cos (\phi – \phi_0 ) \hat{\rho_0} + \sin (\phi – \phi_0 ) \hat{\phi_0} $.

Now, the general line element in cylindrical co-ordinates is : $\displaystyle \vec{\mathrm{d}l} = \mathrm{d} \rho \ \hat{\rho} + \rho \mathrm{d}\phi \ \hat{\phi} + \mathrm{d} z \ \hat{z} \ $ but here,

$$ \displaystyle \ \text{line element:} \ \vec{\mathrm{d}l} = \rho \mathrm{d}\phi \ \hat{\phi} $$


Biot-Savart Law: $ \displaystyle \vec{B} = \frac{\mu_0}{4\pi} \int_{c} \frac{i \vec{\mathrm{d}l} \times \vec{r^{'}}}{||\vec{r^{'}}||^3}$

Hence, first we need to find the cross product $\displaystyle \vec{\mathrm{d}l} \times \vec{r^{'}} = \rho \mathrm{d}\phi \ \hat{\phi} \times \vec{r^{'}} $

$$\displaystyle \hat{\phi} \times \vec{r^{'}} = z_0 \cos (\phi – \phi_0) \hat{\rho_0} + z_0 \sin (\phi – \phi_0 ) \hat{\phi_0} – (\rho + \rho_0 \cos (\phi – \phi_0)) \hat{z}$$

And $ \displaystyle ||\vec{r^{'}}|| = \left[ z^{2}_{0} + \rho_0^{2} + \rho^{2} – 2\rho_0 \rho \cos (\phi – \phi_0) \right]^{1/2} $

Thus our Integral becomes:

$$ \displaystyle \vec{B} = \frac{\mu_0 i \rho }{4\pi} \int_{0}^{2\pi} \frac{z_0 \cos (\phi – \phi_0) \hat{\rho_0} + z_0 \sin (\phi – \phi_0 ) \hat{\phi_0} – (\rho + \rho_0 \cos (\phi – \phi_0)) \hat{z}}{\left[ z^{2}_{0} + \rho_0^{2} + \rho^{2} – 2\rho_0 \rho \cos (\phi – \phi_0) \right]^{3/2} } \mathrm{d} \phi $$

The coefficient of $\displaystyle \hat{\phi_0} $ is integrable and the definite integral here, results to be zero. This have to be true according to laws of electromagnetism (i.e no magnetic field parallel to the current element).

Hence our Magnetic field becomes:

$$ \displaystyle \vec{B} = \frac{\mu_0 i \rho z_0 }{4\pi} \int_{0}^{2\pi} \frac{\cos (\phi – \phi_0)}{\left[ z^{2}_{0} + \rho_0^{2} + \rho^{2} – 2\rho_0 \rho \cos (\phi – \phi_0) \right]^{3/2} } \mathrm{d} \phi \ \hat{\rho_0} \\
– \frac{\mu_0 i \rho }{4\pi} \int_{0}^{2\pi} \frac{\rho + \rho_0 \cos (\phi – \phi_0)}{\left[ z^{2}_{0} + \rho_0^{2} + \rho^{2} – 2\rho_0 \rho \cos (\phi – \phi_0) \right]^{3/2} } \mathrm{d} \phi \ \hat{z} $$


EDIT:

I have used the Ellipltical integrals (as suggested by @Maxim) to simplify the expression as:

$$
\displaystyle
\vec{B} = \frac{\mu_0 i \sqrt{a} }{2^{2.5} \pi \rho_0^{1.5} \sqrt{\rho} \sqrt{1-a}} (z_0-z) \left [ \frac{1}{1+a} \mathrm{E}\left(\pi, \frac{2a}{1-a} \right) – \mathrm{F}\left( \pi,\frac{2a}{1-a} \right)\right ] \hat{\rho_0} – \frac{\mu_0 i \sqrt{a}}{2^{2.5} \pi \rho_0^{1.5} \sqrt{\rho} \sqrt{1-a}} \left [ \left(\frac{\rho_0}{a+1} + \rho \right) \mathrm{E}\left(\pi, \frac{2a}{1-a} \right) – \rho_0 \mathrm{F}\left( \pi,\frac{2a}{1-a} \right)\right ] \hat{z}\\
$$

Where $\displaystyle a = \frac{2\rho \rho_0}{(z_0-z)^2 + \rho^2 + \rho_0^2}$ and the position of the ring is $(\rho,\phi,z).$

$\mathrm{F}$ is elliptical integral of first kind and $\mathrm{E}$ is of second kind.


Thus, my intial stage is well simplified. But the reason behind this complex calculation was that, I want to complute the Magnetic field due to a solenoid at any point in sapce.

If we assume the number density of the coil to be $n$ and length $z_f – z_i,$ then in a small region of thickness $\mathrm{d}z$, there will be $n\mathrm{d}z$ rings, each with nearly $\vec{B}$ as their magnetic field.

Thus $$\displaystyle \vec{B}_{\text{solenoid}} = \int_{z_i}^{z_f} n\vec{B}\mathrm{d}z $$

Hence it is equivalent to compute :

$$
\displaystyle
\vec{B}_{\text{solenoid}} = \frac{\mu_0 n i }{2^{2.5} \pi \rho_0^{1.5} \sqrt{\rho}} \int_{z_i}^{z_f}
\sqrt{\frac{a}{1-a}}
\left(
(z_0-z) \left [ \frac{1}{1+a} \mathrm{E}\left(\pi, \frac{2a}{1-a} \right) – \mathrm{F}\left( \pi,\frac{2a}{1-a} \right)\right ] \hat{\rho_0} – \left [ \left(\frac{\rho_0}{a+1} + \rho \right) \mathrm{E}\left(\pi, \frac{2a}{1-a} \right) – \rho_0 \mathrm{F}\left( \pi,\frac{2a}{1-a} \right)\right ] \hat{z}
\right) \mathrm{d}z
$$


Thus I need help in solving,

$\displaystyle \int_{z_i}^{z^f} \frac {(z_0-z) ( ( z-z_0)^2 +\rho^2 + \rho_0^2 ) }{\sqrt{( z-z_0)^2 + (\rho – \rho_0)^2} (( z-z_0)^2 + (\rho + \rho_0)^2) } \mathrm{E} \left( \pi, \frac{4\rho \rho_0}{ (z-z_0)^2 + (\rho – \rho_0)^2 } \right) \mathrm{d}z $

$\displaystyle \int_{z_i}^{z^f} \frac {1 }{\sqrt{( z-z_0)^2 + (\rho – \rho_0)^2} } \mathrm{E} \left( \pi, \frac{4\rho \rho_0}{ (z-z_0)^2 + (\rho – \rho_0)^2 } \right) \mathrm{d}z $

$\displaystyle \int_{z_i}^{z^f} \frac {(z_0-z) }{\sqrt{( z-z_0)^2 + (\rho – \rho_0)^2} } \mathrm{F} \left( \pi, \frac{4\rho \rho_0}{ (z-z_0)^2 + (\rho – \rho_0)^2 } \right) \mathrm{d}z $

$\displaystyle \int_{z_i}^{z^f} \frac {1 }{\sqrt{( z-z_0)^2 + (\rho – \rho_0)^2} } \mathrm{F} \left( \pi, \frac{4\rho \rho_0}{ (z-z_0)^2 + (\rho – \rho_0)^2 } \right) \mathrm{d}z $

in order to solve for my expression


Question: The above formula should give Magnetic field of solenoid at any point in space.
Do we have any closed form for the above integral ? Or it's taylor series that could simplify the expression.


Progress:

Edit $(30/03/2022) :$ I have got a lead, we can break $\mathrm{E}(\pi,k)$ into complete elliptical integral as

$$\displaystyle \mathrm{E}(\pi,k) = \mathrm{E}(k) + \mathrm{E}\left(\sqrt{\frac{k^2}{1-k^2}}\right)$$

and using the expansion we will get:

$$\displaystyle \mathrm{E}(\pi,k) = \pi – \frac{\pi}{2} \sum_{n=0}^{\infty} \frac{1}{16^n (2n-1)} {\binom{2n}{n}}^2 \left( k^{2n} + {\left[\frac{k^2}{1-k^2} \right]}^n \right)$$

This does simplify our integrand, but it is still vey complicated to sort out.

Best Answer


Suppose we have a finite continuous solenoid of radius $\rho$ and axial length $L$ where $I$ is the current carried by the wire and $n$ is the number of turns of wire per unit length. For convenience, we place the center of the solenoid at the origin and orient its axis to align with the $z$-axis.

The magnetic field $\vec{B}$ at the point $\vec{r}_{0}$ due to the solenoid is given by the iterated integral

$$\vec{B}{\left(\vec{r}_{0}\right)}=n\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\,\frac{\mu_{0}I}{4\pi}\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\frac{\partial\vec{r}}{\partial\phi}\times\left(\vec{r}_{0}-\vec{r}\right)}{\|\vec{r}_{0}-\vec{r}\|^{3}},$$

where $\vec{r}$ is the position vector for a point with cylindrical coordinates $\left(\rho,\phi,z\right)$ on the surface of the solenoid:

$$\vec{r}=\rho\cos{\left(\phi\right)}\,\hat{x}+\rho\sin{\left(\phi\right)}\,\hat{y}+z\hat{z}.$$

Similarly, the position vector $\vec{r}_{0}$ of a point with cylindrical coordinates $\left(\rho_{0},\phi_{0},z_{0}\right)$ can be written as

$$\vec{r}_{0}=\rho_{0}\cos{\left(\phi_{0}\right)}\,\hat{x}+\rho_{0}\sin{\left(\phi_{0}\right)}\,\hat{y}+z_{0}\hat{z}.$$

A closed-form expression for $\vec{B}{\left(\vec{r}_{0}\right)}$ in terms of complete elliptic integrals is derived below.

For reference, the complete elliptic integrals are defined here as follows:

$$K{\left(\kappa\right)}=\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{1}{\sqrt{1-\kappa^{2}\sin^{2}{\left(\varphi\right)}}};~~~\small{\kappa\in\left(-1,1\right)},$$

$$E{\left(\kappa\right)}=\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\sqrt{1-\kappa^{2}\sin^{2}{\left(\varphi\right)}};~~~\small{\kappa\in\left[-1,1\right]},$$

$$\Pi{\left(\nu,\kappa\right)}=\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{1}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-\kappa^{2}\sin^{2}{\left(\varphi\right)}}};~~~\small{\kappa\in\left(-1,1\right)\land\nu\in\left(-\infty,1\right)}.$$


As you correctly stated above, it can be shown that the distance between the two points in cylindrical coordinates is given by

$$\|\vec{r}_{0}-\vec{r}\|=\sqrt{\left(z_{0}-z\right)^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi_{0}-\phi\right)}}.$$

The expression you gave for the vector quantity $\frac{\partial\vec{r}}{\partial\phi}\times\left(\vec{r}_{0}-\vec{r}\right)$, however, is wrong, so let's go over its calculation in detail.

Recall the cylindrical unit vectors $\hat{\rho}$ and $\hat{\phi}$ may be given in terms of Cartesian unit vectors by

$$\hat{\rho}=\cos{\left(\phi\right)}\,\hat{x}+\sin{\left(\phi\right)}\,\hat{y},$$

$$\hat{\phi}=-\sin{\left(\phi\right)}\,\hat{x}+\cos{\left(\phi\right)}\,\hat{y}.$$

Then, $\vec{r}=\rho\hat{\rho}+z\hat{z}$ and $\frac{\partial\vec{r}}{\partial\phi}=\rho\hat{\phi}$.

Similarly, $\vec{r}_{0}=\rho_{0}\hat{\rho}_{0}+z_{0}\hat{z}$, where the unit vectors $\hat{\rho}_{0}$ and $\hat{\phi}_{0}$ can be expressed as

$$\hat{\rho}_{0}=\cos{\left(\phi_{0}\right)}\,\hat{x}+\sin{\left(\phi_{0}\right)}\,\hat{y},$$

$$\hat{\phi}_{0}=-\sin{\left(\phi_{0}\right)}\,\hat{x}+\cos{\left(\phi_{0}\right)}\,\hat{y}.$$

The above pair of equations can be inverted to give $\hat{x}$ and $\hat{y}$ in terms of $\hat{\rho}_{0}$ and $\hat{\phi}_{0}$:

$$\hat{x}=\cos{\left(\phi_{0}\right)}\,\hat{\rho}_{0}-\sin{\left(\phi_{0}\right)}\,\hat{\phi}_{0},$$

$$\hat{y}=\sin{\left(\phi_{0}\right)}\,\hat{\rho}_{0}+\cos{\left(\phi_{0}\right)}\,\hat{\phi}_{0}.$$

We then find

$$\begin{align} \hat{\rho} &=\cos{\left(\phi\right)}\,\hat{x}+\sin{\left(\phi\right)}\,\hat{y}\\ &=\cos{\left(\phi\right)}\left[\cos{\left(\phi_{0}\right)}\,\hat{\rho}_{0}-\sin{\left(\phi_{0}\right)}\,\hat{\phi}_{0}\right]+\sin{\left(\phi\right)}\left[\sin{\left(\phi_{0}\right)}\,\hat{\rho}_{0}+\cos{\left(\phi_{0}\right)}\,\hat{\phi}_{0}\right]\\ &=\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}-\sin{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0},\\ \end{align}$$

$$\begin{align} \hat{\phi} &=-\sin{\left(\phi\right)}\,\hat{x}+\cos{\left(\phi\right)}\,\hat{y}\\ &=-\sin{\left(\phi\right)}\left[\cos{\left(\phi_{0}\right)}\,\hat{\rho}_{0}-\sin{\left(\phi_{0}\right)}\,\hat{\phi}_{0}\right]+\cos{\left(\phi\right)}\left[\sin{\left(\phi_{0}\right)}\,\hat{\rho}_{0}+\cos{\left(\phi_{0}\right)}\,\hat{\phi}_{0}\right]\\ &=\sin{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}+\cos{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}.\\ \end{align}$$

and thus,

$$\begin{align} \hat{\phi}\times\left(\vec{r}_{0}-\vec{r}\right) &=\hat{\phi}\times\left(\rho_{0}\hat{\rho}_{0}+z_{0}\hat{z}-\rho\hat{\rho}-z\hat{z}\right)\\ &=\hat{\phi}\times\left[\left(z_{0}-z\right)\hat{z}-\rho\hat{\rho}+\rho_{0}\hat{\rho}_{0}\right]\\ &=\left(z_{0}-z\right)\hat{\phi}\times\hat{z}-\rho\hat{\phi}\times\hat{\rho}+\rho_{0}\hat{\phi}\times\hat{\rho}_{0}\\ &=\left(z_{0}-z\right)\hat{\rho}+\rho\hat{z}-\rho_{0}\hat{\rho}_{0}\times\hat{\phi}\\ &=\left(z_{0}-z\right)\left[\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}-\sin{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}\right]+\rho\hat{z}\\ &~~~~~-\rho_{0}\hat{\rho}_{0}\times\left[\sin{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}+\cos{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}\right]\\ &=\left(z_{0}-z\right)\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}-\left(z_{0}-z\right)\sin{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}+\rho\hat{z}\\ &~~~~~-\rho_{0}\sin{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}\times\hat{\rho}_{0}-\rho_{0}\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}\times\hat{\phi}_{0}\\ &=\left(z_{0}-z\right)\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}-\left(z_{0}-z\right)\sin{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}+\rho\hat{z}\\ &~~~~~-\rho_{0}\cos{\left(\phi_{0}-\phi\right)}\,\hat{z}\\ &=\left(z_{0}-z\right)\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}-\left(z_{0}-z\right)\sin{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}\\ &~~~~~+\left[\rho-\rho_{0}\cos{\left(\phi_{0}-\phi\right)}\right]\hat{z}.\\ \end{align}$$


We turn now to the calculation of $\vec{B}{\left(\vec{r}_{0}\right)}$ for the solenoid, and we start by simplifying the angular integral.

Given $\vec{r}_{0}\in\mathbb{R}^{3}$ such that $\neg\left[\rho_{0}=\rho\land\left(|z_{0}|\le\frac{L}{2}\right)\right]$, we have

$$\begin{align} \vec{B}{\left(\vec{r}_{0}\right)} &=n\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\,\frac{\mu_{0}I}{4\pi}\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\frac{\partial\vec{r}}{\partial\phi}\times\left(\vec{r}_{0}-\vec{r}\right)}{\|\vec{r}_{0}-\vec{r}\|^{3}}\\ &=\frac{\mu_{0}nI}{4\pi}\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\rho\hat{\phi}\times\left(\vec{r}_{0}-\vec{r}\right)}{\|\vec{r}_{0}-\vec{r}\|^{3}}\\ &=\frac{\mu_{0}nI}{4\pi}\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\rho}{\left[\left(z_{0}-z\right)^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi_{0}-\phi\right)}\right]^{3/2}}\\ &~~~~~\times\bigg{[}\left(z_{0}-z\right)\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}-\left(z_{0}-z\right)\sin{\left(\phi_{0}-\phi\right)}\,\hat{\phi}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi_{0}-\phi\right)}\right]\hat{z}\bigg{]}\\ &=\frac{\mu_{0}nI}{4\pi}\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\rho}{\left[\left(z_{0}-z\right)^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi_{0}-\phi\right)}\right]^{3/2}}\\ &~~~~~\times\bigg{[}\left(z_{0}-z\right)\cos{\left(\phi_{0}-\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi_{0}-\phi\right)}\right]\hat{z}\bigg{]}\\ &=\frac{\mu_{0}nI}{4\pi}\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\rho}{\left[\left(z_{0}-z\right)^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}}\\ &~~~~~\times\bigg{[}\left(z_{0}-z\right)\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]},\\ \end{align}$$

where in the second-to-last line above we used the fact that the $\hat{\phi}_{0}$ component of the angular integral is identically zero because of its $2\pi$-periodic antiderivative, and in the last line above we've used the following lemma: for any $a\in\mathbb{R}$ and any continuous periodic function $f:\mathbb{R}\rightarrow\mathbb{R}$ with period $p\in\mathbb{R}_{>0}$, it can be shown that

$$\int_{0}^{p}\mathrm{d}x\,f{\left(x+a\right)}=\int_{0}^{p}\mathrm{d}x\,f{\left(x\right)}.$$

Then,

$$\begin{align} \vec{B}{\left(\vec{r}_{0}\right)} &=\frac{\mu_{0}nI}{4\pi}\int_{-\frac{L}{2}}^{\frac{L}{2}}\mathrm{d}z\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\rho}{\left[\left(z_{0}-z\right)^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}}\\ &~~~~~\times\bigg{[}\left(z_{0}-z\right)\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]}\\ &=\frac{\mu_{0}nI}{4\pi}\int_{z_{0}-\frac{L}{2}}^{z_{0}+\frac{L}{2}}\mathrm{d}z\int_{0}^{2\pi}\mathrm{d}\phi\,\frac{\rho}{\left[z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}}\\ &~~~~~\times\bigg{[}z\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]};~~~\small{\left[z\mapsto z_{0}-z\right]}\\ &=\frac{\mu_{0}nI}{4\pi}\int_{z_{0}-\frac{L}{2}}^{z_{0}+\frac{L}{2}}\mathrm{d}z\int_{0}^{\pi}\mathrm{d}\phi\,\frac{2\rho}{\left[z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}}\\ &~~~~~\times\bigg{[}z\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]};~~~\small{symmetry}\\ &=B_{0}\int_{z_{-}}^{z_{+}}\mathrm{d}z\int_{0}^{\pi}\mathrm{d}\phi\,\frac{2\rho\bigg{[}z\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]}}{\left[z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}},\\ \end{align}$$

where in the last line above we've set $B_{0}:=\frac{\mu_{0}nI}{4\pi}$ and $z_{\pm}:=z_{0}\pm\frac{L}{2}$.


Now, we could proceed to evaluate the angular integral in terms of elliptic integrals as others have already pointed out, but that would leave us with a very difficult non-elementary axial integral. It turns out, however, that changing the order of integration makes the integral much easier.

Consider the following derivative:

$$\frac{d}{dz}\left[\frac{z\vec{c}-a\vec{b}}{a\sqrt{z^{2}+a}}\right]=\frac{z\vec{b}+\vec{c}}{\left(z^{2}+a\right)^{3/2}};~~~\small{a\in\mathbb{R}_{>0}\land\vec{b}\in\mathbb{R}^{3}\land\vec{c}\in\mathbb{R}^{3}}.$$


Assuming $0<\rho_{0}\neq\rho$, we have $0<\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}$. Also note that $0<\frac{4\rho_{0}\rho}{z^{2}+\left(\rho_{0}+\rho\right)^{2}}<1$ for all real $z$.

Setting $\nu:=\frac{4\rho_{0}\rho}{\left(\rho_{0}+\rho\right)^{2}}\land k_{\pm}:=\sqrt{\frac{4\rho_{0}\rho}{z_{\pm}^{2}+\left(\rho_{0}+\rho\right)^{2}}}$, we then have

$$\begin{align} \vec{B}{\left(\vec{r}_{0}\right)} &=B_{0}\int_{z_{-}}^{z_{+}}\mathrm{d}z\int_{0}^{\pi}\mathrm{d}\phi\,\frac{2\rho\bigg{[}z\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]}}{\left[z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}}\\ &=B_{0}\int_{0}^{\pi}\mathrm{d}\phi\int_{z_{-}}^{z_{+}}\mathrm{d}z\,\frac{2\rho\bigg{[}z\cos{\left(\phi\right)}\,\hat{\rho}_{0}+\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}\bigg{]}}{\left[z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]^{3/2}}\\ &=B_{0}\int_{0}^{\pi}\mathrm{d}\phi\int_{z_{-}}^{z_{+}}\mathrm{d}z\,\frac{d}{dz}\bigg{[}-\frac{2\rho\cos{\left(\phi\right)}\,\hat{\rho}_{0}}{\sqrt{z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}}}\\ &~~~~~+\frac{2z\rho\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}}{\left[\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]\sqrt{z^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}}}\bigg{]}\\ &=B_{0}\int_{0}^{\pi}\mathrm{d}\phi\,\bigg{[}-\frac{2\rho\cos{\left(\phi\right)}\,\hat{\rho}_{0}}{\sqrt{z_{+}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}}}+\frac{2\rho\cos{\left(\phi\right)}\,\hat{\rho}_{0}}{\sqrt{z_{-}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}}}\\ &~~~~~+\frac{2z_{+}\rho\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}}{\left[\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]\sqrt{z_{+}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}}}\\ &~~~~~-\frac{2z_{-}\rho\left[\rho-\rho_{0}\cos{\left(\phi\right)}\right]\hat{z}}{\left[\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}\right]\sqrt{z_{-}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(\phi\right)}}}\bigg{]}\\ &=2B_{0}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\bigg{[}-\frac{2\rho\cos{\left(2\varphi\right)}\,\hat{\rho}_{0}}{\sqrt{z_{+}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(2\varphi\right)}}}\\ &~~~~~+\frac{2\rho\cos{\left(2\varphi\right)}\,\hat{\rho}_{0}}{\sqrt{z_{-}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(2\varphi\right)}}}\\ &~~~~~+\frac{2z_{+}\rho\left[\rho-\rho_{0}\cos{\left(2\varphi\right)}\right]\hat{z}}{\left[\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(2\varphi\right)}\right]\sqrt{z_{+}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(2\varphi\right)}}}\\ &~~~~~-\frac{2z_{-}\rho\left[\rho-\rho_{0}\cos{\left(2\varphi\right)}\right]\hat{z}}{\left[\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(2\varphi\right)}\right]\sqrt{z_{-}^{2}+\rho_{0}^{2}+\rho^{2}-2\rho_{0}\rho\cos{\left(2\varphi\right)}}}\bigg{]};~~~\small{\left[\phi=2\varphi\right]}\\ &=2B_{0}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\bigg{[}\frac{\left[2\rho-4\rho\cos^{2}{\left(\varphi\right)}\right]\hat{\rho}_{0}}{\sqrt{z_{+}^{2}+\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}}}\\ &~~~~~-\frac{\left[2\rho-4\rho\cos^{2}{\left(\varphi\right)}\right]\hat{\rho}_{0}}{\sqrt{z_{-}^{2}+\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}}}\\ &~~~~~+\frac{\left[-\rho_{0}^{2}+\rho^{2}+\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}\right]z_{+}\hat{z}}{\left[\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}\right]\sqrt{z_{+}^{2}+\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}}}\\ &~~~~~-\frac{\left[-\rho_{0}^{2}+\rho^{2}+\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}\right]z_{-}\hat{z}}{\left[\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}\right]\sqrt{z_{-}^{2}+\left(\rho_{0}+\rho\right)^{2}-4\rho_{0}\rho\cos^{2}{\left(\varphi\right)}}}\bigg{]}\\ &=\frac{B_{0}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\bigg{[}\frac{2\rho\left[1-2\cos^{2}{\left(\varphi\right)}\right]k_{+}\hat{\rho}_{0}}{\sqrt{1-k_{+}^{2}\cos^{2}{\left(\varphi\right)}}}-\frac{2\rho\left[1-2\cos^{2}{\left(\varphi\right)}\right]k_{-}\hat{\rho}_{0}}{\sqrt{1-k_{-}^{2}\cos^{2}{\left(\varphi\right)}}}\\ &~~~~~+\frac{\left[-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)+1-\nu\cos^{2}{\left(\varphi\right)}\right]k_{+}z_{+}\hat{z}}{\left[1-\nu\cos^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{+}^{2}\cos^{2}{\left(\varphi\right)}}}\\ &~~~~~-\frac{\left[-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)+1-\nu\cos^{2}{\left(\varphi\right)}\right]k_{-}z_{-}\hat{z}}{\left[1-\nu\cos^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{-}^{2}\cos^{2}{\left(\varphi\right)}}}\bigg{]},\\ \end{align}$$

and finally,

$$\begin{align} \vec{B}{\left(\vec{r}_{0}\right)} &=\frac{B_{0}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\bigg{[}\frac{2\rho\left[1-2\sin^{2}{\left(\varphi\right)}\right]k_{+}\hat{\rho}_{0}}{\sqrt{1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}}}-\frac{2\rho\left[1-2\sin^{2}{\left(\varphi\right)}\right]k_{-}\hat{\rho}_{0}}{\sqrt{1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~+\frac{\left[-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)+1-\nu\sin^{2}{\left(\varphi\right)}\right]k_{+}z_{+}\hat{z}}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~-\frac{\left[-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)+1-\nu\sin^{2}{\left(\varphi\right)}\right]k_{-}z_{-}\hat{z}}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}}}\bigg{]};~~~\small{\left[\varphi\mapsto\frac{\pi}{2}-\varphi\right]}\\ &=\frac{B_{0}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{2\rho\left[1-2\sin^{2}{\left(\varphi\right)}\right]k_{+}\hat{\rho}_{0}}{\sqrt{1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~-\frac{B_{0}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{2\rho\left[1-2\sin^{2}{\left(\varphi\right)}\right]k_{-}\hat{\rho}_{0}}{\sqrt{1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~+\frac{B_{0}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{\left[-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)+1-\nu\sin^{2}{\left(\varphi\right)}\right]k_{+}z_{+}\hat{z}}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~-\frac{B_{0}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{\left[-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)+1-\nu\sin^{2}{\left(\varphi\right)}\right]k_{-}z_{-}\hat{z}}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &=\hat{\rho}_{0}\frac{4B_{0}\sqrt{\rho}}{k_{+}\sqrt{\rho_{0}}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{\left[1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}\right]-\left(1-\frac{k_{+}^{2}}{2}\right)}{\sqrt{1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~-\hat{\rho}_{0}\frac{4B_{0}\sqrt{\rho}}{k_{-}\sqrt{\rho_{0}}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{\left[1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}\right]-\left(1-\frac{k_{-}^{2}}{2}\right)}{\sqrt{1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~+\hat{z}\frac{B_{0}k_{+}z_{+}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{+}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &~~~~~-\hat{z}\frac{B_{0}k_{-}z_{-}}{\sqrt{\rho_{0}\rho}}\int_{0}^{\frac{\pi}{2}}\mathrm{d}\varphi\,\frac{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)}{\left[1-\nu\sin^{2}{\left(\varphi\right)}\right]\sqrt{1-k_{-}^{2}\sin^{2}{\left(\varphi\right)}}}\\ &=\frac{4B_{0}\sqrt{\rho}}{k_{+}\sqrt{\rho_{0}}}\bigg{[}E{\left(k_{+}\right)}-\left(1-\frac{k_{+}^{2}}{2}\right)K{\left(k_{+}\right)}\bigg{]}\hat{\rho}_{0}\\ &~~~~~-\frac{4B_{0}\sqrt{\rho}}{k_{-}\sqrt{\rho_{0}}}\bigg{[}E{\left(k_{-}\right)}-\left(1-\frac{k_{-}^{2}}{2}\right)K{\left(k_{-}\right)}\bigg{]}\hat{\rho}_{0}\\ &~~~~~+\frac{B_{0}k_{+}z_{+}}{\sqrt{\rho_{0}\rho}}\bigg{[}K{\left(k_{+}\right)}-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)\Pi{\left(\nu,k_{+}\right)}\bigg{]}\hat{z}\\ &~~~~~-\frac{B_{0}k_{-}z_{-}}{\sqrt{\rho_{0}\rho}}\bigg{[}K{\left(k_{-}\right)}-\left(\frac{\rho_{0}-\rho}{\rho_{0}+\rho}\right)\Pi{\left(\nu,k_{-}\right)}\bigg{]}\hat{z}.\blacksquare\\ \end{align}$$


Related Question