Skip to main content
deleted 28 characters in body
Source Link

One can use one of the line integral forms of the area, derived from Green's Theorem: $$A = {1\over2} \int_C x \; dy - y \; dx = \int_C x \; dy = - \int_C y \; dx$$$$A = \frac12 \int_C x \; dy - y \; dx = \int_C x \; dy = - \int_C y \; dx$$ The first one is symmetric, which sometimes is an advantage.

c[t_] := {Sqrt[Abs[Cos[t]]] Sign[Cos[t]], Sqrt[Abs[Sin[t]]] Sign[Sin[t]]} dA = 1/2 c'[t].Cross[c[t]] (* complicated output *) 

One problem with this parametrization are the derivatives of Abs and Sign. They are discontinuous at isolated points, and as far as the integral is concerned, it does not matter what value we assign them at the discontinuities. So we can simplify matters by substituting for them. We can also substitute 1 for Sign[x]^2, since x will be 0 only at few isolated points. Thus the differential is

dA = dA /. {Sign'[x_] :> 0, Abs'[x_] :> Sign[x]} /. {Sign[_]^2 :> 1} // Simplify (* (Abs[Cos[t]] Cos[t] Sign[Cos[t]] + Abs[Sin[t]] Sign[Sin[t]] Sin[t]) / (4 Sqrt[Abs[Cos[t]]] Sqrt[Abs[Sin[t]]]) *) 

NIntegrate returns a small imaginary component

NIntegrate[dA, {t, 0, 2 \[Pi]π}] (* 3.70815 - 1.97076*10^-10 I *) 

Oddly, setting WorkingPrecision reduces the imaginary error, even if it is set to less than MachinePrecision (15.9546)

NIntegrate[dA, {t, 0, 2 \[Pi]π}, WorkingPrecision -> 10] (* 3.708149355 + 0.*10^-21 I *) 

Integrate returns an exact answer in this case:

