
[index-ja] Algebra::MPolynomial / Algebra::MPolynomial::Monomial / Algebra::
MPolynomialFactorization / Algebra::Groebner

Algebra::MPolynomial

(¿ѿ¿༰ĥ饹)

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

ե̾:

  m-polynomial.rb

ѡ饹:

  Object

󥯥롼ɤƤ⥸塼:

  Enumerable
  Comparable
  Algebra::Groebner

Ϣؿ:

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

饹᥽å:

::create(ring [, obj0 [, obj1 [, ...]]])
    ringɽ륯饹򷸿ĤȤ¿ѿ¿༰ĥ饹ޤ
   
    ֥obj0, obj1, ...ѿϿͤǤ¿ѿ¿༰ĥ饹
     Algebra::MPolynomial 饹Υ֥饹Ǥ
   
    ֥obj0, obj1, ...ѿζ̤̾to_s͡ˤѤǤ
    
   
    Υ֥饹ˤϥ饹᥽åɤȤground vars졢줾졢
    ringѿ֤ޤ
   
    Ͽ줿֥ obj0, obj1, ... ɽ뤵ѿvar(obj0),
    var(obj1),... 뤳ȤǤޤʤvars == [var(obj0), var(obj1),
    ...] Ǥ
   
    ѿ羮طobj0 > obj1 > ...Ȥʤޤñ༰ν::set_ord
    ꤷޤ
   
    : 򷸿Ȥ¿༰Ĥ
    require "m-polynomial"
    P = Algebra::MPolynomial.create(Integer, "x", "y", "z")
    x, y, z = P.vars
    p((-x + y + z)*(x + y - z)*(x - y + z))
    #=> -x^3 + x^2y + x^2z + xy^2 - 2xyz + xz^2 - y^3 + y^2z + yz^2 - z^3
    p P.ground #=> integer
   
::vars([obj0 [, obj1 [, ...]]])
    1ĤʤȤϿƤƤѿȤ֤ޤ
   
    :
    P = Algebra.MPolynomial(Integer, "x", "y", "z")
    p P.vars #=> [x, y, z]
   
    1ĤʸǤȤʸֱѻ1+פʬ򤷡
    ɽѿϿޤ֥ȤϿƤпϿ
    ϤޤͤϤ줾Υ֥ȤбѿǤ
   
    :
    P = Algebra.MPolynomial(Integer)
    x, y, z, w = P.vars("a0b10cd")
    p P.vars #=> [a0, b10, c, d]
    p [x, y, z, w] #=> [a0, b10, c, d]
   
    ʳΤȤǤ륪֥ obj0, obj1, ... ɽѿ
    Ͽޤ֥ȤϿƤпϿϤޤͤ
    obj0, obj1, ...бѿǤ
   
    :
    P = Algebra.MPolynomial(Integer)
    p P.vars("x", "y", "z") #=> [x, y, z]
   
::mvar([obj0 [, obj1 [, ...]]])
    1ĤʤȤϿƤƤѿȤ֤ޤ
   
    ʳΤȤǤ륪֥ obj0, obj1, ... ɽѿ
    Ͽޤ֥ȤϿƤпϿϤޤͤ
    obj0, obj1, ... бѿǤ
   
::to_ary
    [self, *vars] ֤ޤ
   
    : ¿༰ĤѿƱ롣
    P, x, y, z, w = Algebra.MPolynomial(Integer, "a", "b", "c", "d")
   
::var(obj)
    obj Ͽ줿֥Ȥˤäɽѿ֤ޤ
   
    :
    P = Algebra.MPolynomial(Integer, "X", "Y", "Z")
    x, y, z = P.vars
    P.var("Y") == y #=> true
   
::variables
    ϿƤѿɽ륪֥Ȥ֤ޤ
   
::indeterminate(obj)
    ::var ƱǤ
   
::zero?
    ǤȤ֤ޤ
   
::zero
    ֤ޤ
   
::unity
    ñ̸֤ޤ
   
