bertini: R Interface to Bertini

View source: R/bertini.R

bertiniR Documentation

R Interface to Bertini

Description

Back-end connections to Bertini (https://bertini.nd.edu) executables and front-end tools facilitating its use in the R ecosystem.

Write a Bertini file, evaluate it through a back-end connection to Bertini, and bring the output back into R.

Usage

bertini(
  code,
  dir = tempdir(),
  quiet = TRUE,
  output = c("zero_dim", "pos_dim"),
  parameter_homotopy = FALSE
)

Arguments

code

Bertini code as either a character string, or bertini_input object; see examples

dir

directory to place the files in, without an ending /

quiet

show bertini output

output

the type of output expected (zero-dimensional or positive-dimensional)

parameter_homotopy

logical indicating if the run is a parameter homotopy.

Value

an object of class bertini

Examples


if (has_bertini()) {

# where does the circle intersect the line y = x?
code <- "
INPUT

variable_group x, y;
function f, g;

f = x^2 + y^2 - 1;
g = y - x;

END;
"
bertini(code)
c(sqrt(2)/2, sqrt(2)/2)
str(bertini(code), 1L, give.attr = FALSE)



# where do the surfaces
#  x^2 - y^2 - z^2 - 1/2
#  x^2 + y^2 + z^2 - 9
#  x^2/4 + y^2/4 - z^2
# intersect?
#
code <- "
INPUT

variable_group x, y, z;
function f, g, h;

f = x^2 - y^2 - z^2 - 1/2;
g = x^2 + y^2 + z^2 - 9;
h = x^2/4 + y^2/4 - z^2;

END;
"
bertini(code)

# algebraic solution :
c(sqrt(19)/2, 7/(2*sqrt(5)), 3/sqrt(5)) # +/- each ordinate




# example from bertini manual
code <- "
INPUT

variable_group x, y;
function f, g;

f = x^2 - 1;
g = x + y - 1;

END;
"
out <- bertini(code)
str(out)





# non zero-dimensional example
code <- "
CONFIG
  TRACKTYPE: 1;
END;

INPUT
  variable_group x, y, z;
  function f1, f2;
  f1 = x^2-y;
  f2 = x^3-z;
END;
"
bertini(code, output = "pos_dim")



# using a bertini_input object

polys <- mp(c("x^2 + y^2 - 1", "x - y"))
struct <- bertini_input(polys)
bertini(struct)










}


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