Drawing heart in mathematica

27.9k Views Asked by At

It's not really a typical math question. Today, while studying graphs, I suddenly got inquisitive about whether there exists a function that could possibly draw a heart-shaped graph. Out of sheer curiosity, I clicked on Google, which took me to this page.

The page seems informative, and I am glad to learn certain new things! Now I am interested in drawing them by my own using Mathematica. So my question is: is it possible to draw them in Mathematica? If yes, please show me how.

5

There are 5 best solutions below

5
On BEST ANSWER

For the fifth function in the link you mentioned (which I thought it was the most similar to a heart):

PolarPlot[(Sin[t]Sqrt[Abs[Cos[t]]])/(Sin[t]+7/5)-2Sin[t]+2, {t, 0, 10}]

Similarly, using W|A:

alt text

2
On

This is really about plotting polar plots, parametric plots and implicitly defined functions in Mathematica.

This is the info on how to draw polar plots

http://mathworld.wolfram.com/PolarPlot.html

Parametric plots

http://reference.wolfram.com/mathematica/ref/ParametricPlot.html

This provides info on implicit plots

http://grosz.math.txstate.edu/~dhaz/prob_sets/LTs09cal1lab8.pdf

0
On

You can plot Taubin's heart surface using ContourPlot3D:

ContourPlot3D[(2 x^2 + y^2 + z^2 - 1)^3 - (1/10) x^2 z^3 - y^2 z^3 == 0,
              {x, -1.5, 1.5}, {y, -1.5, 1.5}, {z, -1.5, 1.5},
              Mesh -> None, ContourStyle -> Opacity[0.8, Red]]

Taubin's heart

0
On

Consider the map $T \colon \mathbb R^2 \rightarrow \mathbb R^2, \ (x,y) \mapsto (x, y+ \sqrt{|x|})$. With a little examination, you can see that this will define a warping on the plane that will map the unit circle to a heart shaped curve: alt text

So if you know that a parametrization for the circle is $(\cos(t),\ \sin(t)),\ t\in [-\pi,\pi]$, then the parametrization for its heart-shaped image would be $(\cos(t),\ \sin(t) + \sqrt{|\cos(t)|}),\ t\in [-\pi,\pi]$. You can plot the curve with the following Mathematica code:

ParametricPlot[{Cos[t], Sin[t] + Sqrt[Abs[Cos[t]]]}, {t, -Pi, Pi}]
0
On

A somewhat late addition (I only found my yellowed notebooks containing these just now):

$$\left(2(1+\cos\,\varphi)\sin^3 t\qquad 2\cos\,\theta\;\sin^2 t \sin\,\varphi+\sin\,\theta\cos\,t\left(\cos\,2t-2\cos\,\varphi\;\sin^2 t-3\right)\right)^T$$

is a two-parameter family of curves that generate heart shapes for some values of $\theta$ and $\varphi$. They were derived from projections of a skewed version of the nephroid.

Here for instance is the case $\theta=\pi/4,\quad \varphi=\pi/2$:

heart