Integrate[dA, {t, 0, 2 \[Pi]π}] (* (3 Sqrt[2] \[Pi]π Gamma[5/4] + 4 Gamma[3/4] Gamma[5/4]^2) / (2 Sqrt[\[Pi]]Sqrt[π] Gamma[3/4]) *) FullSimplify@%FullSimplify @ % (* (Sqrt[\[Pi]Sqrt[π/2] Gamma[1/4])/Gamma[3/4] *) N[%, 20] (* 3.7081493546027438369 *) 

One can use one of the line integral forms of the area, derived from Green's Theorem: $$A = {1\over2} \int_C x \; dy - y \; dx = \int_C x \; dy = - \int_C y \; dx$$ The first one is symmetric, which sometimes is an advantage.

c[t_] := {Sqrt[Abs[Cos[t]]] Sign[Cos[t]], Sqrt[Abs[Sin[t]]] Sign[Sin[t]]} dA = 1/2 c'[t].Cross[c[t]] (* complicated output *) 

One problem with this parametrization are the derivatives of Abs and Sign. They are discontinuous at isolated points, and as far as the integral is concerned, it does not matter what value we assign them at the discontinuities. So we can simplify matters by substituting for them. We can also substitute 1 for Sign[x]^2, since x will be 0 only at few isolated points. Thus the differential is

dA = dA /. {Sign'[x_] :> 0, Abs'[x_] :> Sign[x]} /. {Sign[_]^2 :> 1} // Simplify (* (Abs[Cos[t]] Cos[t] Sign[Cos[t]] + Abs[Sin[t]] Sign[Sin[t]] Sin[t]) / (4 Sqrt[Abs[Cos[t]]] Sqrt[Abs[Sin[t]]]) *) 

NIntegrate returns a small imaginary component

NIntegrate[dA, {t, 0, 2 \[Pi]}] (* 3.70815 - 1.97076*10^-10 I *) 

Oddly, setting WorkingPrecision reduces the imaginary error, even if it is set to less than MachinePrecision (15.9546)

NIntegrate[dA, {t, 0, 2 \[Pi]}, WorkingPrecision -> 10] (* 3.708149355 + 0.*10^-21 I *) 

Integrate returns an exact answer in this case:

Integrate[dA, {t, 0, 2 \[Pi]}] (* (3 Sqrt[2] \[Pi] Gamma[5/4] + 4 Gamma[3/4] Gamma[5/4]^2) / (2 Sqrt[\[Pi]] Gamma[3/4]) *) FullSimplify@% (* (Sqrt[\[Pi]/2] Gamma[1/4])/Gamma[3/4] *) N[%, 20] (* 3.7081493546027438369 *) 

One can use one of the line integral forms of the area, derived from Green's Theorem: $$A = \frac12 \int_C x \; dy - y \; dx = \int_C x \; dy = - \int_C y \; dx$$ The first one is symmetric, which sometimes is an advantage.

c[t_] := {Sqrt[Abs[Cos[t]]] Sign[Cos[t]], Sqrt[Abs[Sin[t]]] Sign[Sin[t]]} dA = 1/2 c'[t].Cross[c[t]] (* complicated output *) 

One problem with this parametrization are the derivatives of Abs and Sign. They are discontinuous at isolated points, and as far as the integral is concerned, it does not matter what value we assign them at the discontinuities. So we can simplify matters by substituting for them. We can also substitute 1 for Sign[x]^2, since x will be 0 only at few isolated points. Thus the differential is

dA = dA /. {Sign'[x_] :> 0, Abs'[x_] :> Sign[x]} /. {Sign[_]^2 :> 1} // Simplify (* (Abs[Cos[t]] Cos[t] Sign[Cos[t]] + Abs[Sin[t]] Sign[Sin[t]] Sin[t]) / (4 Sqrt[Abs[Cos[t]]] Sqrt[Abs[Sin[t]]]) *) 

NIntegrate returns a small imaginary component

NIntegrate[dA, {t, 0, 2 π}] (* 3.70815 - 1.97076*10^-10 I *) 

Oddly, setting WorkingPrecision reduces the imaginary error, even if it is set to less than MachinePrecision (15.9546)

NIntegrate[dA, {t, 0, 2 π}, WorkingPrecision -> 10] (* 3.708149355 + 0.*10^-21 I *) 

Integrate returns an exact answer in this case:

Integrate[dA, {t, 0, 2 π}] (* (3 Sqrt[2] π Gamma[5/4] + 4 Gamma[3/4] Gamma[5/4]^2) / (2 Sqrt[π] Gamma[3/4]) *) FullSimplify @ % (* (Sqrt[π/2] Gamma[1/4])/Gamma[3/4] *) N[%, 20] (* 3.7081493546027438369 *) 
Source Link
Michael E2
  • 258.7k
  • 21
  • 370
  • 830

One can use one of the line integral forms of the area, derived from Green's Theorem: $$A = {1\over2} \int_C x \; dy - y \; dx = \int_C x \; dy = - \int_C y \; dx$$ The first one is symmetric, which sometimes is an advantage.

c[t_] := {Sqrt[Abs[Cos[t]]] Sign[Cos[t]], Sqrt[Abs[Sin[t]]] Sign[Sin[t]]} dA = 1/2 c'[t].Cross[c[t]] (* complicated output *) 

One problem with this parametrization are the derivatives of Abs and Sign. They are discontinuous at isolated points, and as far as the integral is concerned, it does not matter what value we assign them at the discontinuities. So we can simplify matters by substituting for them. We can also substitute 1 for Sign[x]^2, since x will be 0 only at few isolated points. Thus the differential is

dA = dA /. {Sign'[x_] :> 0, Abs'[x_] :> Sign[x]} /. {Sign[_]^2 :> 1} // Simplify (* (Abs[Cos[t]] Cos[t] Sign[Cos[t]] + Abs[Sin[t]] Sign[Sin[t]] Sin[t]) / (4 Sqrt[Abs[Cos[t]]] Sqrt[Abs[Sin[t]]]) *) 

NIntegrate returns a small imaginary component

NIntegrate[dA, {t, 0, 2 \[Pi]}] (* 3.70815 - 1.97076*10^-10 I *) 

Oddly, setting WorkingPrecision reduces the imaginary error, even if it is set to less than MachinePrecision (15.9546)

NIntegrate[dA, {t, 0, 2 \[Pi]}, WorkingPrecision -> 10] (* 3.708149355 + 0.*10^-21 I *) 

Integrate returns an exact answer in this case:

Integrate[dA, {t, 0, 2 \[Pi]}] (* (3 Sqrt[2] \[Pi] Gamma[5/4] + 4 Gamma[3/4] Gamma[5/4]^2) / (2 Sqrt[\[Pi]] Gamma[3/4]) *) FullSimplify@% (* (Sqrt[\[Pi]/2] Gamma[1/4])/Gamma[3/4] *) N[%, 20] (* 3.7081493546027438369 *)