bertini is an R package that provides methods and data structures for numerical algebraic geometry, the numerical solution to (nonlinear) systems of polynomial equations using homotopy continuation.
It is still experimental, but the core functionality in the zero-dimensional case is quite stable.
Note: the following assumes you have Bertini and bertini recognizes its path.
library("bertini")
# Loading required package: mpoly
# Please cite bertini! See citation("bertini") for details.
code <- "
INPUT
variable_group x, y;
function f, g;
f = x^2 + y^2 - 1;
g = y - x;
END;
"
bertini(code)
# 2 solutions (x,y) found. (2 real, 0 complex)
# (-0.707,-0.707) (R)
# ( 0.707, 0.707) (R)
poly_solve()
is the basic workhorse for solving systems of polynomial
equations. For example, if we want to solve the system y = x and
x2 + y2 = 1, which corresponds geometrically
to the points where the identity line intersects the unit circle, we can
use:
poly_solve(c("y = x", "x^2 + y^2 = 1"), varorder = c("x", "y"))
# 2 solutions (x,y) found. (2 real, 0 complex)
# (-0.707,-0.707) (R)
# ( 0.707, 0.707) (R)
poly_optim()
can be used to find the critical points of polynomials
over varieties. For example, if we want to find the maximum value of the
function f(x, y) = x + y over the unit circle:
poly_optim("x + y", "x^2 + y^2 = 1")
# 2 critical values (x,y) found. (1 global maximum, 1 global minimum.)
# ( 0.707, 0.707) -> 1.414 (global max)
# (-0.707,-0.707) -> -1.414 (global min)
- From Github (dev version):
if (!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/mpoly")
devtools::install_github("dkahle/bertini")
This material is based upon work supported by the National Science Foundation under Grant Nos. 1622449 and 1622369.