I tried to solve the first question of the University of Tokyo 2019 Mathematics Entrance Examination with python sympy. I also measured the time to measure how many seconds it took to solve.
See here for problems. https://sokuho.yozemi.ac.jp/sokuho/k_mondaitokaitou/1/kaitou/kaitou/1306831_5342.html
On my PC, I was able to calculate in 23 seconds.
import sympy as sym
import datetime
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z')
f = (x**2 + x/sqrt(1+x**2))*(1+ x/((1+x**2)*sqrt(1+x**2)))
#start time
start_t = datetime.datetime.now()
#calc
answer=sym.integrate(f,(x,0,1))
#end time
end_t = datetime.datetime.now()
#elapse time
elapse_t = end_t - start_t
print(answer)
print(elapse_t,"It took a second")
Recommended Posts