::set_ord(ord [, v_ord])
    ord ñ༰򥷥ܥǻꤷޤȤƲǽʻ :lex (
    (ǥե)):grlex (դ񼰽):grevlex (դռ
    )3ĤǤ
   
    ѿ֤νϿ줿Ͽۤ礭ˤˤʤޤv_ord
    ͿƤν֤ѹǤޤ
   
    : x, y, z = P.var("xyz") ȤȤν
    require "m-polynomial"
    P = Algebra.MPolynomial(Integer)
    x, y, z = P.vars("xyz")
    f = -5*x**3 + 7*x**2*z**2 + 4*x*y**2*z + 4*z**2
    
    P.set_ord(:lex)
    p f #=> -5x^3 + 7x^2z^2 + 4xy^2z + 4z^2
    
    f.method_cash_clear
    P.set_ord(:grlex)
    p f #=> 7x^2z^2 + 4xy^2z - 5x^3 + 4z^2
    
    f.method_cash_clear
    P.set_ord(:grevlex)
    p f #=> 4xy^2z + 7x^2z^2 - 5x^3 + 4z^2
    
    f.method_cash_clear
    P.set_ord(:lex, [2, 1, 0]) # z > y > x
    p f #=> 7x^2z^2 + 4z^2 + 4xy^2z - 5x^3
   
    ::with_ord ⻲ȤƤ
   
::get_ord
    ñ༰(:lex, :grlex, :grevlex)֤ޤ
   
