from sympy import *

# 連想ラゲール多項式の次数とパラメータを設定
n_assoc_laguerre = 3
alpha_assoc_laguerre = 1

# エルミート多項式の次数を設定
n_hermite = 3

# ルジャンドル陪多項式の次数とパラメータを設定
n_legendre = 3
m_legendre = 1

# シンボルを定義
x, y = symbols('x y')

# 式を定義
expression = (x + 3*y) * (x - 1) * (y**2 + x)

# 式を展開
expanded_expression = expand(expression)

print(f"元の式: {expression}")
print(f"展開された式: {expanded_expression}")


# 被微分関数を定義（例: f(x) = x^3 - 3x^2 + 2x - 1）
f = x**3 - 3*x**2 + 2*x - 1

# 微分
df = diff(f, x)

print(f"関数 f(x): {f}")
print(f"微分された関数 f'(x): {df}")

# ラゲール陪多項式を生成
assoc_laguerre_poly = assoc_laguerre(n_assoc_laguerre, alpha_assoc_laguerre, x)
expanded_assoc_laguerre_poly = expand(assoc_laguerre_poly)

# エルミート多項式を生成
hermite_poly = hermite(n_hermite, x)
expanded_hermite_poly = expand(hermite_poly)

# ルジャンドル陪多項式を生成
assoc_legendre_poly = assoc_legendre(n_legendre, m_legendre, x)
expanded_assoc_legendre_poly = expand(assoc_legendre_poly)

print(f"連想ラゲール多項式 L_{n_assoc_laguerre}^{({alpha_assoc_laguerre})}(x): {assoc_laguerre_poly}")
print(f"展開された連想ラゲール多項式: {expanded_assoc_laguerre_poly}\n")

print(f"エルミート多項式 H_{n_hermite}(x): {hermite_poly}")
print(f"展開されたエルミート多項式: {expanded_hermite_poly}\n")

print(f"ルジャンドル陪多項式 P_{n_legendre}^{({m_legendre})}(x): {assoc_legendre_poly}")
print(f"展開されたルジャンドル陪多項式: {expanded_assoc_legendre_poly}\n")
