# Calculus

## Green Formula

Let \Omega be a non-empty open of \mathbb{R}^d, denote \partial\Omega its boundary. Denote \mathbf{n} the local normal to \partial\Omega.

We have the following properties called Green formulas which are simply special cases of integration by parts. Let \mathbf{e}_k is the unit vector in the direction x_k, u,v be scalar fields and \mathbf{E} be a vector field.

\int_\Omega \frac{\partial u}{\partial x_k}\; v\; dx = - \int_\Omega u \; \frac{\partial v}{\partial x_k} \; dx + \int_{\partial \Omega} u\, v \; (\mathbf{e}_k \cdot \mathbf{n})\; ds

\int_\Omega \Delta u \; v\; dx = - \int_\Omega \nabla u \cdot \nabla v \; dx + \int_{\partial \Omega} \frac{\partial u}{\partial n}\, v \; ds

\int_\Omega u \; \nabla \cdot \mathbf{E} \; dx = - \int_\Omega \nabla u \cdot \mathbf{E} \; dx + \int_{\partial \Omega} u \; (\mathbf{E} \cdot \mathbf{n})\; ds

## Change of variables in integrals

Let \hat{K} and K be two open set of \mathbb{R}^d. Let \varphi be a {\cal C}^1-diffeomorphism from \hat{K} to K, i.e. a bijection of class {\cal C}^1 whose reciprocal is also of class {\cal C}^1. Denote (e_1,\ldots,e_d) the canonical basis of \mathbb{R}^d.

We have

\varphi : \hat{x}=\sum_{i=1}^d \hat{x}_i \, e_i \; \longrightarrow \; \varphi(\hat{x}) = \sum_{i=1}^d \varphi_i(\hat{x}_1,\ldots,\hat{x}_d) \, e_i

The jacobian matrix of \varphi at a point \hat{x}, denote J_\varphi(\hat{x}) is the matrix of size d\times d such that its entries read:

\left( J_\varphi(\hat{x}) \right)_{ij} = \frac{\partial \varphi_i}{\partial \hat{x}_j}(\hat{x}_1,\ldots,\hat{x}_d) \qquad 1\le i,j \le d

We have the following formula for the change of variable to compute an integral over K as an integral over \hat{K}

\int_K u(x)\; dx = \int_{\hat{K}} u(\varphi(\hat{x}))\; \left| \mathrm{det} J_\varphi(\hat{x}) \right| \; d\hat{x}

 In the finite element method we have often to compute integrals using change of variables of the type \int_K Hu(x)\; dx, where H is an operator (gradient, laplacian, …​). You then have to use to be careful when applying the change of variables.

$$\begin{eqnarray*} \int_K (\nabla u(x))^2\; dx & = & \int_K \left[ \left(\frac{\partial u(x,y)}{\partial x} \right)^2 + \left(\frac{\partial u(x,y)}{\partial y} \right)^2 \right]\; dx\; dy \\ & = & \int_{\hat{K}} \left[ \left(\frac{\partial u(F(\hat{x},\hat{y}))}{\partial x} \right)^2 \left(\frac{\partial u(F(\hat{x},\hat{y}))}{\partial y} \right)^2 \right] \left| \hbox{det} J_F(\hat{x}) \right| \; \; d\hat{x}\, d\hat{y}\\ & = & \int_{\hat{K}} \left[ \left(\frac{\partial u(F(\hat{x},\hat{y}))}{\partial \hat{x}} \; \frac{\partial \hat{x}}{\partial x} + \frac{\partial u(F(\hat{x},\hat{y}))}{\partial \hat{y}} \; \frac{\partial \hat{y}}{\partial x} \right)^2 \right.\\ & & \qquad \left. \left(\frac{\partial u(F(\hat{x},\hat{y}))}{\partial \hat{x}} \; \frac{\partial \hat{x}}{\partial y} + \frac{\partial u(F(\hat{x},\hat{y}))}{\partial \hat{y}} \; \frac{\partial \hat{y}}{\partial y} \right)^2 \right] \left| \hbox{det} J_F(\hat{x}) \right| \; \; d\hat{x}\, d\hat{y} \end{eqnarray*}$$

