import math
import matplotlib.pyplot as plt
x = [i * 0.1 for i in range(1, 10000)] # x: 0.1〜1000
y = [math.sin(math.pi / i) * i for i in x]
plt.plot(x, y)
plt.title("y = x × sin(π / x)")
plt.xlabel("x")
plt.ylabel("y")
plt.axhline(math.pi, color='red', linestyle=':', label='y = π')
plt.legend()
plt.grid(True)
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: