6 votes

How to represent the Formula of love in Python?

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:

introducir la descripción de la imagen aquí

If cleared, the introducir la descripción de la imagen aquí us will be the following solutions:

introducir la descripción de la imagen aquí

introducir la descripción de la imagen aquí

And the task is to represent it in Python.

5voto

Eduardo Munizaga Points 1876

The representation would be to use numpy and 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:

introducir la descripción de la imagen aquí

Happy Valentine's day !

Note: Idea copied verbatim from here.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X