使用三角函数及反三角函数
- import numpy as np
- import matplotlib.pyplot as plt
-
- # 创建一个从-2π到2π(包含2π)的等差数列,步长为0.01
- x = np.arange(-4*np.pi, 4*np.pi, 0.01)
-
- # 计算y值
- y = np.arcsin(np.sin(x))
-
- # 绘制图像
- plt.figure(figsize=(8, 6))
- plt.plot(x, y)
- plt.title('y = arcsin(sin(x))')
- plt.xlabel('x')
- plt.ylabel('y')
- plt.grid(True)
- plt.show()
- import numpy as np
- import matplotlib.pyplot as plt
-
- # 创建一个从-2π到2π(包含2π)的等差数列,步长为0.01
- x = np.arange(-4*np.pi, 4*np.pi, 0.01)
-
- # 计算y值
- y = np.arcsin(np.sin(x))
-
- # 绘制图像
- plt.figure(figsize=(8, 6))
- plt.plot(x, y)
- plt.title('y = arcsin(sin(x))')
- plt.xlabel('x')
- plt.ylabel('y')
- plt.grid(True)
- plt.show()