:) The title is a joke, please don't be serious.
With the rapid development of AI, is interested in this line of the code of the farmers is also a sharp increase, bringing the algorithm, the interest of mathematics is also exceptionally high.
The origin of this article is this, today an old colleague in the circle of friends sent a screen shot, to find formulas.
It is still difficult to see, the upper half is basically two semicircular, the lower half is two rotated inverse cosine function.
But my math is also relatively slag, see this step behind also daoteng unclear, but to this extent on the Internet search search Find the answer or not difficult, quickly found the right formula (with y=0 as the boundary, it is definitely need two sets of solutions):
$$ y = \sqrt{1-(\left| x \right|-1) ^2}, Arccos (1-\left| x \right|) -\pi $$
Otherwise just search the heart-shaped function, will certainly get a large variety of, but do not match test instructions pictures, such as:
To verify this formula with Mathmatics most convenient, but just changed the computer, just not installed.
Recently in the area of doing python3, 5 minutes with Python3 wrote a verification program, the source attached:
#!/usr/bin/env Python3ImportMatplotlib.pyplot asPlt fromMatplotlib.font_managerImportFontpropertiesImportNumPy asmp[=Np.linspace (-2,2, $) y1=NP.SQRT (1-Np.square (Np.fabs (x)-1)) Y2=Np.arccos (1-Np.fabs (x))-Np.piplt.plot (x, y1,' R ', X,y2,' R ') Plt.axis ([-2.5,2.5,-3.5,1.5]) Plt.title (' Heart of Numbers, by @andrew ', FontSize= -) Plt.show ()
The result of the drawing is the head graph.
The program used to Matplotlib and numpy two libraries, before running the need to first install with PIP3.
Resources
Https://www.quora.com/What-is-the-equation-that-gives-you-a-heart-on-the-graph
Even if you can draw a heart with Python, you're still a single dog.