Your question was closed because... well...it is unclear.
- You do not specify what $r$ is and instead you expect the readers to divine it for you. To be specific how can you expect someone who was not present at the lecture to
provide some context about how you would find $\hat r$ and $r$?
- What is the problem here? Is it the integration?
- You claim
For the most part, it's just a big QED, because it's calculus, not electromagnetism.
I don’t understand what that means. You have an integral to evaluate hence it is a calculus problem.
- What do you mean by QED? Quid est demonstratum (which I presume must be right) or quantum electrodynamics?
- What are $X$, $Y$ and $Z$?
To be blunt this is a simple example, and this or similar are found in many textbooks. Did you consult any of them?