# Line Integral Difficulty

I am having difficulty with the following question:

Compute the line integral of $$f(x,y)=\frac{xy}{1+x+2y},$$ along the unit quarter-circle in the first quadrant from (1,0) to (0,1).

My problem could either be a mathematic mistake or a Mathematica difficulty, I am not sure which.

I define my function:

f[{x_, y_}] = x y/(1 + x + 2 y)


Then I parametrize the unit quarter circle as follows:

r[t_] = {Cos[t], Sin[t]}


I am going to compute the integral $$\int_0^{\pi/2} f(\vec r(t))\,|\vec r\,'(t)|\,dt,$$ so I perform this next:

integrand = f[r[t]] Sqrt[r'[t].r'[t]] // Simplify


Then I integrate and find a numerical approximation.

Integrate[integrand, {t, 0, \[Pi]/2}]
N[%]

(* 0.168183 *)


Now I do a second parametrization of the unit quarter circle, namely, I let $x=t$, then $y=\sqrt{1-t^2}$, but here I will need to let my $t$-values vary from $t=1$ to $t=0$ in order for the parametrization to move again from the point (1,0) to the point (0,1). So I do this next:

r[t_] = {t, Sqrt[1 - t^2]}


Then I do this:

integrand = f[r[t]] Sqrt[r'[t].r'[t]] // Simplify


Then I integrate from $t=1$ to $t=0$ (and I am expecting the same answer as I got above):

Integrate[integrand, {t, 1, 0}]
% // N

(* -0.168183 *)


I got the negative of the answer above.

So, my question. Am I making some type of mathematical error in my thinking, or is there something strange happening with Mathematica?

Update: MichaelE2 may be right. It may be the $\Delta t$ problem, keeping it positive. In order to have the $t$-values go from $t=0$ to $t=1$, and to have the curve pass from (1,0) to (0,1), I am going to have to choose a different parametrization.

r[t_] = {1 - t, Sqrt[1 - (1 - t)^2]}


Then:

Manipulate[
ParametricPlot[r[t], {t, 0, final}, PlotRange -> 1] /.
Line -> Arrow,
{{final, 0.5}, 0.00001, 1}] Now we integrate.

integrand = f[r[t]] Sqrt[r'[t].r'[t]] // Simplify;
Integrate[integrand, {t, 0, 1}];
% // N

(* 0.168183 *)


• You can evaluate this integral symbolically using Integrate[(x y)/(1 + x + 2 y) /. {x -> Cos[\[Theta]], y -> Sin[\[Theta]]}, {\[Theta], 0, \[Pi]/2}]. Nov 15 '15 at 10:15
• The $ds$ in the integral represents $\Delta s = \sqrt{\sum \Delta x} = \sqrt{\sum x'(c_i)^2 \Delta t_i^2} = \sqrt{\sum x'(c_i)^2}\, |\Delta t_i|$, which equals $\sqrt{\sum x'(c_i)^2}\, \Delta t_i$ only if the $\Delta t_i >0$, i.e., if you integrate from $t=0$ to $t=1$. (So I think there is a mathematical error in how you set up the second integral.) Nov 15 '15 at 13:57
• @MichaelE2 I think I found what I needed (examples) at: http://tutorial.math.lamar.edu/Classes/CalcIII/LineIntegralsPtI.aspx and http://tutorial.math.lamar.edu/Classes/CalcIII/LineIntegralsPtII.aspx. I am making a mathematical error. Nov 15 '15 at 17:41 Note the last condition, or consider limit of Riemann sum $\Delta t=\frac{b-a}{n}$.

As can be seen the expected integral should be positive:

f[x_, y_] := x y/(1 + x + 2 y);
p3 = Plot3D[f[x, y], {x, 0, 1}, {y, 0, 1},
MeshFunctions -> (#1^2 + #2^2 &), Mesh -> {{1}},
PlotStyle -> Opacity[0.5]];
pp = ParametricPlot3D[{t, Sqrt[1 - t^2], f[t, u Sqrt[1 - t^2]]}, {t,
0, 1}, {u, 0, 1}, Mesh -> None, PlotStyle -> Blue];
Show[p3, pp] See paramatrizations: $\{x,y\}\mapsto\{t,\sqrt{1-t^2}\}$, or$\{x,y\}\mapsto\{\sqrt{1-t^2},t\}$ for $0\le t\le 1$ or $\{x,y\}\mapsto\{\cos (t),\sin (t)\}$ for $0\le t\le \pi/2$.

So,

NIntegrate[f[Sqrt[1 - t^2], t]/Sqrt[1 - t^2], {t, 0, 1}]
NIntegrate[f[t, Sqrt[1 - t^2]]/Sqrt[1 - t^2], {t, 0, 1}]
NIntegrate[f[Cos[t], Sin[t]], {t, 0, Pi/2}]


all yield 0.168183 (and same analytic result).

Or else consider,$\int_C y ds$ for the same $C$ with same parametrizations:

Integrate[1, {t, 0, 1}]
Integrate[t/Sqrt[1 - t^2], {t, 0, 1}]
Integrate[Sin[t], {t, 0, Pi/2}]


all yield 1.

• Thanks for the nice answer, but I still see a problem. The parametrization $(x,y)\to (t,\sqrt{1-t^2})$ as $0\le t\le 1$ does not trace the quarter unit-circle from (0,1) to (1,0). Rather, it traces the unit circle from (0,1) to (1,0), so it is not the correct parametrization for this problem. Nov 15 '15 at 16:48
• Replace t by 1-t. Nov 15 '15 at 21:49
• @murray Yep, that's what I did too. Nov 15 '15 at 22:07

Integrate supports Region primitives, so you can use:

Integrate[(x y)/(1 + x + 2 y), {x, y} ∈ Circle[{0, 0}, 1, {0, π/2}]]


1/25 (15 - 2 π + Log - 3 Log)

Numerical approximation:

N @ %


0.168183