Having two current carrying (currents $I'$ and $I$) wires of length $a$ parallel to the $z$-axis, one with end points $(0,0,0)$ and $(0,0,a)$ and one from $(a,0,0)$ to $(a,0,a)$, I'm looking for the force on the second one due to the first one. Here is my problem:
I know I'm suppose to get (which I get by finding the magnetic field,...) $F=\frac{\mu_0II'}{2\pi a}a$ but I also know that I can compute this with the formula $F=\frac{-\mu_0II'}{4\pi a}\int_0^a\int_0^a (dr'.dr) \frac{(r'-r)}{|r'-r|^3}$ where $r$ and $r'$ are along the wires. When I tried, I got rid of the absolute value by separating the second integral in two parts : $\int_0^r$ and $\int_r^a$. But I don't get anywhere near the solution! Can you help me?
Let $\mathbf r=(0,0,z)$ and $\mathbf r'=(a,0,z')$.
Then
$d\mathbf r=(0,0,dz)\;$ and $\;d\mathbf r'=(a,0,dz')$
$d\mathbf r \cdot d\mathbf r'=dz\, dz'$
$\mathbf r' - \mathbf r=(a,0,z'-z)$
$|\mathbf r' - \mathbf r|=\sqrt {a^2+(z'-z)^2}$
Consider the force exerted by the first segment$$\mathbf F=-\frac {\mu_0 II'}{4\pi}\int_0^a \int_0^a \frac {\mathbf r' - \mathbf r}{\;\;|\mathbf r' - \mathbf r|^3} \,d\mathbf r \cdot d\mathbf r'$$ By simmetry, $F_y$ and $F_z$ are null.
One has $$F_x=-\frac {\mu_0 II'}{4\pi}\int_0^a \int_0^a \frac a{\left[a^2+(z'-z)^2 \right]^{\frac 32}} dz\, dz'$$Now$$\int_0^a \frac a{\left[a^2+(z'-z)^2 \right]^{\frac 32}} dz' =\frac 1a \left[\frac z{\sqrt{a^2+z^2}} + \frac {a-z}{\sqrt {a^2+(a-z)^2}}\right]$$so $$F_x=-\frac {\mu_0 II'}{2\pi}(\sqrt 2 -1)$$ See E.B.Moullin The Principles of Electromagnetism (1950) pp. 37-38 as a reference.
Note: your supposed result is valid if a wire is much longer than the other.