poly_solve: Solve a System of Polynomial Equations

View source: R/poly_solve.R

poly_solveR Documentation

Solve a System of Polynomial Equations

Description

poly_solve() solves a system of polynomial equations, specifiable in any of several ways.

Usage

poly_solve(lhs, rhs, varorder, ...)

Arguments

lhs

a mpolyList or character vector of left hand sides

rhs

a mpolyList or character vector of right hand sides

varorder

variable order (see examples)

...

stuff to pass to bertini

Value

an object of class bertini

See Also

variety(), bertini()

Examples


if (has_bertini()) {

# it can solve linear systems
# (here where the line y = x intersects y = 2 - x)
poly_solve(c("y", "y"), c("x", "2 - x"), c("x", "y"))

# or nonlinear systems
poly_solve(c("y", "y"), c("x^2", "2 - x^2"), c("x", "y"))

# perhaps an easier specification is equations themselves
# with either the " = " or " == " specifications
# varorder is used to order the solutions returned
poly_solve(c("y = x^2", "y = 2 - x^2"), varorder = c("x", "y"))
poly_solve(c("y == x^2", "y == 2 - x^2"), varorder = c("x", "y"))


# mpoly objects can be given instead of character strings
lhs <- mp(c("y - (2 - x)", "x y"))
rhs <- mp(c("0","0"))
poly_solve(lhs, rhs, varorder = c("x", "y"))

# if no default right hand side is given, and no "=" or "==" is found,
# rhs is taken to be 0's.
# below is where the lines y = x and y = -x intersect the unit circle
poly_solve(c("(y - x) (y + x)", "x^2 + y^2 - 1"))

# the output object is a bertini object
out <- poly_solve(c("(y - x) (y + x)", "x^2 + y^2 - 1"))
str(out, 1)

# here is the code that was run :
cat(out$bertini_code)

# the finite and real solutions:
out$finite_solutions
out$real_finite_solutions



# (known priting issue)
# example from Riccomagno (2008), p. 399
# poly_solve(c(
#   "x (x - 2) (x - 4) (x - 3)",
#   "(y - 4) (y - 2) y",
#   "(y - 2) (x + y - 4)",
#   "(x - 3) (x + y - 4)"
# ))

}


dkahle/bertini documentation built on July 16, 2022, 9:26 a.m.