import numpy as np import sympy as sp import matplotlib.pyplot as plt from IPython.display import display import japanize_matplotlib def descartes(ax, ran_x, ran_y, ax_title,x_label = "x", y_label = "y"): ax.set_xlabel(x_label, fontsize = 12) ax.set_ylabel(y_label, fontsize = 12) ax.set_xlim(ran_x[0], ran_x[1]) ax.set_ylim(ran_y[0], ran_y[1]) ax.set_title(ax_title, fontsize = 14) ax.grid() ax.axhline(0, color = "black") ax.axvline(0, color = "black") fig = plt.figure(figsize = (5, 5)) ax = fig.add_subplot(111) title1 = "数学Ⅲ 数列の極限 応用例題1" x_label = "x軸" y_label = "y軸" descartes(ax, [0,100], [-0.6, 0.6],title1,x_label,y_label) x=sp.var('x',integer=True) y=1/x*sp.sin(sp.pi*x/6) lim_an = sp.limit(y, x, sp.oo) n=np.arange(1,101) an=1/n*np.sin(np.pi*n/6) y1=-1/n y2=1/n ax.scatter(n,an,color='r',s=1.5) ax.scatter(n,y1,color='b',s=1) ax.scatter(n,y2,color='b',s=1) ax.text(20,0.5,"1/n*np.sin(np.pi*n/6) の極限値は{}".format(lim_an),color='r') plt.show()