I have an area integral problem over an irregular convex polygon. I use Green's Theorem to convert the area integral to a contour integral, and solve using standard methods.

Green's Theorem says I can pick any functions $L$, $M$ such that $\left( \frac{\partial M}{\partial x} - \frac{\partial L}{\partial y} \right)$ gives my original integrand. Or, equivalently, to pick any vector function $\mathbf{F}$ such that the divergence $\nabla \cdot \mathbf{F}$ gives the same integrand.

So to check my answer, I picked different functions $L, M$ satisfying this property, expecting to get the same result. However, I get a slightly different result and I am unable to find the source of my error.


Here is the original area integral problem:

$$ \iint_P \frac{ax + by + c}{dx + ey + f} + g \; dx \; dy, $$

where $a$ through $g$ are constants. And here I am specifically considering the case where $d = 0$, i.e.

$$ \iint_P \frac{ax + by + c}{ey + f} + g \; dx \; dy. $$

The polygon $P$ is comprised of $N$ vertices $\mathbf{v}_i, i=1..N$.

First solution

In the first attempt, I chose the function $$F_x = \frac{ax^2/2 + bxy + cx}{ey+f} + gx, F_y = 0.$$

I substituted these functions into Green's Theorem to get the contour integral, and substituted for the variables $x, y$ the parametric forms, $v_{ix} + t \Delta_{ix}, v_{iy} + t \Delta_{iy}$, where $\Delta = v_{i+1} - v_{i}$:

$$ \iint_P \frac{ax + by + c}{dx + ey + f} + g \; dx \; dy = \iint_P \nabla \cdot \mathbf{F} \; dx \; dy = \oint_P \mathbf{F}.[dy, -dx] $$ $$ = \sum_{i=1}^{N} \int_0^1 \mathbf{F}(t).[\Delta_{iy}, -\Delta_{ix}] \; dt.$$

This leads to a form like $$\iint_P = \sum_{i=1}^N \int_0^1 \frac{\alpha t^2 + \beta t + \gamma}{\delta t + \epsilon} + g \Delta_{iy}(\Delta_{ix} t + v_{ix}) \; dt, $$

for other constants $\alpha$ through $\gamma$, and where $v_{N+1} := v_1$.

Solving this definite integral gives the solution

$$\sum_{i=1}^N \frac{\alpha + 2\beta}{2\delta} - \frac{\alpha \epsilon}{\delta^2} + g \Delta_{iy}(v_{ix} + \frac{\Delta_{ix}}{2}) + (\frac{\gamma}{\delta} - \frac{\beta \epsilon}{\delta^2} + \frac{\alpha \epsilon^2}{\delta^3}) \ln(1 + \frac{\delta}{\epsilon}), $$

for $\delta \neq 0$.

Second solution

Here I picked a different function $F$ to check my solution:

$$F_x = \frac{bxy + cx}{ey + f} + gx, F_y = \frac{ax}{e} \ln(ey + f).$$

Following the same procedure, this results in a slightly different answer. Specifically the terms that are linear in the constants all match, but the log terms do not.

I cannot see that the two solutions agree, nor can I find any error in my working. Help at this point is appreciated.

EDIT: Parameterization and closed curve

OK, I will try to be explicit about the parameterization.

Let $P$ be a polygon specified by $N$ vertices $v_1, v_2, ..., v_N$, ordered counter-clockwise. For notational convenience, let $v_{N+1} := v_1$.

Let the $i$th segment of the polygon be parameterized with the linear interpolation $\mathbf{p}(t) = (x(t), y(t)) = \mathbf{v}_i + t (\mathbf{v}_{i+1} - \mathbf{v}_i) = \mathbf{v}_i + \mathbf{\Delta}_i t, t \in [0, 1].$

Then a function $g(x, y)$ can be integrated along the positively oriented closed polygon boundary $\partial P$ as:

$$ \oint_{\partial P} g(x, y) = \sum_{i=1}^N \int_0^1 g(x(t), y(t)) dt$$.

You can see the curve is closed because all $N$ segments are being used and $v_{N+1}$ is defined as $v_1$.

EDIT: Detail of differences in solutions

Both solutions involve terms in $\ln(ev_{i+1y}+f)$, but the coefficients of this term disagree between my two solutions.

For the second solution I get a coefficient that includes the additional term $-\frac{a}{2e}v_{i+1x}^2$, which does not appear in the first solution. All other terms of this coefficient agree.

    Term1[i_, t_, x_, y_] := ((b (x[[i]] + t dx[i]) (y[[i]] + t dy[i]) + 
        c (x[[i]] + t dx[i]))/(e (y[[i]] + t dy[i]) + f) + 
       g (x[[i]] + t dx[i])) dy[i] - (a dx[i] (x[[i]] + t dx[i]))/
     e Log[e (y[[i]] + t dy[i]) + f] /. 
   dx[i] -> (x[[i + 1]] - x[[i]]) /. dy[i] -> (y[[i + 1]] - y[[i]])

