1
$\begingroup$

I am trying to do a line integral along an ellipse. The am integrating the field $x^2 + y^2$. I want to integrate over an ellipse $\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1$ where the perimeter of the ellipse is $2\pi$ and $a = 1.5$. To get $b$ such that the perimeter is $2\pi$, I use Ramanujans equation. Here is the code I use to do this integral over a region:

a = 1.5;
b =  1/3 (3 - 2 a + Sqrt[3 + 6 a - 5 a^2]);
R = ImplicitRegion[x^2/a^2 + y^2/b^2 == 1., {x, y}];
NIntegrate[x^2 + y^2, {x, y} \[Element] R]

This integral returns 5.397.

I can also parameterize the ellipse using $x = a\cos{\theta}$ and $y = b\cos{\theta}$. Then I would plug this into the field and integrate over $\theta$:

a = 1.5;
b =  1/3 (3 - 2 a + Sqrt[3 + 6 a - 5 a^2]);
NIntegrate[(a*Cos[\[Theta]])^2 + (b*Sin[\[Theta]])^2,{\[Theta],0,2*Pi}]

This integral gives me 7.33. Why are the two integrals returning different results?

$\endgroup$
1
  • 2
    $\begingroup$ By the way, in this case you could integrate directly over the (boundary of) ellipse: Integrate[x^2 + y^2, {x, y} \[Element] Circle[{0, 0}, {a, b}]], and with exact a and b, get an exact answer. $\endgroup$
    – kirma
    Nov 2, 2022 at 6:01

1 Answer 1

6
$\begingroup$

We need to add Jacobian in curve integral. Sqrt[D[a*Cos[θ], θ]^2 +D[b*Sin[θ], θ]^2] when we change the variables in integral.

a = 1.5;
b = 1/3 (3 - 2 a + Sqrt[3 + 6 a - 5 a^2]);
NIntegrate[((a*Cos[θ])^2 + (b*Sin[θ])^2)*Sqrt[
  D[a*Cos[θ], θ]^2 + 
   D[b*Sin[θ], θ]^2], {θ, 0, 2*Pi}]

5.39697

$\endgroup$
1

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.