I need to integrate a function along the edge of a quadrilateral (boundary integral). For example, the function is $f(x,y)=x^3+y^3$, the quadrilateral coordinates are $(0,0),(2,-1),(3,2),(1,3)$ and the concerned edge is the line joining $(2,-1)$ and $(3,2)$. So, the required integral is $$I=\int_{(2,-1)}^{(3,2)}x^3+y^3\ dl\ \ ;\ \ dl=\sqrt{dx^2+dy^2}$$ In another procedure I mapped the quadrilateral into a standard square in $s,t $ axes.
By using Lagrange interpolation, $$X(s,t)=\ \frac{3(s + 1)(t + 1)}{4} - \frac{(s + 1)(t - 1)}{2} - \frac{(s - 1)(t + 1)}{4}$$ $$Y(s,t)=\ \frac{(s + 1)(t - 1)}{4} - \frac{3(s - 1)(t + 1)}{4}+ \frac{(s + 1)(t + 1)}{2}$$ Since integration is from $t=-1$ to $t=1$, $dl=J dt$ where $J=\sqrt{\left(\frac{\partial X}{\partial t}\right)^2+\left(\frac{\partial Y}{\partial t}\right)^2}$. So the required integral is, $$I=\int_{-1}^1X^3+Y^3\ Jdt$$ Unfortunately, the second method gives the wrong result. I got 66.4078 while the actual result is 55.3399.
Where did I make mistake here?

  • $\begingroup$ Did you compute $(X^3+Y^3)J$? $\endgroup$
    – chris
    Dec 21, 2016 at 15:32
  • $\begingroup$ @chris, Yes. I have integrated it. Is there any conceptual error in procedure? $\endgroup$
    – user294664
    Dec 21, 2016 at 16:54
  • $\begingroup$ Your first integral goes from (2,-1) to (3,2). The exact solution is $35\sqrt{10}/2$. If that edge corresponds to $s=1$ and $-1 \leq t \leq 1$, your mapping would go from (2,-1) to (3,-2), so it's probably not correct. Besides, I would expect the determinant of the mapping's Jacobian, not the 2-norm. $\endgroup$
    – chris
    Dec 22, 2016 at 13:02
  • $\begingroup$ @chris How would I get a better result numerically from mapping? $\endgroup$
    – user294664
    Dec 22, 2016 at 15:02
  • $\begingroup$ @chris, Could you explain how does my mapping go from (2,-1) to (3,-2) $\endgroup$
    – user294664
    Dec 22, 2016 at 15:23

1 Answer 1


I prefer a bit different notation, but the workflow is certainly similar.

Denote the rectangular vertices, as follows: $$ \mathbf{v}_{00}=\left(\matrix{0\\0}\right),\quad \mathbf{v}_{10}=\left(\matrix{2\\-1}\right),\quad \mathbf{v}_{11}=\left(\matrix{3\\2}\right),\quad \mathbf{v}_{01}=\left(\matrix{1\\3}\right) $$ Now, the position vector $\mathbf{r}$ inside (or on the boundary) of the quadrilateral can be expressed in terms of barycentric coordinates $(\xi,\eta)$: $$ \mathbf{r}(\xi,\eta) = (1-\xi)(1-\eta)\mathbf{v}_{00} + \xi(1-\eta)\mathbf{v}_{10} + (1-\xi)\eta\mathbf{v}_{01} + \xi\eta\mathbf{v}_{11}, \quad \xi,\eta\in[0,1] $$ Now, the integral for the edge between $\mathbf{v}_{10}$ and $\mathbf{v}_{11}$, will correspond to $\xi=1$ and $\eta \in[0,1]$. Now, in a slighlty sloppy mathematical notation: $$ \int\limits_{\mathbf{v}_{10}}^{\mathbf{v}_{11}}f(\mathbf{v})d\mathbf{v} = \int\limits_0^1d\eta f\big(\mathbf{r}(\xi=1,\eta)\big)J $$ where $f(\mathbf{v}) = (\mathbf{v}\cdot\hat{x})^3 + (\mathbf{v}\cdot\hat{y})^3$, which is just a fancy way to write $f(x,y) = x^3+y^3$ using position-vectors. For this integral, the Jacobian $J$ would be the length of the line between $\mathbf{v}_{10}$ and $\mathbf{v}_{11}$. So, $J=\sqrt{10}$

Now, we can just compute the integral and obtain that

$$ J\int\limits_0^1d\eta f\big(\mathbf{r}(\xi=1,\eta)\big)=\sqrt{10}\frac{35}{2}\approx 55.3399 $$ which is the analytical result.

I also checked your Lagrange interpolant and Jacobian. Seems right to me. I guess the error is somewhere in the piping between your functions, main code and interpolants.

Please, see below screenshot of Mathcad screen for reference that implements both the "method" described above, as well as your Lagrange interpolant (only for the integral over the requested edge).enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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