0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

大人用です。2014年大阪星光学院「【小学生が解く図形】天才しか引けない補助線、あなたは引ける?...」様を、計算はsympyで作図は手抜きのつもりでした。

0
Last updated at Posted at 2026-09-17

・困ったな。ver1.1,ver2.1。
・>...この問題、なかなか難しいんデス。...

オリジナル

まなびスクエア 様 (0:00〜10:06) いつもお世話になっております。
【小学生が解く図形】天才しか引けない補助線、あなたは引ける?【中学受験の算数】
https://youtu.be/If3IBQZR-iA

いつものsympyで(オリジナル Youtbe様の方法を参考に)

ver0.1

・先生の丸写しです。図形の証明は省略です。ステキです。

# ver0.1
from sympy import *
var('degθ',real=True,positive=True)
san_sikaku=7
iti_sikaku=san_sikaku*Rational(1,3)
yon_sikaku=san_sikaku*Rational(4,3)
print("#",yon_sikaku)
# 28/3

ver0.2

・??? 点検です。 解から、3/4 がでません。0.75。困ったver1.1,ver2.1
 大人はいろんな事をやらないとだめです。

# ver0.2
from sympy import *
var('degθ',real=True,positive=True)
AD       =4                          
AB       =Rational(28,3)                      # ←←← 解                         
tr_DAB   =Triangle(sas=(AD,20,AB))           
angle_BDA=tr_DAB.angles[tr_DAB.vertices[2]]                    #;print( angle_BDA, float(deg(angle_BDA)) )
tr_CAD   =Triangle(asa=(80,AD,180-deg(angle_BDA)))
print("#",      (tr_CAD.sides[1].length/tr_DAB.sides[1].length).simplify()                       )
print("#",      (tr_CAD.sides[1].length/tr_DAB.sides[1].length).simplify().simplify()            )
print("#",      (tr_CAD.sides[1].length/tr_DAB.sides[1].length).simplify().simplify().simplify() )
print("#",float((tr_CAD.sides[1].length/tr_DAB.sides[1].length)))
# 3*sqrt(49*sin(pi/9)**2 + (-7*sin(pi/9)*tan(pi/18) + 4)**2)/(4*sqrt(58 - 42*cos(pi/9)))
# 3*sqrt(98*sin(pi/9)**2 + 2*(-7*sin(pi/9)*tan(pi/18) + 4)**2)/(8*sqrt(29 - 21*cos(pi/9)))
# 3*sqrt(98*sin(pi/9)**2 + 2*(-7*sin(pi/9)*tan(pi/18) + 4)**2)/(8*sqrt(29 - 21*cos(pi/9)))
# 0.75
# p0=tr_DAB.args[0]
# p1=tr_DAB.args[1]
# p2=tr_DAB.args[2]
# print("#",float(deg(tr_DAB.angles[p0])))
# print("#",float(deg(tr_DAB.angles[p1])))
# print("#",float(deg(tr_DAB.angles[p2])))

いつもの sympyで

ver1.1

・解がでません。

# # ver1.1
# from sympy import *
# var('k,degθ',real=True,positive=True)
# DA     =4                          
# B,D,C,A=map(Point,[(0,0),(4*k,0),(7*k,0),(DA*cos(rad(degθ)),DA*sin(rad(degθ)))])
# sol=solve([Eq(Line(A,D).angle_between(Line(A,B)),rad(-20)),  \
#            Eq(Line(A,D).angle_between(Line(A,C)),rad( 80))], \
#           [k,degθ])
# print(sol)

ver2.1

・コレも、解がでません。

# # ver2.1
# from sympy import *
# var('degθ',real=True,positive=True)
# AD =4                          
# A,D=map(Point,[(0,0),(AD,0)])
# B  =Line(A,D).rotate(rad(-20),A).intersection(Line(D,A).rotate(rad(180-degθ),D))[0]  ;print(B)
# C  =Line(A,D).rotate(rad( 80),A).intersection(Line(D,A).rotate(rad(   -degθ),D))[0]  ;print(C)
# # sol=solve(Eq(B.distance(D)/D.distance(C),Rational(3,4)),deg)
# sol=solveset(Eq(B.distance(D)/D.distance(C),Rational(4,3)),degθ,Interval(30,40))
# print("#",sol)

