0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Python3]2017年東大数学に挑戦

Last updated at Posted at 2017-11-05

#2017年東大数学に挑戦してみます
######今回は文系の第一問で練習です!

問題文は載せるのやめておきます。。探せばいくらでも出てきますので・・・
文系といえど受かろうと思ったらこれを落とすとさすがにきついのではないかな~と思われる問題。
基本を押さえていれば、東大では標準レベルかと思いましたが、プログラミングだと苦労しますね・・・
まずはグラフの描写や積分、方程式の解などベタに求めてみます。

kaitou01.py

import sympy as sy
import matplotlib.pyplot as plt
import numpy as np
plt.style.use("ggplot")
fig = plt.figure()

x, y1, y2, s, t = sy.symbols('x y1 y2 s t')

y1 = s*(x - 1)**2
y2 = -x**2 + t**2

#積分
Sp = sy.integrate(y1, (x, 0, 1))

print('Pの面積は' + str(Sp))

#y2とx軸の交点は y2=0 かつ x>0
x0 = sy.symbols('x0')
#y2=0をxについて解く
tmp_kouten = sy.solve(y2, x)

x0 = tmp_kouten[1] 
Sq = sy.integrate(y2, (x, 0, x0))
print('Qの面積は' + str(Sq))

P_waru_Q = sy.simplify(Sq / Sp)
print('従って')
print('P/Q = ' + str(P_waru_Q))

#AとBが接する条件 y1 = y2 かつ x座標が等しい
print('y1 = y2を整理すると 「' + str(sy.sympify(y1 - y2)) + ' = 0 」')
tmp_kouten2 = sy.solve(y1 - y2, x)
setten = sy.solve(tmp_kouten2[0] - tmp_kouten2[1], s)

print('y1 = y2が解を一つしか持たないときsとtは 「s = ' + str(setten[0]) + '」を満たす。')

print('sに代入すると')
P_waru_Q_only_t = P_waru_Q.subs([(s,setten[0])])
print('P/Q = ' + str(sy.factor(P_waru_Q_only_t)))

print('tで微分すると')
d_P_waru_Q_only_t = sy.diff(P_waru_Q_only_t, t)
print('P/Q’ = ' + str(d_P_waru_Q_only_t))

tmp_Max_t = sy.solve(d_P_waru_Q_only_t, t)

Max_t = [max_t for max_t in tmp_Max_t if 0 < max_t < 1]

print('極大値をとるtは' + str(Max_t[0]))

print('従ってP/Qの最大値はt = ' + str(Max_t[0]) + ' のとき')
Max_P_waru_Q = P_waru_Q_only_t.subs([(t,Max_t[0])])

print('最大値' + str(Max_P_waru_Q) + 'を取る')

print('このときAとBを描くと')

a = np.arange(-1.25, 1.25, 0.01)
ax = fig.add_subplot(111)

Y1 = (1/2)*(a - 1)**2
Y2 = -a**2 + (sqrt(3)/3)**2

ax.plot(a, Y1)
ax.plot(a, Y2)
plt.show()

##実行結果はこんな感じ・・・
Pの面積はs/3
Qの面積は2t**3/3
従って
P/Q = 2
t3/s
y1 = y2を整理すると 「s*(x - 1)2 - t2 + x
2 = 0 」
y1 = y2が解を一つしか持たないときsとtは 「s = -t2/(t2 - 1)」を満たす。
sに代入すると
P/Q = -2t(t - 1)(t + 1)
tで微分すると
P/Q’ = -6
t**2 + 2
極大値をとるtはsqrt(3)/3
従ってP/Qの最大値はt = sqrt(3)/3 のとき
最大値4*sqrt(3)/9を取る
このときAとBを描くと
kaitougraph.png

途中のP/Q(t)を描いてみる

PQgraph.py
p = np.arange(-1.25, 1.25, 0.01)
ax = fig.add_subplot(111)
ax.plot(p, -2*p*(p - 1)*(p + 1))
plt.show()

tocyuugraph.png

######今回は単純に計算機とグラフ描写の為にしかpythonを使えていないです・・・
######二次関数が接する等の条件は関数で表現できればいいのかなーとか思ったりしますが難しい。
######いずれはAIでできたらいいのですが、文字認識→思考→解答作成となるととても難しそうだ笑
######とにかくプログラミングの練習になったのはよかったかなと。。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?