・(その2)を制作中です。 2024-06-21
https://qiita.com/mrrclb48z/items/e0399d05b7350a2e9e11
オリジナル
・PASSLABO 様 (0:00〜12:05)
・大学入試数学問題集成 様> 前期【3】 テキスト
ChatGPT-3.5先生へ(1回目) できませんでした。
・ページのソースを表示です。MathMLです。
省略しようと思いましたが、大学入試数学問題集成 様 の全文から必要部分の抜粋です。
<div class="refinfo">
<p>2020 一橋大学 前期</p></div>
<div class="refinfo2">
</div>
<div class="diff"><p>易□ 並□ 難□</p></div></div>
<div class="qbody">
<p class="slevel"><a name="q-0103"
id="q-0103"></a><span
class="qnum">【3】</span> 半径<math>
<mspace width=".2em"></mspace><mn>1</mn>
<mspace width=".2em"></mspace>
</math>の円周上に<math>
<mspace width=".2em"></mspace><mn>3</mn>
<mspace width=".2em"></mspace>
</math>点<math>
<mspace width=".2em"></mspace><mrow>
<mi mathvariant="normal">A</mi><mspace width=".2em"></mspace>
<mtext>,</mtext></mrow>
</math><math>
<mrow><mi mathvariant="normal">B</mi>
<mspace width=".2em"></mspace><mtext>,</mtext></mrow>
</math><math>
<mi mathvariant="normal">C</mi><mspace width=".2em"></mspace>
</math>がある.内積<math>
<mspace width=".2em"></mspace><mrow><mover><mi>AB</mi>
<mo>→</mo></mover><mo>⋅</mo>
<mover><mi>AC</mi><mo>→</mo></mover></mrow>
<mspace width=".2em"></mspace>
</math>の最大値と最小値を求めよ.
</p>
</div>
</div>
日本語で
結論
最大値は 4、最小値は 0です。
ChatGPT-3.5先生へ(2回目) sympyで、できませんでした。
import sympy as sp
# 変数を定義
theta1, theta2 = sp.symbols('theta1 theta2')
# 点の座標を定義
A = sp.Matrix([1, 0])
B = sp.Matrix([sp.cos(theta1), sp.sin(theta1)])
C = sp.Matrix([sp.cos(theta2), sp.sin(theta2)])
# ベクトルABとACを計算
AB = B - A
AC = C - A
# 内積を計算
dot_product = AB.dot(AC)
# 内積の式を簡単化
simplified_dot_product = sp.simplify(dot_product)
# 内積の最大値と最小値を求める
max_value = sp.Max(simplified_dot_product.subs(theta1, 0).subs(theta2, 0),
simplified_dot_product.subs(theta1, sp.pi).subs(theta2, sp.pi),
simplified_dot_product.subs(theta1, 0).subs(theta2, sp.pi),
simplified_dot_product.subs(theta1, sp.pi).subs(theta2, 0))
min_value = sp.Min(simplified_dot_product.subs(theta1, 0).subs(theta2, 0),
simplified_dot_product.subs(theta1, sp.pi).subs(theta2, sp.pi),
simplified_dot_product.subs(theta1, 0).subs(theta2, sp.pi),
simplified_dot_product.subs(theta1, sp.pi).subs(theta2, 0))
max_value, min_value
結論
このコードを実行すると、内積の最大値が 4、最小値が 0 であることを確認できます。
sympyで(オリジナル 様の方法を参考に)
勉強中です。省略
いつもの? sympyの実行環境と 参考のおすすめです。
いつもと違うおすすめです。
・