import sympy as sym import numpy as np from IPython.display import display import matplotlib.pyplot as plt 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") def inner_product(vect1,vect2): i1=np.inner(vect1,vect2) a1=np.linalg.norm(vect1) a2=np.linalg.norm(vect2) theta=np.arccos(i1/(a1*a2)) return theta fig = plt.figure(figsize = (5, 5)) ax = fig.add_subplot(111) title1 = "Tokyo University 2024 Math qu.2 NO1" descartes(ax, [-0.5,1.5], [-0.5, 1],title1) x=np.linspace(0,1,200) y=2*x*np.arctan(x)-np.log(1+x**2)-np.pi/4*x+1/2*np.log(2) ax.plot(x,y,color="blue") x=1 y=2*x*np.arctan(x)-np.log(1+x**2)-np.pi/4*x+1/2*np.log(2) ax.scatter(x,y,color="red") x=np.sqrt(2)-1 y=2*x*np.arctan(x)-np.log(1+x**2)-np.pi/4*x+1/2*np.log(2) ax.scatter(x,y,color="red") plt.show()