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?

More than 1 year has passed since last update.

「対称式a+b+c(Symmetric polynomial)」についてwolframalphaとsympyで調べた。

Last updated at Posted at 2022-07-25

wikipediaで

WolframAlphaで

初等対称多項式の和として対称多項式を書く:

以下は,wolframでできました。

結果 {(a + b + c)^2 - 2 (a b + a c + b c), 0}

sympyで

Rewrite a polynomial in terms of elementary symmetric polynomials.

sympy.polys.polyfuncs.symmetrize(F, *gens, **args)

sympyでsymmetrizeを調べた。

以下、汎用性はありません。

from sympy import *
var('x,y'  ,real=True)
var('s1,s2',real=True)
eq=Eq(x**3-x*y+y**3,1)
print("#",           eq.lhs )
print("#",symmetrize(eq.lhs))
print("#",symmetrize(eq.lhs,formal=True))
s=symmetrize(eq.lhs,formal=True)
print("#0  ",s[0])
print("#1  ",s[1])
print("#2  ",s[2])
print("#20 ",s[2][0])
print("#21 ",s[2][1])
print("#200",s[2][0][0])
print("#201",s[2][0][1])
print("#210",s[2][1][0])
print("#211",s[2][1][1])
print()
def mySymmetrize(myLhs):
    s=symmetrize(myLhs,formal=True)
    mySubs={s[2][0][0]:s[2][0][1],s[2][1][0]:s[2][1][1]}
    return s[0].subs(mySubs).expand()
print("#",mySymmetrize(eq.lhs))

# x**3 - x*y + y**3
# (-3*x*y*(x + y) - x*y + (x + y)**3, 0)
# (s1**3 - 3*s1*s2 - s2, 0, [(s1, x + y), (s2, x*y)])
#0   s1**3 - 3*s1*s2 - s2
#1   0
#2   [(s1, x + y), (s2, x*y)]
#20  (s1, x + y)
#21  (s2, x*y)
#200 s1
#201 x + y
#210 s2
#211 x*y

# x**3 - x*y + y**3

参考

問題1

a+b+c,a^2+b^2+c^2

var('a b c')
print("#",symmetrize(a**2+b**2+c**2))
# (-2*a*b - 2*a*c - 2*b*c + (a + b + c)**2, 0)

問題2

a+b+c,a3+b3+c3-3abc

参考

未整理

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?