))と同じです。
--- divmod(other)
((|other|)) で割った商と余りの配列を返します。
--- div(other)
((|other|)) で割った商を返します。(({divmod(other).first}))
と一致します。
--- %(other)
((|other|)) で割った余りを返します。(({divmod(other).last}))
と一致します。
--- divide?(other)
((|other|)) で割り切れるとき真を返します。
(({divmod(other).last == zero?}))と一致します。
--- deg
次数を返します。
例:
P = Algebra::Polynomial(Integer, "x")
x = P.var
(5*x**3 + 2*x + 1).deg #=> 3
--- lc
先頭係数(leading coeffcient)を返します。
例:
(5*x**3 + 2*x + 1).lc #=> 5
--- lm
先頭単項式(leading monomial)を返します。
例:
(5*x**3 + 2*x + 1).lm #=> x**3
--- lt
先頭項(leading term)を返します。(({lc * lm}))と等しい値を持ちます。
例:
(5*x**3 + 2*x + 1).lt #=> 5*x**3
--- rt
残余項(rest term)を返します。(({self - lt}))と等しい値を持ちます。
例:
(5*x**3 + 2*x + 1).rt #=> 2*x + 1
--- monic
最高次係数を1に直した式を返します。(({self / lc})) と同じ値を持
ちます。
--- cont
係因数(content(全ての係数の最大公約数))を返します。
--- pp
原始的部分(primitive part)を返します。(({self / cont}))と
同じ値を持ちます。
--- to_s
文字列表現を得ます。表示形式を変えるには ((|display_type|)) を用います。
((|display_type|)) に与えられる値は ((|:norm|))(デフォルト), ((|:code|))
です。
例:
P = Algebra::Polynomial(Integer, "x")
x = P.var
p 5*x**3 + 2*x + 1 #=>5x^3 + 2x + 1
P.display_type = :code
p 5*x**3 + 2*x + 1 #=> 5*x**3 + 2*x + 1
--- derivate
微分した値を返します。
例:
(5*x**3 + 2*x + 1).derivate #=> 15*x**2 + 2
--- sylvester_matrix(other)
((|other|)) とのシルベスター行列を返します。
--- resultant(other)
((|other|)) との集結式返します。予め
--- project(ring[, obj]){|c, n| ... }
各単項式について、
次数を ((|n|)) に、係数 ((|c|)) に代入し ... を評価したものを
その単項式の値に置き換え、((|ring|)) 上で和を取った値を
返します。((|obj|)) が省略されると (({ring.var})) が用いら
れます。
例:
require "polynomial"
require "rational"
P = Algebra::Polynomial(Integer, "x")
PQ = Algebra::Polynomial(Rational, "y")
x = P.var
f = 5*x**3 + 2*x + 1
p f.convert_to(PQ) #=> 5y^3 + 2y + 1
p f.project(PQ) {|c, n| Rational(c) / (n + 1)} #=> 5/4y^3 + y + 1
--- evaluate(obj)
主変数に ((|obj|)) を代入した値を返します。
(({ project(ground, obj){|c, n| c} })) の値と一致します。
例:
require "polynomial"
P = Algebra::Polynomial(Integer, "x")
x = P.var
f = x**3 - 3*x**2 + 1
p f.evaluate(-1) #=> -3 (in Integer)
p f.evaluate(x + 1) #=> x^3 - 3x - 1 (in P)
--- call(obj)
((
))と同じです。
--- sub(var, value)
変数 ((|var|)) に ((|value|)) を代入した値を返します。
例:
require "polynomial"
P = Algebra::Polynomial(Integer, "x", "y", "z")
x, y, z = P.vars
f = (x - y)*(y - z - 1)
p f.sub(y, z+1) #=> 0
--- convert_to(ring)
各項を((|ring|))上で評価します。(({ project(ring){|c, n| c} }))の
値と一致します。
= Algebra::PolynomialFactorization
((*(因数分解モジュール)*))
因数分解をするためのモジュールです。
== ファイル名:
((|polynomial-factor.rb|))
== メソッド:
--- sqfree
無平方化します。
--- sqfree?
無平方なら真を返します。
--- irreducible?
既約なら真を返します。
--- factorize
因数分解します。
因数分解可能な係数環は
* Integer
* Rational
* 素体
* 代数体(Rational 上の有限次拡大)
です。
= Algebra::SplittingField
((*(分解体モジュール)*))
多項式の最小分解体を求めるためのモジュール
== ファイル名:
* ((|splitting-field.rb|))
== メソッド:
--- decompose([fac0])
自身の最小分解体を ((|field|))、拡大に要した既約多項式
の配列を ((|def_polys|))、最小分解体上で1次式の積に因数分解し
たものを ((|facts|))、多項式の根の配列を ((|roots|))、
((|roots|)) を基礎体に添加した元が前に来るように並べ替えた
の配列を ((|proots|)) として、
[field, def_polys, facts, roots, proots]
を返します。基礎体上の因数分解 ((|fac0|)) を添えると高速化に役立ちます。
(((|facts|)) の要素と ((|fact0|)) は ((|Algebra::Factors|)) オブジェクト
、((|field|)) は
(())
オブジェクトです。ただし、自身が一次因子に分解されるときは
(()) そのものを返します。
例:
require "algebra"
PQ = Polynomial(Rational, "x")
x = PQ.var
f = x**5 - x**4 + 2*x - 2
field, def_polys, facts, roots, proots = f.decompose
p def_polys #=> [a^4 + 2, b^2 + a^2]
p facts #=> (x - 1)(x - a)(x + a)(x - b)(x + b)
p roots #=> [1, a, -a, b, -b]
p proots #=> [a, b, 1, -a, -b]
fp = Polynomial(field, "x")
x = fp.var
facts1 = Factors.new(facts.collect{|g, n| [g.call(x), n]})
p facts1.pi == f.convert_to(fp) #=> true
--- splitting_field([fac0]))
自身の最小分解体の情報を返します。返り値の各フィールドの値は以下
の通りです。poly_exps 以外は (()) の以下のものに相当します。
poly, field, roots, proots, def_polys
ただし、((|roots|))、((|proots|)) の各要素は ((|field|)) の
要素として変換されています。
例:
require "algebra"
PQ = Polynomial(Rational, "x")
x = PQ.var
f = x**5 - x**4 + 2*x - 2
sf = f.splitting_field
p sf.roots #=> [1, a, -a, b, -b]
p sf.proots #=> [a, b, 1, -a, -b]
p sf.def_polys #=> [a^4 + 2, b^2 + a^2]
= Algebra::Galois
((*(ガロア群)*))
多項式のガロア群を求めるためのモジュール
== ファイル名:
* ((|galois-group.rb|))
== インクルードしているモジュール:
* なし
== 関連するメソッド:
--- GaloisGroup.galois_group(poly)
(()) と同じ
== モジュールメソッド:
* なし
== メソッド:
--- galois_group
多項式のガロア群を返します。群は各元が
(()) である
(()) オブジェクトとして表現されます。
例:
require "rational"
require "polynomial"
P = Algebra.Polynomial(Rational, "x")
x = P.var
p( (x**3 - 3*x + 1).galois_group.to_a )
#=>[[0, 1, 2], [1, 2, 0], [2, 0, 1]]
(x**3 - x + 1).galois_group.each do |g|
p g
end
#=> [0, 1, 2]
# [1, 0, 2]
# [2, 0, 1]
# [0, 2, 1]
# [1, 2, 0]
# [2, 1, 0]
=end