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?

Verification and Properties of the Golden Ratio Using SymPy「SymPyを用いた黄金比の検証と性質の確認」をAI先生に教えてもらいました。

0
Posted at

GoldenRatio: SymPyがあらかじめ用意している黄金比の定数です。

WolframAlpha で

1/2 (1 + sqrt(5))

(本日の)Gemini先生へ。

黄金比(Golden Ratio)を表す数で、一般的にギリシャ文字の $\phi$(ファイ)または $\tau$(タウ)で表されます。...
主な数学的性質
1.方程式x^2 - x - 1 = 0 の正の解です。...
2.線分の分割(黄金分割)...
3.フィボナッチ数列との関係...
4.正五角形の「対角線の長さ」と「1辺の長さ」の比は、ちょうど黄金比になります。

sympy のソースコード で教えて下さい。

SymPyでは、黄金比は組み込み定数 GoldenRatio として定義されています。また、そのまま (1 + sp.sqrt(5)) / 2 として数式処理することも可能です。
...

sympy のソースコード で教えて下さい。計算結果も。
# Calculate and verify properties of the golden ratio using SymPy
from sympy import Eq, N, S, simplify, solve, symbols, sqrt

# 1. 式として定義して数値計算する
phi_expr = (1 + sqrt(5)) / 2
print("黄金比の数式表現:", phi_expr)
print("数値近似 (10桁):", N(phi_expr, 10))

# 2. SymPyに内蔵されているビルトインの黄金比定数を使う
print("SymPy内蔵の黄金比 (S.GoldenRatio):", S.GoldenRatio)
print("内蔵定数の数値近似 (10桁):", N(S.GoldenRatio, 10))

# 3. 2次方程式 x^2 - x - 1 = 0 を解いて黄金比を導出する
x = symbols("x")
eq = Eq(x**2 - x - 1, 0)
solutions = solve(eq, x)
print("方程式 x^2 - x - 1 = 0 の解:", solutions)

# 4. 特性 (phi^2 = phi + 1) が成り立つことを記号計算で検証する
eq_check = simplify(phi_expr**2 - (phi_expr + 1))
print("phi^2 == phi + 1 の検証結果 (0になれば一致):", eq_check)
# Calculate and verify properties of the golden ratio using SymPy
from sympy import Eq, N, S, simplify, solve, symbols, sqrt

# 1. 式として定義して数値計算する
phi_expr = (1 + sqrt(5)) / 2
print("黄金比の数式表現:", phi_expr)
print("数値近似 (10桁):", N(phi_expr, 10))

# 2. SymPyに内蔵されているビルトインの黄金比定数を使う
print("SymPy内蔵の黄金比 (S.GoldenRatio):", S.GoldenRatio)
print("内蔵定数の数値近似 (10桁):", N(S.GoldenRatio, 10))

# 3. 2次方程式 x^2 - x - 1 = 0 を解いて黄金比を導出する
x = symbols("x")
eq = Eq(x**2 - x - 1, 0)
solutions = solve(eq, x)
print("方程式 x^2 - x - 1 = 0 の解:", solutions)

# 4. 特性 (phi^2 = phi + 1) が成り立つことを記号計算で検証する
eq_check = simplify(phi_expr**2 - (phi_expr + 1))
print("phi^2 == phi + 1 の検証結果 (0になれば一致):", eq_check)

実行結果(出力)

黄金比の数式表現: 1/2 + sqrt(5)/2
数値近似 (10桁): 1.618033989
SymPy内蔵の黄金比 (S.GoldenRatio): GoldenRatio
内蔵定数の数値近似 (10桁): 1.618033989
方程式 x^2 - x - 1 = 0 の解: [1/2 - sqrt(5)/2, 1/2 + sqrt(5)/2]
phi^2 == phi + 1 の検証結果 (0になれば一致): 0

(本日の)Gemini先生へ。履歴。

1. 1/2 (1 + sqrt(5))  何?
2. sympy のソースコード で教えて下さい。
3. 上記の計算結果も
4. 以上の内容の 全体の見出しを 英語と日本語で。各1行で。
5. 上記の私の質問すべてから、Markdownのテキスト形式で、質問リストを出力して。追番を追加して。本質問も含めて。コピーできる形式で。空白行不要です。

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

wikipedia で

sympy のdoc

・class sympy.core.numbers.GoldenRatio

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?