2

I want to find the area enclosed by the fourth heart curve (http://www.wolframalpha.com/input/?i=fourth+heart+curve). Since both $y(t)$ and $x(t)$ are given and I know that $t$ is in the range $[0,2\pi]$, I should be able to find the area $A$ by applying the well-known equation $$A = \int_0^{2\pi}\left(y'\cdot x\right)dt,$$ which can only be evaluated numerically. Therefore I want to use mathematica. I first specified both variables:

x = Cos[t]*(Sin[t]*Sqrt[Abs[Cos[t]]]/(Sin[t]+7/5)-2Sin[t]+2)
y = Sin[t]*(Sin[t]*Sqrt[Abs[Cos[t]]]/(Sin[t]+7/5)-2Sin[t]+2)

And since I am right now only interested in the area of the heart, I just use NIntegrate:

NIntegrate[D[y,t]*x,{t,0,2*3.142}]

I only use an approximate value for $\pi$ since I want to avoid problems arising from the fact that $\pi$ is irrational. However, if I do this, mathematica gives the error message that "has evaluated to non-numerical values for all sampling points in the region with boundaries" which would only happen without the absolute value of the cosine. This seems to be strange, because Wolfram|Alpha seems to be able to find a solution, and if I try the numerical integration with other software, I get exactly the same result.

Aaron Wild
  • 213
  • 2
  • 5
  • 6
    Replace Abs[Cos[t]] with Sqrt[Cos[t]^2] and it will work. The problem is that Mathematica doesn't deal with derivatives of functions like Abs very well (at first glance anyway). – march Mar 23 '16 at 21:48
  • @march, it worked, thank you very much. i did not know that... – Aaron Wild Mar 23 '16 at 22:42

1 Answers1

2

In this type of integration it is better to use Geometric Computation:

reg = ParametricRegion[r {x, y}, {{t, 0, 2 π}, {r, 0, 1}}];

NIntegrate[1, {x1, y1} ∈ reg]

(*12.5212*)
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78