ver2.2

・こうなったらGemini先生へ。 ソルバー風です。??? 解が2つ。

ソルバーで何とかなりますか。結果も出力して。
# ver2.2
# SymPy を用いた平面図形における角度および各線分長の数値計算プログラム
from sympy import Abs, Eq, Rational, Symbol, nsolve, rad, sin

# 変数(角度 deg_theta)の定義
deg_theta = Symbol("deg_theta", real=True)

# 式の定義(正弦定理による各線分の長さの表現)
BD_expr = 4 * sin(rad(20)) / Abs(sin(rad(deg_theta - 20)))
DC_expr = 4 * sin(rad(80)) / Abs(sin(rad(80 + deg_theta)))
AB_expr = 4 * sin(rad(deg_theta)) / Abs(sin(rad(deg_theta - 20)))

# 条件式: BD / DC = 4 / 3
eq = Eq(BD_expr / DC_expr, Rational(4, 3))

# 数値求解 (0° < θ < 90° 内の2つの解)
sol1 = float(nsolve(eq, deg_theta, 5))
sol2 = float(nsolve(eq, deg_theta, 34))

# 値の計算
bd1 = float(BD_expr.subs(deg_theta, sol1))
dc1 = float(DC_expr.subs(deg_theta, sol1))
ab1 = float(AB_expr.subs(deg_theta, sol1))

bd2 = float(BD_expr.subs(deg_theta, sol2))
dc2 = float(DC_expr.subs(deg_theta, sol2))
ab2 = float(AB_expr.subs(deg_theta, sol2))

# 計算結果の出力
print("==========================================")
print("             計算結果一覧                 ")
print("==========================================")
print(f"[解 1]")
print(f"  θ       = {sol1:.6f}°")
print(f"  BD      = {bd1:.6f}")
print(f"  DC      = {dc1:.6f}")
print(f"  BD / DC = {bd1/dc1:.6f}  (厳密値: 4/3)")
print(f"  AB      = {ab1:.6f}  (分数: 4/3)")
print("------------------------------------------")
print(f"[解 2]")
print(f"  θ       = {sol2:.6f}°")
print(f"  BD      = {bd2:.6f}")
print(f"  DC      = {dc2:.6f}")
print(f"  BD / DC = {bd2/dc2:.6f}  (厳密値: 4/3)")
print(f"  AB      = {ab2:.6f}  (分数: 28/3)")
print("==========================================")

# ==========================================
#              計算結果一覧                 
# ==========================================
# [解 1]
#   θ       = 4.961631°
#   BD      = 5.272681
#   DC      = 3.954511
#   BD / DC = 1.333333  (厳密値: 4/3)
#   AB      = 1.333333  (分数: 4/3)
# ------------------------------------------
# [解 2]
#   θ       = 33.788722°
#   BD      = 5.739982
#   DC      = 4.304987
#   BD / DC = 1.333333  (厳密値: 4/3)
#   AB      = 9.333333  (分数: 28/3)
# ==========================================

ver3.1

・さらにGemini先生へ。

三角関数で何とかして。結果も出力して。

・私はアキラメました。アドバイスいただけたら幸いです。

ver3.2

以下を正弦定理で。
(ver2.2 のソースコードの表示を省略)
全体版で、計算結果は厳密解のみ出力して下さい。
# SymPy を用いた正弦定理に基づく平面図形の厳密解(解析解)計算プログラム
from sympy import Abs, Eq, Rational, Symbol, deg, rad, simplify, sin, solve

# 変数(角度 deg_theta)の定義
deg_theta = Symbol("deg_theta", real=True)

