<s>[INST] Trig substitution for integral of $z/(x^2+z^2)$? So I have an integral $\int_1^4\int_y^4\int_0^z\frac{z}{x^2+z^2}\,dx\,dz\,dy$ but I can't figure out what trig substitution to use on the first step. When I try $z=\cos$ and $x=\sin$, I end up with $\int\cos$ but the book comes up with $z\cdot\frac{1}{z}\cdot\arctan \frac{x}{z}$ so I know I screwed up.
Can someone show me how the book took this step?
Thanks!
 [/INST] The innermost integral is with respect to $x$, treating $z$ as a constant.
Since this is the case, you might as well go with: $$ x = z\tan\theta \implies \text{d}x = z \sec^2\theta \text{ d}\theta \qquad (*)$$ $$ x = 0 \implies \theta = 0, \ x = z \implies \theta = \dfrac{\pi}{4} $$

$$ \int_{0}^{z} \dfrac{z}{x^2+z^2} \text{ d}x = \int_{0}^{\pi/4} \dfrac{z}{z^2 \sec^2\theta} \ z\sec^2\theta \text{ d}\theta = \dfrac{\pi}{4} $$


In the case of the indefinite integral, we have that:

$$ \begin{aligned} \int \dfrac{z}{x^2+z^2} \text{ d}x \ \overset{(*)}= \ \int \dfrac{z}{z^2 \sec^2\theta} \ z\sec^2\theta \text{ d}\theta \ = \int z \dfrac{1}{z} \text{ d}\theta \ & = \ z \dfrac{1}{z} \theta + \mathcal{C} \ = \ z \dfrac{1}{z} \arctan \left( \dfrac{x}{z} \right) + \mathcal{C} \end{aligned} $$

</s>