\int_{\hat{K}} \left[ \left(\frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{x}} \; \frac{\partial \hat{x}}{\partial x} + \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{y}} \; \frac{\partial \hat{y}}{\partial x} \right)^2 + \left(\frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{x}} \; \frac{\partial \hat{x}}{\partial y} + \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{y}} \; \frac{\partial \hat{y}}{\partial y} \right)^2 \right] \left| \hbox{det} J_F(\hat{x}) \right| \; \; d\hat{x}\, d\hat{y}

In the case the transformation F is affine, for example

\left\{ \begin{array}{lll} x & = & a\hat{x} + b\hat{y} + e\\ y & = & c\hat{x} + d\hat{y} + f \end{array} \right.

we have

\begin{aligned} \hat{x} &= \frac{d(x-e)-b(y-f)}{D},\\ \hat{y} &= \frac{-c(x-e)+a(y-f)}{D},\\ \left| \hbox{det} J_F(\hat{x}) \right| &= D = ad-bc \end{aligned}

The previous calculus becomes

\begin{aligned} \int_K (\nabla u(x))^2\; dx &= \int_{\hat{K}} \left[ \left(\frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{x}} \; \frac{d}{D} + \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{y}} \; \frac{-c}{D} \right)^2 \left(\frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{x}} \; \frac{-b}{D} + \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{y}} \; \frac{a}{D} \right)^2 \right] |D| \; \; d\hat{x}\, d\hat{y}\\ & = \frac{1}{|D|}\; \int_{\hat{K}} \left[ \left( d\, \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{x}} - c\, \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{y}} \right)^2 \left(-b\, \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{x}} \; + a\, \frac{\partial \hat{u}(\hat{x},\hat{y})}{\partial \hat{y}} \right)^2 \right] \; \; d\hat{x}\, d\hat{y} \end{aligned}

### Some change of variable formulas

Denote f: K \mapsto \mathbb{R} and \hat{f}: \hat{K} \mapsto \mathbb{R} such that \hat{f} = f \circ F and \mathbf{F}: K \mapsto \mathbb{R}^d and \mathbf{\hat{F}}: \hat{K} \mapsto \mathbb{R}^d such that \hat{\mathbf{F}} = \mathbf{F} \circ \chi^e.

Moreover denote \mathbf{n} the local outward normal to \Omega and \mathbf{n} the local outward normal to \hat{\Omega}.

we have the following relations

\begin{aligned} \int_{K} \ f\ dx\ &= \int_{\hat{K}} f( \chi^e(\xi) ) J^e( \xi )\ d \xi \ =\ \int_{\hat{K}} \hat{f}(\xi) J^e( \xi )\ d \xi\\ \int_{K}\ \nabla f\ dx\ &=\ \int_{\hat{K}} \Big(\nabla^{\text{st}} \underbrace{\hat{f}(\xi)}_{f \circ \chi^e(\xi)} B^e(\xi)\Big) J^e( \xi )\ d \xi\\ \int_{\partial K}\ f( x )\ dx &= \int_{\partial \hat{K}} \hat{f}(\xi)\ \| Be(\xi)T \ \mathbf{n^{\text{st}}}(\xi) \|\ J^e( \xi )\ d \xi\\ \int_{\partial K}\ \mathbf{F}( x )\ \cdot\ \mathbf{n}(x) dx & = \int_{\partial \hat{K}} \mathbf{\hat{F}}( \xi )\ \cdot \Big(Be(\xi)T \ \mathbf{n^{\text{st}}}(\xi) \Big) \ J^e( \xi )\ d \xi \end{aligned}