level 1
双鱼hewen
楼主
首先我们定义一个函数
def f(x, love=50):
y = x ** (2 / 3) + 0.9 * np.sqrt(np.maximum(3.3 - x ** 2, 0)) * np.sin(love * np.pi * x)
return y
不需要管中间复杂的公式,只要知道这个函数需要1-2个输入值(love不输入默认为50)
然后我们再定义一个函数
def show_curve(numbers):
x = np.linspace(0, 2, 1500)
y = [f(i,numbers) for i in x]
plt.plot(x, y, color='red', linewidth=3)
plt.plot(-x, y, color='red', linewidth=3)
plt.xlim(-2, 2)
plt.show()
最后调用函数
show_curve(12)
就可以得到爱心了

2026年11月24日 09点11分
1
def f(x, love=50):
y = x ** (2 / 3) + 0.9 * np.sqrt(np.maximum(3.3 - x ** 2, 0)) * np.sin(love * np.pi * x)
return y
不需要管中间复杂的公式,只要知道这个函数需要1-2个输入值(love不输入默认为50)
然后我们再定义一个函数
def show_curve(numbers):
x = np.linspace(0, 2, 1500)
y = [f(i,numbers) for i in x]
plt.plot(x, y, color='red', linewidth=3)
plt.plot(-x, y, color='red', linewidth=3)
plt.xlim(-2, 2)
plt.show()
最后调用函数
show_curve(12)
就可以得到爱心了
