In order to celebrate this February 14, it would be good to know how a computer can represent the formula of love.
The first thing is to indicate that this is the formula:
If cleared, the us will be the following solutions:
And the task is to represent it in Python.
AnswerToo many ads?
The representation would be to use
matplotlib in this way:
import numpy as np import matplotlib.pyplot as plt x = np.linspace(-1,1,50) y1 = np.sqrt(x * x) + np.sqrt(1 - x * x) y2 = np.sqrt(x * x) - np.sqrt(1 - x * x) plt.plot(x, y1, c='r', lw = 3) plt.plot(x, y2, c='r', lw = 3) plt.show()
and the result:
Happy Valentine's day !
Note: Idea copied verbatim from here.