3

I have the following exercise: Evaluate the multivariate integral $$\int_Af(\boldsymbol x)\,\mathrm d\boldsymbol x$$ numerically, where $f:\mathbb R^p\to\mathbb R$ is a known function and $A := \{\boldsymbol x\in\mathbb R^p : \Vert \boldsymbol x\Vert_2 < C\}$ for some constant $C>0$.

I have an integration routine for multivariate integrals of the form $$\int_{\underline v_1}^{\overline v_1}\int_{\underline v_2}^{\overline v_2}\,\cdots\,\int_{\underline v_p}^{\overline v_p}f(\boldsymbol x)\,\mathrm dx_p\cdots\mathrm dx_2\,\mathrm dx_1.$$ This routine integrates over rectangles, but $A$ is a ball in $\mathbb R^p$.

My idea was therefore a change of variables: Define a function $\Phi:\mathbb R^p\to\mathbb R^p$ by $\Phi(\boldsymbol u) = \boldsymbol x$ such $$\begin{align*} x_1 &= r\cos(\varphi_1)\\ x_2 &= r\sin(\varphi_1)\cos(\varphi_2)\\ &\vdots\\ x_{p-1} &= r\sin(\varphi_1)\sin(\varphi_2)\cdots\sin(\varphi_{p-2})\cos(\varphi_{p-1})\\ x_p &= r\sin(\varphi_1)\sin(\varphi_2)\cdots\sin(\varphi_{p-2})\sin(\varphi_{p-1}). \end{align*}$$ Then it should hold that $$\int_Af(\boldsymbol x)\,\mathrm d\boldsymbol x = \int_0^C\int_0^{\pi}\cdots\int_0^{\pi}\int_0^{2\pi}f\big(\Phi(\boldsymbol u)\big)\vert\operatorname{det}\mathrm D\Phi(\boldsymbol u)\vert\,\mathrm d\boldsymbol u,$$ right? Here $\boldsymbol u = (r, \varphi_1, \varphi_2, \dots, \varphi_{p-1})$ and $\vert\operatorname{det}\mathrm D\Phi(\boldsymbol u)\vert\ = r^{p-1}\prod_{k=1}^{p-2}\vert\sin(\varphi_{p-k})^{k-1}\vert$.

If the above is correct, are there efficient ways to implement this procedure?

0 Answers0