
[index-ja] Algebra::Polynomial / Algebra::PolynomialFactorization / Algebra::
SplittingField / Algebra::Galois

Algebra::Polynomial

(1ѿ¿༰ĥ饹)

1ѿ¿༰ĤɽޤºݤΥ饹ˤϴĤꤷơ饹᥽
å ::create 뤤ϴؿ Algebra.Polynomial() Ѥޤ

ե̾:

  polynomial.rb

ѡ饹:

  Object

󥯥롼ɤƤ⥸塼:

  Enumerable
  Comparable
  Algebra::EuclidianRing
  Algebra::PolynomialFactorization
  Algebra::SplittingField
  Algebra::Galois

Ϣ᥽å:

Algebra.Polynomial(ring [, obj0 , obj1 [, ...]])
    ::create(ring, obj0[, obj1 [, ...]])> Ʊ
   

饹᥽å:

::create(ring, obj0[, obj1[, ...]])
    ring ɽ륯饹򷸿ĤȤ¿༰ĥ饹ޤ
   
    obj0, obj1, ... ǻꤵ줿֥Ȥѿɽ줬ʣʤС
    ƵŪ¿༰ľ¿༰Ĥޤ
   
    Υ᥽åɤͤ Polynomial 饹Υ֥饹ǤΥ֥饹
    ϥ饹᥽åɤȤ ground  varvars 졢줾졢
    ringѿ֥ȡʺǸ˻ꤵ줿ѿˡƤѿ֥Ȥ
    ֤ޤ
   
    ֥obj0, obj1, ...ѿ̾to_s͡ˤѤǤ
   
    : 򷸿Ȥ¿༰Ĥ
    require "polynomial"
    P = Algebra::Polynomial.create(Integer, "x")
    x = P.var
    p((x + 1)**100) #=> x^100 + 100x^99 + ... + 100x + 1
    p P.ground #=> integer
   
    : 򷸿Ȥʣѿ¿༰Ĥ
    require "polynomial"
    P = Algebra::Polynomial.create(Integer, "x", "y", "z")
    x, y, z = P.vars
    p((-x + y + z)*(x + y - z)*(x - y + z))
    #=> -z^3 + (y + x)z^2 + (y^2 - 2xy + x^2)z - y^3 + xy^2 + x^2y - x^3
    p P.var #=> z
   
     P 
    Algebra::Polynomial.create(
      Algebra::Polynomial.create(
        Algebra::Polynomial.create(
          Integer,
        "x"),
      "y"),
    "z")
   
    ƱͤǡǸѿ z ѿȤʤޤ
   
::var
    ¿༰Ĥѿʼѿˤ֤ޤ
   
::vars
    ƵŪ˳¿༰Ĥѿ򽸤᤿֤ޤ
   
::mvar
    ::vars ƱǤ
   
::to_ary
    [self, *vars] ֤ޤ
   
    : ¿༰ĤѿƱ롣
    P, x, y, z = Algebra::Polynomial.create(Integer, "x", "y", "z")
   
::variable
    ѿʼѿˤɽ륪֥Ȥ֤ޤ
   
::variables
    ƵŪ˳¿༰Ĥѿɽ륪֥Ȥ򽸤᤿֤ޤ
   
::indeterminate(obj)
    obj ɽѿƵŪõ֤ޤ
   
::monomial([n])
    n ñ༰֤ޤ
   
    :
    P = Algebra::Polynomial(Integer, "x")
    P.monomial(3) #=> x^3
   
::const(c)
     c ֤ޤ
   
    :
    P = Algebra::Polynomial(Integer, "x")
    P.const(3)      #=> 3
    P.const(3).type #=> P
   
::zero
    ֤ޤ
   
::unity
    ñ̸֤ޤ
   

᥽å:

var
    ::var ƱǤ
   
variable
    ::variable ƱǤ
   
each(&b)
    Ƽηѽ˷֤ޤ
   
    :
    P = Algebra::Polynomial(Integer, "x")
    x = P.var
    (x**3 + 2*x**2 + 4).each do |c|
      p c #=> 4, 0, 2, 1
    end
   
reverse_each(&b)
    Ƽηѽ˷֤ޤ
   
    :
    P = Algebra::Polynomial(Integer, "x")
    x = P.var
    (x**3 + 2*x**2 + 4).reverse_each do |c|
      p c #=> 1, 2, 0, 4
    end
   
[n]
    n η֤ޤ
   
[n] = v
    n ηvꤷޤ
   
monomial
    ::monomial ƱǤ
   
monomial?
    ñ༰ǤȤ֤ޤ
   
zero?
    ǤȤ֤ޤ
   
zero
    ֤ޤ
   
unity
    ñ̸֤ޤ
   
==(other)
    Ȥ֤ޤ
   
<=>(other)
    羮طޤ
   
+(other)
    ¤׻ޤ
   
-(other)
    ׻ޤ
   
*(other)
    Ѥ׻ޤ
   
**(n)
    n ׻ޤ
   
/(other)
    ׻ޤdivƱǤ
   
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)
    evaluateƱǤ
   
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
    Τźä addelems Ȥơ
    [field, def_polys, facts, roots, addelems]
   
    ֤ޤξΰʬ fac0 źȹ®Ωޤfacts
    Ǥ fact0  Algebra::Factors ֥ȡfield 
    AlgebraicExtensionField ֥ȤǤȤ켡Ҥʬ򤵤
    Ȥ groud ΤΤ֤ޤ
   
    :
    require "algebra"
    PQ = Polynomial(Rational, "x")
    x = PQ.var
    f = x**4 + 2
    field, def_polys, facts, roots, addelems = f.decompose
    p def_polys #=> [a^4 + 2, b^2 + a^2]
    p facts    #=> (x - a)(x + a)(x - b)(x + b)
    p roots    #=> [a, b, a, -b]
    p addelems #=> [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 ʳ decompose ΰʲΤΤޤ
   
    poly, field, roots, def_polys, poly_exps
   
     poly_exp ϡ¾κɽǽʺǤ
   
    :
    require "algebra"
    PQ = Polynomial(Rational, "x")
    x = PQ.var
    f = x**4 + 2
    sf = f.splitting_field
    p sf.roots     #=> [a, b, -a, -b]
    p sf.def_polys #=> [a^4 + 2, b^2 + a^2]
    p sf.poly_exps #=> [-a, -b]
   

Algebra::Galois

()

¿༰Υ뤿Υ⥸塼

ե̾:

  galois-group.rb

󥯥롼ɤƤ⥸塼:

  ʤ

Ϣ᥽å:

GaloisGroup.galois_group(poly)
    galois_group Ʊ
   

⥸塼᥽å:

  ʤ

᥽å:

galois_group
    ¿༰Υ֤ޤϳƸ PermutationGroup Ǥ FiniteGroup
    ֥ȤȤɽޤ
   
    :
    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]
   

