Problem

A popular mathematical equation for 2D heart is the following,

\[f(x,y) = (x^2 + y^2 - 1)^3 - x^2 y^3 = 0\]

Any $(x,y)$ values that result in $f(x,y) < 0$ represent the coordinates of a point that falls inside the heart shape. Write a script that generates a heart shape via a set of random points uniformly distributed inside the heart shape. Estimate the area of the heart by drawing an appropriate box around the heart and sampling points randomly uniformly from this box and counting those that fall inside the heart. Here is a plot of the heart,

Comments