# 式の定義(正弦定理による各線分の長さの表現)
BD_expr = 4 * sin(rad(20)) / Abs(sin(rad(deg_theta - 20)))
DC_expr = 4 * sin(rad(80)) / Abs(sin(rad(80 + deg_theta)))
AB_expr = 4 * sin(rad(deg_theta)) / Abs(sin(rad(deg_theta - 20)))

# 条件式: BD / DC = 4 / 3
eq = Eq(BD_expr / DC_expr, Rational(4, 3))

# 厳密解の代数的求解 (0° < θ < 90°)
solutions = solve(eq, deg_theta)
valid_solutions = [
    sol for sol in solutions if sol.is_real and 0 < sol < 90
]

# 計算結果の出力
print("==========================================")
print("             計算結果一覧 (厳密解)         ")
print("==========================================")

for idx, sol in enumerate(valid_solutions, 1):
    # 各線分長を厳密値として計算・簡略化
    bd_val = simplify(BD_expr.subs(deg_theta, sol))
    dc_val = simplify(DC_expr.subs(deg_theta, sol))
    ab_val = simplify(AB_expr.subs(deg_theta, sol))
    ratio_val = simplify(bd_val / dc_val)

    print(f"[解 {idx}]")
    print(f"  θ       = {sol}")
    print(f"  BD      = {bd_val}")
    print(f"  DC      = {dc_val}")
    print(f"  BD / DC = {ratio_val}")
    print(f"  AB      = {ab_val}")
    print("------------------------------------------")
計算結果をmarkdownの背景黒で
==========================================
             計算結果一覧 (厳密解)         
==========================================
[解 1]
  θ       = 180・atan(3・sin(π/9) / (4・sin(4π/9) - 3・cos(π/9))) / π + 20°
  BD      = 4・sin(π/9) / sin(atan(3・sin(π/9) / (4・sin(4π/9) - 3・cos(π/9))))
  DC      = 3・sin(π/9) / sin(atan(3・sin(π/9) / (4・sin(4π/9) - 3・cos(π/9))))
  BD / DC = 4/3
  AB      = 4/3
------------------------------------------
[解 2]
  θ       = 180・atan(3・sin(π/9) / (4・sin(4π/9) + 3・cos(π/9))) / π + 20°
  BD      = 4・sin(π/9) / sin(atan(3・sin(π/9) / (4・sin(4π/9) + 3・cos(π/9))))
  DC      = 3・sin(π/9) / sin(atan(3・sin(π/9) / (4・sin(4π/9) + 3・cos(π/9))))
  BD / DC = 4/3
  AB      = 28/3
==========================================

(本日の)ChatGPT先生へ。作図。

以下のpng図だけ出力して。matplotlib 不要。
(ver2.2 のソースコードの表示を省略)

紆余曲折の末。

image.png

いつもの? sympyの実行環境 と 参考のおすすめです。

sympyのweb上での実行方法

SymPy Live Shellで。
ソースコードの解説は、私よりGemini先生へのソースコードの丸投げがおすすめです。質問の追加はいくらでも。
モーダル対応?「実行して」。「作図して」「問題文章の丸投げ」いい時代です。

(テンプレート)

いつもと違うおすすめです。

sympy のdoc

・いらないカモ。

ver0.1

ver0.2

・property sides < Triangle
https://docs.sympy.org/latest/modules/geometry/polygons.html#sympy.geometry.polygon.Polygon.sides

ver1.1

ver2.1

ver2.2

・sympy.solvers.solvers.nsolve(*args, dict=False, **kwargs)
https://docs.sympy.org/latest/modules/solvers/solvers.html#sympy.solvers.solvers.nsolve

ver3.1

wikipedia内で

qiita 内で

後記

GeminiはAIであり、不正確な情報を表示することがあります

・後出しで、私の言い訳です。気をつけて確認しているつもりです。
 お気づきがあれば、アドバイスいただけると幸いです。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?