::with_ord(ord [, v_ord[ [, array_of_polys]])
    ord ñ༰v_ord ѿνѴȤơ֥å¹Ԥޤ
    ֥åȴȰνޤ¿༰ array_of_polys Ϳ
    СФ method_cash_clear ¹ԤƤ顢֥å
    Ԥޤ (Υ֥åϥåɥդǤϤޤ)
   
    :
    require "m-polynomial"
    P = Algebra.MPolynomial(Integer)
    x, y, z = P.vars("xyz")
    f = -5*x**3 + 7*x**2*z**2 + 4*x*y**2*z + 4*z**2
    
    P.with_ord(:lex, nil, [f]) do
      p f    #=> -5x^3 + 7x^2z^2 + 4xy^2z + 4z^2
      p f.lt #=> -5x^3
    end
    
    P.with_ord(:grlex, nil, [f]) do
      p f    #=> 7x^2z^2 + 4xy^2z - 5x^3 + 4z^2
      p f.lt #=> 7x^2z^2
    end
    
    P.with_ord(:grevlex, nil, [f]) do
      p f    #=> 4xy^2z + 7x^2z^2 - 5x^3 + 4z^2
      p f.lt #=> 4xy^2z
    end
    
    P.with_ord(:lex, [2, 1, 0], [f]) do # z > y > x
      p f    #=> 7x^2z^2 + 4z^2 + 4xy^2z - 5x^3
      p f.lt #=> 7x^2z^2
    end
   
    ::set_ord ⻲ȤƤ
   
::monomial(ind[, c])
    multi-degree ind ǡ c ñ༰֤ޤʤAlgebra::
    MPolynomial::Monomial  extend Ƥʤ c άСñ̸
    ߤʤޤ
   

᥽å:

monomial(ind[, c])
    ::monomial Ʊ
   
constant?
    (0)ǤȤ֤ޤ
   
monomial?
    ñ༰ǤȤ֤ޤ
   
zero?
    ǤȤ֤ޤ
   
zero
    ֤ޤ
   
unity
    ñ̸֤ޤ
   
method_cash_clear
    Υ饤֥ϡƱ׻򷫤֤ʤ褦˷̤¸Ƥޤ
    򥯥ꥢޤñ༰ѹʤɤԤäɬפˤʤޤ
    
   
    ̤¸Ƥ᥽åɤϡ lc, lm, lt, rt, multideg Ǥ
   
    :
    P = Algebra.MPolynomial(Integer)
    x, y, z = P.vars("xyz")
    f = -5*x**3 + 7*x**2*z**2 + 4*x*y**2*z + 4*z**2
    P.set_ord(:lex)
    p f.lt #=> -5x^3
    P.set_ord(:grlex)
    p f.lt #=> -5x^3
    f.method_cash_clear
    p f.lt #=> 7x^2z^2
   
==(other)
    Ȥ֤ޤ
   
<=>(other)
    羮طޤ
   
+(other)
    ¤׻ޤ
   
-(other)
    ׻ޤ
   
*(other)
    Ѥ׻ޤ
   
**(n)
    n ׻ޤ
   
/(other)
    other (0)ǤȤ׻ޤ
   
divmod(f0 [, f1 [,...]])
    ¿༰ f0, f1,... ˤ껻򤷡Ⱦ;׻ޤ
    P = Algebra.MPolynomial(Integer)
    x, y = P.vars("xy")
    f = x**2*y + x*y**2 + y**2
    f0 = x*y - 1
    f1 = y**2 - 1
    p f.divmod(f0, f1) #=> [[x + y, 1], x + y + 1]
    p f % [f0, f1]     #=> x + y + 1
   
%(others)
    others ¿༰ȤȤˤ껻ξ;֤ޤ
    divmod(*others)[1] ƱǤ
   
multideg
    ¿š˼֤ޤ
   
    : (lex )
    P = Algebra.MPolynomial(Integer)
    x, y, z = P.vars("xyz")
    f = 4*x*y**2*z + 4*z**2 - 5*x**3*y + 7*x**2*z**2
    p f.multideg #=> [3, 1]
   
totdeg
    ¿ż¡ˤ֤ޤ
   
    : (lex )
    f = 4*x*y**2*z + 4*z**2 - 5*x**3*y + 7*x**2*z**2
    p f.totdeg   #=> 4
   
deg
    multideg ƱǤ
   
lc
    Ƭ(leading coeffcient)֤ޤ
   
    : (lex )
    f = 4*x*y**2*z + 4*z**2 - 5*x**3*y + 7*x**2*z**2
    p f.lc       #=> -5
   
lm
    Ƭñ༰(leading monomial)֤ޤͤAlgebra::MPolynomial::
    MonomialȤ⥸塼뤬 extend ޤ
   
    : (lex )
    f = 4*x*y**2*z + 4*z**2 - 5*x**3*y + 7*x**2*z**2
    p f.lm       #=> x^3y
   
lt
    Ƭ(leading term)֤ޤlc * lmͤޤ
   
    : (lex )
    f = 4*x*y**2*z + 4*z**2 - 5*x**3*y + 7*x**2*z**2
    p f.lt       #=> -5x^3y
   
rt
    ;(rest term)֤ޤself - ltͤޤ
   
    : (lex )
    f = 4*x*y**2*z + 4*z**2 - 5*x**3*y + 7*x**2*z**2
    p f.rt       #=> 4*z**2 - 5*x**3*y + 7*x**2*z**2
   
to_s
    ʸɽޤɽѤˤdisplay_typeѤޤ
    display_typeͿͤ :norm(ǥե), :code Ǥ
   
    :
    P = Algebra.MPolynomial(Integer)
    x, y, z = P.vars("xyz")
    f = -5*x**3 + 7*x**2*z**2 + 4*x*y**2*z + 4*z**2
    p f #=> -5x^3 + 7x^2z^2 + 4xy^2z + 4z^2
    P.display_type = :code
    p f #=> -5x**3 + 7x**2z**2 + 4xy**2z + 4z**2
   
project(ring[, vs]){|c, ind| ... }
    ¿༰˴ޤޤñ༰ˤĤơ multi-degree  ind c 
    ... ɾơring ¤ä֤ͤޤvs ά ::vars
    ͤѤޤ
   
    :
    require "m-polynomial"
    require "rational"
    P = Algebra::MPolynomial(Integer, "x", "y", "z")
    PQ = Algebra::MPolynomial(Rational, "x0", "y0", "z0")
    x, y, z = P.vars
    x0, y0, z0 = PQ.vars
    f = x**2 + 2*x*y - z**3
    p f.project(PQ) {|c, ind| Rational(c) / (ind[0] + 1)}
                            #=> 1/3x0^2 + x0y0 - z0^3
    p f.convert_to(PQ)      #=> x0^2 + 2x0y0 - z0^3
   
evaluate(obj0[, [obj1, [obj2,..]]])
    ѿ obj0, obj1, obj2,... ֤ͤޤ project(ground,
    [obj0, obj1, obj2,..]){|c, ind| c} ͤȰפޤ
   
    :
    require "m-polynomial"
    P = Algebra::MPolynomial(Integer, "x", "y", "z")
    x, y, z = P.vars
    f = x**2 + 2*x*y - z**3
    p f.evaluate(1, -1, -1) #=> 0 (in Integer)
    p f.evaluate(y, z, x)   #=> -x^3 + y^2 + 2yz (in P)
   
call(obj0[, [obj1, [obj2,..]]])
    evaluateƱǤ
   
convert_to(ring)
    ƹringɾޤproject(ring){|c, ind| c}ͤȰפޤ
   

Algebra::MPolynomial::Monomial

(ñ༰򽸤᤿⥸塼)

lt, lm ͤǤ¿༰ˤϤΥ⥸塼뤬extendޤ

᥽å:

divide?(other)
    ñ༰ other ǳڤȤ֤ޤ
   
/(other)
    ñ༰ other ǳڤޤ
   
prime_to?(other)
    ñ༰ other ǤʤȤ֤ޤ
   
lcm(other)
    ñ༰ other ȤκǾܿǤñ༰֤ޤ
   
divide_or?(other0, other1)
    divide?(other0.lcm(other1)) Ʊ֤ͤޤ
   

Algebra::MPolynomialFactorization

(ʬ⥸塼)

ʬ򤹤뤿Υ⥸塼Ǥ

ե̾:

m-polynomial-factor.rb

᥽å:

factorize
    ʬ򤷤ޤ
   
    ʬǽʷĤ
      Integer
      Rational
      
   
    Ǥ
   

Algebra::Groebner

(֥ʴ׻⥸塼)

ե̾:

  groebner-basis.rb
  groebner-basis-coeff.rb

饹᥽å:

Groebner.basis(f)
     f 󥰥֥ʴꡢȤ֤ޤ
    Groebner.basis(Groebner.minimal_basis(Groebner.basis_159A(f))) ƱǤ
   
    :
    require "m-polynomial"
    require "rational"
    P = Algebra.MPolynomial(Rational)
    P.set_ord :grevlex
    x, y, z = P.vars("xyz")
    f1 = x**2 + y**2 + z**2 -1
    f2 = x**2 + z**2 - y
    f3 = x - z
    b = Groebner.basis([f1, f2, f3])
    p b #=> [y^2 + y - 1, z^2 - 1/2y, x - z]
   
Groebner.basis_159A(f)
     f 饰֥ʴȤ֤ޤ
   
Groebner.minimal_basis(f)
    ֥ʴ f ˾֥ʴ֤ޤ
   
Groebner.reduced_basis(f)
    ˾֥ʴ f 󥰥֥ʴ֤ޤ
   
Groebner.basis_coeff(f)
     f 󥰥֥ʴȡƴ뤿η֤
    ޤ
   
    :
    require "m-polynomial"
    require "rational"
    P = Algebra.MPolynomial(Rational)
    P.set_ord :grevlex
    x, y, z = P.vars("xyz")
    f1 = x**2 + y**2 + z**2 -1
    f2 = x**2 + z**2 - y
    f3 = x - z
    fs = [f1, f2, f3]
    c, b = Groebner.basis_coeff(fs)
    p b #=> [y^2 + y - 1, z^2 - 1/2y, x - z]
    p c #=> [[1, -1, 0], [0, 1/2, -1/2x - 1/2z], [0, 0, 1]]
    for i in 0..2
      p c[i].inner_product(fs) == b[i] #=> true
    end
   
Groebner.basis?(f)
    f ֥ʴݤ֤ޤ
   
Groebner.minimal_basis?(f)
    f ˾֥ʴݤ֤ޤ
   
Groebner.reduced_basis?(f)
    f ˾֥ʴݤ֤ޤ
   

᥽å:

S_par(other)
    other Ȥ S-pair ޤ
   
    :
    (x**2*y + y**2 + z**2 -1).S_pair(x**2*z + z**2 - y)
      #=> y^2z + y^2 - yz^2 + z^3 - z
   
divmod_s(f1[, f2[, f3...]])
     f1, f2, f3, ... ǳäʳƴηˤ; [[q1, q2, q3,
    ...], r] ֤ޤ
   
     f1, f2, f3, ... 򥰥֥ʴѴƤ껻ԤΤǡdivmod
    (f1, f2, ...).last == 0  self ǥ (f1, f2, ...) °뤳ȤƱ
    Ǥ
   
    :
    require "m-polynomial"
    require "rational"
    P = Algebra.MPolynomial(Rational)
    P.set_ord :grevlex
    x, y, z = P.vars("xyz")
    f1 = x**2 + y**2 + z**2 -1
    f2 = x**2 + z**2 - y
    f3 = x - z
    fs = [f1, f2, f3]
    f = x**3 + y**3 + z**3
    c, r = f.divmod_s(*fs)
    p r #=> yz + 2y - 1
    p c #=> [y - 1, -y + z + 1, x^2]
    p f == c.inner_product(fs) + r #=> true
   

