# Question about Divergence formula derivation posted a while ago

As a new user, I am not allowed to comment on someone else's answer to a question. My only choice was to ask a new question about an old answer to a question.

User @Kcronix mentioned, in this question, that the divergence of an arbitrary vector field can be derived as the net flux through the boundary of a region $$R$$: $$\text{net flux}=\oint_{\partial \text{Rect}} \vec{V}\cdot \hat{n}\;\mathbb{d}s=\int_{R} \vec{V}\cdot \hat{n}\;\mathbb{d}s+\int_{L} \vec{V}\cdot \hat{n}\;\mathbb{d}s+\int_{T} \vec{V}\cdot \hat{n}\;\mathbb{d}s+\int_{B} \vec{V}\cdot \hat{n}\;\mathbb{d}s$$

I have tried to define the same situation in a notebook and I figured that going counter-clockwise through the sides of the rectangle would be a good idea. So it would be simply rearranged in my case: $$\text{net flux}=\oint_{\partial \text{Rect}} \vec{V}\cdot \hat{n}\;\mathbb{d}s=\int_{B} \vec{V}\cdot \hat{n}\;\mathbb{d}s+\int_{R} \vec{V}\cdot \hat{n}\;\mathbb{d}s+\int_{T} \vec{V}\cdot \hat{n}\;\mathbb{d}s+\int_{L} \vec{V}\cdot \hat{n}\;\mathbb{d}s$$

Thus, I defined my top flux as: $$\int_{T} \vec{V}\cdot \hat{n}\;\mathbb{d}s=\int_{x+\Delta x}^{x} \left(M(X,y+\Delta y)\hat i+N(X,y+\Delta y)\hat j\right)\cdot \hat j\;\mathbb{d}X=\int_{x+\Delta x}^{x}N(X,y+\Delta y)\;\mathbb{d}X$$

Please, notice how the integral goes from $$x+\Delta x$$ to $$x$$, instead of going from $$x$$ to $$x+\Delta x$$. This also happens to occur with the left side of the rectangle, going from $$y+\Delta y$$ to $$y$$, instead of $$y$$ to $$y+\Delta y$$.

This is my main question with this derivation. I know I can switch the boundaries of the integral by bringing a negative sign outside of it (from the Fundamental Theorem of Calculus), but still, I would get: $$\text{net flux}=\int_{y}^{y+\Delta y}M(x+\Delta x,Y)\;\mathbb{d}Y+\int_{y}^{y+\Delta y}M(x,Y)\;\mathbb{d}Y\\-\int_{x}^{x+\Delta x}N(X,y+\Delta y)\;\mathbb{d}X-\int_{x}^{x+\Delta x}N(X,y)\;\mathbb{d}X\tag{1}$$ and I do not think I can reduce to the partial derivative definition with the above.

Is there anything I am missing?

As my first answer there is a high likelihood that I have made a mistake somewhere.

However, I believe the issue here is that you have not transitioned from a line integral to a definite integral correctly.

To make this transition, you must first choose a paramaterisation of the segment $$T$$, and then you need to employ the definition of a line integral, which is:

$$\int_C f(\boldsymbol{r})ds=\int_a^b f(\boldsymbol{r}(t))|\boldsymbol{r}^\prime(t)|dt$$

The paramaterisation can be created in many ways, but I will simply create the following: $$\boldsymbol{r}(t)=(t, y+\Delta y)$$

To bijectively map to the curve ("segment") $$T$$, this requires that the function $$\boldsymbol{r}$$ should be defined as:

$$\boldsymbol{r} : [x,x+\Delta x]\to T$$

For this paramaterisation, $$|\boldsymbol{r}^\prime(t)|=|(0,1)|=1$$,

Therefore, the line integral written in terms of a definite integral (with our chosen paramaterisation) has the particularly simple form:

$$\int_T f(\boldsymbol{r})ds=\int_x^{x+\Delta x} f(\boldsymbol{r}(t))\; \text{d}t$$

Since $$t$$ is a "dummy" variable, I chose to write it as "X" instead, since it more accurately corresponds with intuition.

Note: The function $$f:T\to\mathbb{R}$$ is defined by $$\boldsymbol{\alpha}\mapsto\vec{V}(\boldsymbol{\alpha})\cdot \hat{n}(\boldsymbol{\alpha})=N(t, y+\Delta y)$$ for all $$\boldsymbol{\alpha}\in T$$. The expression in terms of $$t$$, always holds for some $$t\in[x,x+\Delta x]$$, by def. of the bijection $$\boldsymbol{r}(t)$$. The dot product with the normal vector is described in my previous answer to the other question. Putting this all together we have the following relationship between line integral over $$T$$ and definite integral over $$[x,x+\Delta x]$$:

$$\int_T f\; \text{d}s=\int_T \vec{V}\cdot \hat{n}\; \text{d}s=\int_x^{x+\Delta x} N(X, y+\Delta y)\; \text{d}X$$

You can create a paramaterisation such that you move from right to left as the parameter increases (as you desired). However, this will not change the result of the line integral, it will only look different, with a different differential and integration bounds.

Lastly, if you consider the bottom segment $$B$$ and paramaterise in the same fashion, you obtain:

$$\boldsymbol{r}_B : [x,x+\Delta x]\to B$$

Where the map is defined by:

$$\boldsymbol{r}_B(t)=(t, y)$$ Same as before, $$|\boldsymbol{r}_B^\prime(t)|=1$$.

The negative sign out the front of this integral will come solely from the opposite directions in $$\hat{n}=-\hat{j}$$ and $$\vec{V}$$ along $$B$$.

In detail, the function $$f_B:B\to\mathbb{R}$$ (commonly written as $$f$$, by abuse of notation, but intuitively clear) is defined as:

$$\boldsymbol{\alpha}\mapsto f_B(\boldsymbol{\alpha})=\vec{V}(\boldsymbol{\alpha})\cdot \hat{n}(\boldsymbol{\alpha})=(M(t,y)\hat{i}+N(t, y)\hat{j})\cdot -\hat{j}=-N(t,y)$$

For some $$t\in[x,x+\Delta x]$$ that corresponds bijectively to $$\alpha\in B$$ by the bijection $$\boldsymbol{r}_B$$. It is very natural to just define $$f_{B□}:[x, x+\Delta x]\to\mathbb{R}$$ (typically just written as $$f$$, by abuse of notation), which is the composition $$f_{□B}:=f_B\circ \boldsymbol{r_B}$$.

Hence, the final integral for the bottom segment is:

$$\int_B f\; \text{d}s=\int_B \vec{V}\cdot \hat{n}\; \text{d}s=-\int_x^{x+\Delta x} N(X, y)\; \text{d}X$$

The same principle can be applied to properly convert the left and right segments' line integrals into definite integrals.

Remark: You may have noticed that there is something strange happening at the corners of the rectangle: "the normal vector is undefined at corners of this rectangle boundary". However, this does not affect the integral, as the value of an integral "ignores" undefined values/discontinuities. This is true so long as there are only finitely many points like this, i.e. the set of them is of measure zero.

• Thanks, @Kcronix! You have clarified it a lot to me. I would like to know if you can get to the same result if you consider the curve $\vec{s}(t) = r\cos(t)\hat{i} + r\sin(t)\hat{j}$, on the interval $[0, 2\pi]$. May 17, 2021 at 18:52