❤️

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
x = np.arange(-2, 2, 0.0001)
plt.ion()

for b in range(0, 101):
y = np.power(np.power(x, 2), 1 / 3) + 0.9 * np.sqrt(4 - x ** 2) * np.sin(b * np.pi * x)
plt.plot(x, y, 'r', linewidth=3)
plt.title("b={}".format(b))
plt.xticks([])
plt.yticks([])
plt.show()
if b == 100:
plt.pause(2)
else:
plt.pause(0.1)
plt.clf()
plt.ioff()

5 2 0_机器学习

采样间隔太大容易变心:

x = np.arange(-2, 2, 0.01)

5 2 0_线性代数_02

❤️

print('\n'.join([''.join([('LOVE'[(x - y) % 4] if ((x * 0.05) ** 2 + (y * 0.1) ** 2 - 1) ** 3 - (
x * 0.05) ** 2 * (y * 0.1) ** 3 > 0 else ' ') for x in range(-30, 30)]) for y in range(15, -15, -1)]))

5 2 0_python_03

LOVE YOU ❤️

L

O

V

E

Y

U

❤️

上半部分:

下半部分:

import matplotlib.pyplot as plt
import numpy as np

x1 = np.arange(0, 2, 0.0001)
L = 1.0 / (x1 + 0.00001)

x2 = np.arange(-2, 2, 0.0001)

O1 = np.sqrt(4 - x2 ** 2) # 上半部分
O2 = -np.sqrt(4 - x2 ** 2) # 下半部分

V = 2 * np.abs(x2)

E = -2 * np.abs(np.sin(1.5 * x2))

Y = np.log(2 * np.abs(x2))

U = x2 ** 2

heart1 = np.sqrt(1 - (np.abs(x2) - 1) ** 2)
heart2 = np.arccos(1 - np.abs(x2)) - np.pi

fig = plt.figure(figsize=(12, 6))
ax_L = fig.add_subplot(241)
ax_O = fig.add_subplot(242)
ax_V = fig.add_subplot(243)
ax_E = fig.add_subplot(244)
ax_Y = fig.add_subplot(245)
ax_O_2 = fig.add_subplot(246)
ax_U = fig.add_subplot(247)
ax_heart = fig.add_subplot(248)

linewidth = 2
ax_L.plot(x1, L, color="r", linewidth=linewidth)
ax_L.xaxis.set_ticks([]), ax_L.yaxis.set_ticks([])
ax_O.plot(x2, O1, color="r", linewidth=linewidth)
ax_O.plot(x2, O2, color="r", linewidth=linewidth)
ax_O.xaxis.set_ticks([]), ax_O.yaxis.set_ticks([])


ax_V.plot(x2, V, color="r", linewidth=linewidth)
ax_V.xaxis.set_ticks([]), ax_V.yaxis.set_ticks([])

ax_E.plot(E, x2, color="r", linewidth=linewidth)
ax_E.xaxis.set_ticks([]), ax_E.yaxis.set_ticks([])

ax_Y.plot(x2, Y, color="r", linewidth=linewidth)
ax_Y.xaxis.set_ticks([]), ax_Y.yaxis.set_ticks([])

ax_O_2.plot(x2, O1, color="r", linewidth=linewidth)
ax_O_2.plot(x2, O2, color="r", linewidth=linewidth)
ax_O_2.xaxis.set_ticks([]), ax_O_2.yaxis.set_ticks([])

ax_U.plot(x2, U, color="r", linewidth=linewidth)
ax_U.xaxis.set_ticks([]), ax_U.yaxis.set_ticks([])

ax_heart.plot(x2, heart1, color="r", linewidth=linewidth)
ax_heart.plot(x2, heart2, color="r", linewidth=linewidth)
ax_heart.xaxis.set_ticks([]), ax_heart.yaxis.set_ticks([])

plt.show()

5 2 0_机器学习_04