Term2[i_, t_, x_, y_] := ((a ((x[[i]] + t dx[i]))^2/2 + 
       b (x[[i]] + t dx[i]) (y[[i]] + t dy[i]) + 
       c (x[[i]] + t dx[i]))/(e (y[[i]] + t dy[i]) + f) + 
      g (x[[i]] + t dx[i])) dy[i] /. 
   dx[i] -> (x[[i + 1]] - x[[i]]) /. dy[i] -> (y[[i + 1]] - y[[i]])

Integdand1[t_, N_, x_, y_] := \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(N\)]\((Term1[i, t, x, y

Integdand2[t_, N_, x_, y_] := \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(N\)]\((Term2[i, t, x, y])\)\)

You can try Triangle (0,0),(1,0),(0,1)

x = {0, 1, 0, 0}
y = {0, 0, 1, 0}
IntegrandTriangle = Integdand2[t, 3, x, y] - Integdand1[t, 3, x, y] // FullSimplify

\*SubsuperscriptBox[\(\[Integral]\), \(0\), \
\(1\)]\(\((IntegrandTriangle)\) \[DifferentialD]t\)\)

Rectangle (0,0),(1,0),(1,1),(0,1)

x = {0, 1, 1, 0, 0}
y = {0, 0, 1, 1, 0}
IntegrandRectangle = Integdand2[t, 4, x, y] - Integdand1[t, 4, x, y] // FullSimplify

\!\(\*SubsuperscriptBox[\(\[Integral]\), \(0\), \
\(1\)]\(\((IntegrandRectangle)\) \[DifferentialD]t\)\)
  • $\begingroup$ Thank you again. Unfortunately I don't have a copy of Mathematica to run. Does it report what is the result of integrating the ith term in the sum? I am still banging my head against this problem as I still get very slightly different results from the integration with the two different methods. $\endgroup$ – Powers of Two Nov 22 '15 at 19:42
  • $\begingroup$ well it cries that you have to take such and such assumptions etc, but for the triangle and square and even trapeze $(0,0),(2,0), (3,5),(0,6) in first quadrant it works, shows 0. Since this works in first quadrant I would say you done, ... up to scaling and shifting. $\endgroup$ – Michael Medvinsky Nov 22 '15 at 20:47
  • $\begingroup$ When I try to to exit the first quadrant I get things like $\ln a+\ln (-a)$ which is of course cannot be defined in reals. The theorem states that $M,L$ should have continuous partial derivatives. So the only condition to require that I can see is $ey+f>0$. When I try to add negative $x$ the code above, i.e. $\int A-B dt$, doesn't work well, i.e. for some reason it shows the nonsense with the $\ln$'s. However if you integrate them separately and compare you get the same result,i.e. $\int A dt=\int B dt$ which confirms that the only requirement is to have $ey +f>0$ $\endgroup$ – Michael Medvinsky Nov 22 '15 at 20:50
  • $\begingroup$ I'm trying to run this code in a trial version of Mathematica Online. But it is not parsing correctly for me; e.g. the lines with the definitions of Integdand1, Integdand2. I posted another question here: math.stackexchange.com/questions/1542945/… $\endgroup$ – Powers of Two Nov 23 '15 at 16:03
  • 1
    $\begingroup$ Summing the differences between the two methods around the polygon gives: $$ \sum_{i=1}^N \frac{a v_{ix}^2}{2e} \ln(e v_{iy}+ f) - \frac{a v_{i+1,x}^2}{2e} \ln(e v_{i+1,y}+f)$$ $$= 0.$$ $\endgroup$ – Powers of Two Nov 24 '15 at 14:17

I think the reason you get a mistake is due to wrong sign in $F_y$ in second solution, perhaps not only, but I didn't try to follow. Hopefully the following helps.

In following example we consider rectangular domain $$P=[\alpha,\beta]\times[\gamma,\delta],$$ the extension to more general polygon is analogous.

The arrows in the line integrals denotes the counter clock walking along the boundary curve lines starting from bottom left corner. Note also the notation $dx$ along a fixed $x=x_0$ is denoted as $dx_0=0$.

Green's theorem $$\oint_{\partial P} (L\, dx + M\, dy) = \iint_{P} \left(\frac{\partial M}{\partial x} - \frac{\partial L}{\partial y}\right)\, dx\, dy$$

Problem $$\iint_P \frac{ax + by + c}{ey + f} + g \; dx \; dy.$$

