Title: | Utilities for Multivariate Polynomials with Rational Coefficients |
---|---|
Description: | Computation of resultant, subresultants, greatest common divisor, integral division (aka division without remainder) of two multivariate polynomials with rational coefficients, Sturm-Habicht sequence and square-free factorization of a multivariate polynomial with rational coefficients. The computations are performed by the 'C++' library 'CGAL' (<https://www.cgal.org/>). Resultants have applications in polynomial systems solving, number theory, and algebraic geometry. The package also contains some functions computing the number of real roots of a univariate polynomial with rational coefficients, and a function computing the division with remainder of two univariate polynomials with rational coefficients. |
Authors: | Stéphane Laurent [aut, cre] |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-19 03:25:10 UTC |
Source: | https://github.com/stla/resultant |
Greatest common divisor of two polynomials with rational coefficients.
gcd(qspray1, qspray2, utcf = FALSE)
gcd(qspray1, qspray2, utcf = FALSE)
qspray1 , qspray2
|
two |
utcf |
Boolean, whether to get the greatest common divisor up to a constant factor (this can be faster) |
A qspray
polynomial.
library(resultant) x <- qlone(1) y <- qlone(2) g <- x^2 + 2*x*y + 1 p <- g * (y^2 + x^2) q <- g * (y + x^3 + 2) gcd(p, q)
library(resultant) x <- qlone(1) y <- qlone(2) g <- x^2 + 2*x*y + 1 p <- g * (y^2 + x^2) q <- g * (y + x^3 + 2) gcd(p, q)
Integral division (division without remainder) of two polynomials with rational coefficients.
integralDivision(qspray1, qspray2, check = TRUE)
integralDivision(qspray1, qspray2, check = TRUE)
qspray1 , qspray2
|
two |
check |
Boolean, whether to check that |
If check=TRUE
, this returns NULL
if qspray2
does not divide qspray1
, otherwise this returns a qspray
polynomial, the quotient of qspray1
by qspray2
.
If check=FALSE
, this always returns a qspray
polynomial,
which is the quotient of qspray1
by qspray2
if
qspray2
divides qspray1
, otherwise it is an undefined
polynomial. So you can use check=FALSE
only when you are sure that
qspray2
divides qspray1
.
univariateDivision
,
qsprayDivision
.
library(resultant) x <- qlone(1) y <- qlone(2) q <- x^2 + 2*x*y + 1 qspray1 <- q * (x^4 + y^2 + 2) qspray2 <- x^4 + y^2 + 2 integralDivision(qspray1, qspray2) == q # should be TRUE
library(resultant) x <- qlone(1) y <- qlone(2) q <- x^2 + 2*x*y + 1 qspray1 <- q * (x^4 + y^2 + 2) qspray2 <- x^4 + y^2 + 2 integralDivision(qspray1, qspray2) == q # should be TRUE
Number of distinct real roots of a univariate polynomial.
numberOfRealRoots(qspray)
numberOfRealRoots(qspray)
qspray |
a univariate |
An integer, the number of real roots of the polynomial.
The roots are not counted with their multiplicity.
library(resultant) x <- qlone(1) P <- 2*x^4 + x^3 - 3*x^2 - x + 1 numberOfRealRoots(P)
library(resultant) x <- qlone(1) P <- 2*x^4 + x^3 - 3*x^2 - x + 1 numberOfRealRoots(P)
Number of distinct real roots of a univariate polynomial in a given interval.
numberOfRealRootsInInterval(qspray, lower, upper, closed = TRUE)
numberOfRealRootsInInterval(qspray, lower, upper, closed = TRUE)
qspray |
a univariate |
lower , upper
|
the bounds of the interval, |
closed |
Boolean, whether to consider the interval is closed or open |
An integer, the number of real roots of the polynomial in the interval.
The roots are not counted with their multiplicity.
library(resultant) x <- qlone(1) P <- 2*x^4 + x^3 - 3*x^2 - x + 1 numberOfRealRootsInInterval(P, 0, 1)
library(resultant) x <- qlone(1) P <- 2*x^4 + x^3 - 3*x^2 - x + 1 numberOfRealRootsInInterval(P, 0, 1)
Principal Sturm-Habicht sequence of a polynomial with rational coefficients.
principalSturmHabicht(qspray, var = 1)
principalSturmHabicht(qspray, var = 1)
qspray |
a |
var |
integer indicating with respect to which variable the resultant
is desired (e.g. |
For a univariate polynomial, this returns a vector of bigq
rational numbers.
For a multivariate polynomial, this returns a list of qspray
polynomials that do not involve the var
-th variable.
library(resultant) x <- qlone(1) y <- qlone(2) qspray <- x^3*y^2 - 5*x*y^2 + 7*x - 2 principalSturmHabicht(qspray, var = 1) principalSturmHabicht(qspray, var = 2)
library(resultant) x <- qlone(1) y <- qlone(2) qspray <- x^3*y^2 - 5*x*y^2 + 7*x - 2 principalSturmHabicht(qspray, var = 1) principalSturmHabicht(qspray, var = 2)
Principal subresultants of two polynomials with rational coefficients.
principalSubresultants(qspray1, qspray2, var = 1)
principalSubresultants(qspray1, qspray2, var = 1)
qspray1 , qspray2
|
two |
var |
integer indicating with respect to which variable the
subresultants are desired (e.g. |
If both qspray1
and qspray2
are univariate polynomials,
the function returns a vector of bigq
rational numbers.
Otherwise, it returns a list of qspray
polynomials that do not
involve the var
-th variable.
library(resultant) x <- qlone(1) y <- qlone(2) p <- x^2 * y * (y^2 - 5*x + 6) q <- x^2 * y * (3*y + 2) principalSubresultants(p, q, var = 1) # should be 0, 0, non-zero, ... principalSubresultants(p, q, var = 2) # should be 0, non-zero, ...
library(resultant) x <- qlone(1) y <- qlone(2) p <- x^2 * y * (y^2 - 5*x + 6) q <- x^2 * y * (3*y + 2) principalSubresultants(p, q, var = 1) # should be 0, 0, non-zero, ... principalSubresultants(p, q, var = 2) # should be 0, non-zero, ...
Resultant of two polynomials with rational coefficients.
resultant(qspray1, qspray2, var = 1)
resultant(qspray1, qspray2, var = 1)
qspray1 , qspray2
|
two |
var |
integer indicating with respect to which variable the resultant
is desired (e.g. |
If both qspray1
and qspray2
are univariate polynomials,
the function returns a bigq
rational number.
Otherwise, it returns a qspray
polynomial that does not involve
the var
-th variable.
library(resultant) x <- qlone(1) y <- qlone(2) f <- x^4 - x^3 + x^2 - 2*x*y^2 + y^4 g <- x - 2*y^2 resultant(f, g, var = 1) resultant(f, g, var = 2)
library(resultant) x <- qlone(1) y <- qlone(2) f <- x^4 - x^3 + x^2 - 2*x*y^2 + y^4 g <- x - 2*y^2 resultant(f, g, var = 1) resultant(f, g, var = 2)
Square-free factorization of a polynomial with rational coefficients.
squareFreeFactorization(qspray)
squareFreeFactorization(qspray)
qspray |
a |
A list with two fields constantFactor
and
nonConstantFactors
. In the field constantFactor
, there is
a bigq
rational number, the constant factor of the factorization.
In the field nonConstantFactors
, there is a list providing the
square-free and pairwise coprime qspray
polynomials of the
factorization with their multiplicity.
library(resultant) x <- qlone(1) y <- qlone(2) p <- x^8*y^7 + 2*x^7*y^5 + x^6*y^4 + 2*x^5*y^2 squareFreeFactorization(p)
library(resultant) x <- qlone(1) y <- qlone(2) p <- x^8*y^7 + 2*x^7*y^5 + x^6*y^4 + 2*x^5*y^2 squareFreeFactorization(p)
Sturm-Habicht sequence of a polynomial with rational coefficients.
SturmHabicht(qspray, var = 1)
SturmHabicht(qspray, var = 1)
qspray |
a |
var |
index of the variable with respect to which the Sturm-Habicht sequence will be computed |
A list of qspray
polynomials, the Sturm-Habicht sequence of
qspray
, starting with the 0
-th Sturm-Habicht polynomial.
library(resultant) x <- qlone(1) y <- qlone(2) SturmHabicht(x^3*y^2 + 2*x*y + 1)
library(resultant) x <- qlone(1) y <- qlone(2) SturmHabicht(x^3*y^2 + 2*x*y + 1)
Subresultants of two polynomials with rational coefficients.
subresultants(qspray1, qspray2, var = 1)
subresultants(qspray1, qspray2, var = 1)
qspray1 , qspray2
|
two |
var |
integer indicating with respect to which variable the
subresultants will be computed (e.g. |
A list of qspray
polynomials.
library(resultant) x <- qlone(1) y <- qlone(2) p <- x^2 * y * (y^2 - 5*x + 6) q <- x^2 * y * (3*y + 2) subresultants(p, q, var = 1) subresultants(p, q, var = 2)
library(resultant) x <- qlone(1) y <- qlone(2) p <- x^2 * y * (y^2 - 5*x + 6) q <- x^2 * y * (3*y + 2) subresultants(p, q, var = 1) subresultants(p, q, var = 2)
Division with remainder of univariate polynomials with rational coefficients.
univariateDivision(qspray1, qspray2)
univariateDivision(qspray1, qspray2)
qspray1 , qspray2
|
two univariate |
A list of two univariate qspray
polynomials, the quotient
of the division in the field Q
of the list, and the remainder in
the field R
.
integralDivision
,
qsprayDivision
.
library(resultant) x <- qlone(1) qspray1 <- 2*x^4 + x^3 - 3*x^2 - x + 1 qspray2 <- x^2 - 5*x + 10 division <- univariateDivision(qspray1, qspray2) Q <- division[["Q"]]; R <- division[["R"]] qspray1 == Q*qspray2 + R # should be TRUE
library(resultant) x <- qlone(1) qspray1 <- 2*x^4 + x^3 - 3*x^2 - x + 1 qspray2 <- x^2 - 5*x + 10 division <- univariateDivision(qspray1, qspray2) Q <- division[["Q"]]; R <- division[["R"]] qspray1 == Q*qspray2 + R # should be TRUE