0
$\begingroup$

This question already has an answer here:

I've plotted two polar curves.

PolarPlot[{3 Sin[t], 1 + Sin[t]}, {t, 0, 2 Pi}, PlotRange -> {-1, 3}]

enter image description here

I'd like to shade the region that lies inside the circle but outside of the cardioid. Then I'd like to find the area of the shaded region using Mathematica's Area command.

Is this possible using polar coordinates? Can someone share some suggestions?

Update: Thanks for posting some old questions I asked. Couldn't find them. Here is what I finally came up with:

Clear[r, t]
Show[
  PolarPlot[{3 Sin[t], 1 + Sin[t]}, {t, 0, 2 π}],
  ParametricPlot[{r Cos[t], r Sin[t]}, {t, π/6, 5 π/6}, {r, 1 + Sin[t], 3 Sin[t]}]]

enter image description here

Now, rather than using ImplicitRegion, I used:

Area[{r Cos[t], r Sin[t]}, {t, π/6, 5 π/6}, {r, 1 + Sin[t], 3 Sin[t]}]

Which returns an exact answer of $\pi$. Here is the timing.

Area[{r Cos[t], r Sin[t]}, {t, π/6, 5 π/6}, {r, 1 + Sin[t], 3 Sin[t]}] // 
  AbsoluteTiming

{0.722002, π}

$\endgroup$

marked as duplicate by Yves Klett, mikado, Young, Michael E2 plotting May 7 '17 at 13:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6
$\begingroup$

One approach is to use ImplicitRegion to represent the disk and cardioid regions by using your formulas as the maximum radius in polar coordinates and converting this to a cartesian representation that is easier to use with ImplicitRegion. Then we can get your desired region as the RegionDifference and plot it via DiscretizeRegion:

tocartesian = {t -> ArcTan[x, y], r -> Sqrt[x^2 + y^2]}
diskregion = ImplicitRegion[r < (3 Sin[t]) /. tocartesian // Simplify, {x, y}]
cardioidregion = ImplicitRegion[r < (1 + Sin[t]) /. tocartesian // Simplify, {x, y}]
crescentregion = RegionDifference[diskregion, cardioidregion]
DiscretizeRegion[crescentregion, PrecisionGoal->6]
RegionMeasure[%]

Discretized crescent shaped region

(* Out[1]= 3.14159 *)

The area seems to be Pi. In theory we should be able to verify this symbolically with

RegionMeasure[crescentregion]

but Mathematica seems to take a bit longer to solve the integral for this region (i.e. it didn't finish on my machine after a few minutes).

$\endgroup$
  • 1
    $\begingroup$ +1 - you could also use your replacement rule to transform the difference region, and use reg = r < (3 Sin[t]) && r > (1 + Sin[t]) /. tocartesian; {RegionPlot[reg, {x, -3/2, 3/2}, {y, 1/2, 3}], DiscretizeRegion@ImplicitRegion[reg, {x, y}]} $\endgroup$ – Jason B. Apr 27 '17 at 16:06
  • $\begingroup$ @JasonB. Yeah, i was thinking the same, and trying out the same thing at the moment actually :) The thing that i'm trying to figure out his how to get the area of the region. It's easy and fast for the discretized version with RegionMeasure, but the implicit version seems to set off a nontrivial integral computation in Mathematica and doesn't seem to finish... $\endgroup$ – Thies Heidecke Apr 27 '17 at 16:11
  • $\begingroup$ I did notice that Area[ ImplicitRegion[... was taking a long time, so I also didn't see a better way to get the area. $\endgroup$ – Jason B. Apr 27 '17 at 17:06
3
$\begingroup$

The same as Thies Heidecke calculated it, only with other procedures.

reg = ImplicitRegion[TransformedField["Polar" -> "Cartesian", 
    r < 3 Sin[φ] && r > 1 + Sin[φ], {r, φ} -> {x, y}], {x, y}];
Area@DiscretizeRegion[reg, PrecisionGoal -> 6]

3.14159

Addition

Another way with area = 1/2 Integrate[r^2(φ) dφ]:

r1 = 1 + Sin[φ];
r2 = 3 Sin[φ];
{φ1, φ2} = φ /. Solve[r1 == r2, φ] /. C[1] -> 0
{π/6, (5 π)/6}

area = 1/2 Integrate[r2^2 - r1^2, {φ, φ1, φ2}] //AbsoluteTiming
{0.156459, π}
$\endgroup$

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