Zero Solution $$(1) \;\iint_P \frac{ax + by + c}{ey + f} + g \; dx \; dy= \int_\gamma^\delta \frac{a x^2}{2 (e y+f)}+\frac{x (b y+c)}{e y+f}+g x\Bigg|_{x=\alpha}^\beta\;dy =\frac{1}{2} x \left(\frac{\ln (e y+f) (a e x-2 b f+2 c e)}{e^2}+\frac{2 y (b+e g)}{e}\right)\Bigg|_{x=\alpha}^\beta \Bigg|_{y=\gamma}^\delta$$ similarly $$(2)\;\iint_P \frac{ax + by + c}{ey + f} + g \; dx \; dy =\iint_P \frac{ax + by + c}{ey + f} + g \; dy \; dx \quad\\= \int_\alpha^\beta\frac{\ln (e y+f) (a e x-b f+c e)}{e^2}+\frac{b y}{e}+g y \Bigg|_{y=\gamma}^\delta \;dx \quad= \frac{1}{2} x \left(\frac{\ln (e y+f) (a e x-2 b f+2 c e)}{e^2}+\frac{2 y (b+e g)}{e}\right) \Bigg|_{y=\gamma}^\delta \Bigg|_{x=\alpha}^\beta $$

First Solution $$M(x,y) = \frac{ax^2/2 + bxy + cx}{ey+f} + gx,\\ L(x,y)= 0$$

$$\iint_P \frac{ax + by + c}{ey + f} + g \; dx \; dy = \oint_{\partial P} 0\, dx + M\, dy=\\ \oint_{\rightarrow} M(x,\gamma)\, d\gamma+ \oint_{\uparrow} M(\beta,y)\, dy+ \oint_{\leftarrow} M(x,\delta)\, d\delta+ \oint_{\downarrow} M(\alpha,y)\, dy \\ =\oint_{\uparrow} M(\beta,y)\, dy+ \oint_{\downarrow} M(\alpha,y)\, dy= \oint_{\uparrow} M(\beta,y)\, dy- \oint_{\uparrow} M(\alpha,y)\, dy\\= \int_\gamma^\delta \frac{a x^2}{2 (e y+f)}+\frac{x (b y+c)}{e y+f}+g x\Bigg|_{x=\alpha}^\beta\;dy=(1)$$

Second Solution $$M = \frac{bxy + cx}{ey + f} + gx, \\ L = -\frac{ax}{e} \ln(ey + f).$$

$$ %comment \oint_{\partial P} (L\, dx + M\, dy)=\\ \oint_{\rightarrow} L(x,\gamma)dx + M(x,\gamma)\, d\gamma+ \oint_{\uparrow} L(\beta,y)d\beta + M(\beta,y)\, dy\\+ \oint_{\leftarrow} L(x,\delta)dx + M(x,\delta)\, d\delta+ \oint_{\downarrow} L(\alpha,y)d\alpha + M(\alpha,y)\, dy\\ = \oint_{\rightarrow} L(x,\gamma)dx + \oint_{\uparrow} M(\beta,y)\, dy+ \oint_{\leftarrow} L(x,\delta)dx + \oint_{\downarrow} M(\alpha,y)\, dy\\ = \oint_{\uparrow} M(\beta,y)-M(\alpha,y)\, dy+ \oint_{\leftarrow} L(x,\delta) - L(x,\gamma)\,dx \\ = \iint_P \frac{\partial M}{\partial x}\,dx\, dy -\iint_P \frac{\partial L}{\partial y}\,dy\, dx = \iint_P \frac{ax + by + c}{ey + f} + g \; dx \; dy$$

  • $\begingroup$ Thank you very much for your detailed answer. I am checking through very carefully to see if this resolves the discrepancy I was seeing. $\endgroup$ – Powers of Two Nov 20 '15 at 11:26
  • $\begingroup$ This all makes sense, and I get the same result for this simplified case. Maybe my problem is in the parameterization of the polygon. Using the notation above, I write: $$\iint_P \frac{\partial M}{\partial x} - \frac{\partial L}{\partial y} dx dy = \oint_{\partial P} L dx + M dy $$ $$=\sum_{i=1}^N \int_0^1 L(t) \frac{dx}{dt} + M(t) \frac{dy}{dt} dt$$ $\endgroup$ – Powers of Two Nov 20 '15 at 12:22
  • $\begingroup$ $$=\sum_{i=1}^N \int_0^1 L(t) \Delta_{ix} + M(t) \Delta_{iy} dt $$ $$=\sum_{i=1}^N \int_0^1 \Delta_{iy} \left(\frac{bx(t)y(t) + cx(t)}{ey(t)+f} + gx(t) \right) - \Delta_{ix} \left( \frac{a}{e}x(t) \ln(ey(t)+f) \right) dt $$ $\endgroup$ – Powers of Two Nov 20 '15 at 12:28
  • $\begingroup$ $$= \sum_{i=1}^N \int_0^1 \frac{\alpha t^2 + \beta t + \gamma}{ey(t) + f} + g \Delta_{iy} x(t) - \frac{a \Delta_{ix} x(t)}{e} \ln(e y(t) + f) dt $$ $\endgroup$ – Powers of Two Nov 20 '15 at 12:37
  • 1
    $\begingroup$ please write your parameterization explicitly and make sure you have a closed curve. This is essential that the curve is closed. This is true that contour integral is independent of the parameterization and also true that you can parameterize for $0\le t \le1$ but I fall to see the directions and closeness of the curve in your notes. $\endgroup$ – Michael Medvinsky Nov 20 '15 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.