Skip to content
piotrmgsPublic

About

Classification of quadratic polynomial maps of the plane up to affine equivalence

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

quadplane

quadplane classifies quadratic polynomial maps of the plane up to affine changes of coordinates.

A quadratic map of the plane is a pair f = (g, h) of polynomials of degree at most two in (x, y) with real coefficients, for example f(x, y) = (x^2 + y, y^2 + x). Two maps are equivalent if f2 = L ∘ f1 ∘ R for invertible affine maps L and R of the plane (a change of coordinates in the target and in the source). Farnik and Jelonek proved that there are exactly 17 equivalence classes (orbits) over the complex numbers and 21 over the real numbers, and listed a normal form for each [1]. quadplane decides to which orbit a given map belongs, and computes the objects attached to it: the critical set, the set of critical values and the discriminant.

It is meant for mathematicians and applied scientists who meet such maps (singularity theory, real algebraic geometry, noninvertible planar maps in dynamics, quadratic models) and want a reproducible answer to "which map is this, up to coordinates?".

  • Two modes: EXACT (rational coefficients, rational arithmetic) and FLOAT (floating-point coefficients, with a statement of how reliable the answer is).
  • Pure Python (3.10 or newer, tested with 3.10 to 3.14), no compiled code. FLOAT mode has no dependencies; EXACT mode and the critical values need SymPy.

Installation

quadplane is distributed through GitHub.

python -m pip install "quadplane[exact] @ git+https://github.com/piotrmgs/quadplane"

[exact] also installs SymPy; leave it out (python -m pip install "quadplane @ git+https://github.com/piotrmgs/quadplane") if you only need FLOAT mode. If git is not installed, use the archive of the repository:

python -m pip install "quadplane[exact] @ https://github.com/piotrmgs/quadplane/archive/refs/heads/main.zip"

To work from a copy of the repository:

git clone https://github.com/piotrmgs/quadplane
cd quadplane
python -m pip install -e ".[exact]"

To check the installation, print the version:

python -c "import quadplane; print(quadplane.__version__)"

Quick start

A polynomial a x^2 + b xy + c y^2 + d x + e y + f is entered as Coeffs(a, b, c, d, e, f).

from quadplane import Coeffs, QuadraticMap, classify

# f(x, y) = (x^2 - y, y^2 + 2x)
f = QuadraticMap(
    g=Coeffs(1, 0, 0, 0, -1, 0),
    h=Coeffs(0, 0, 1, 2, 0, 0),
)
result = classify(f)

print(f)
print(result)
print(result.best_orbit_id(), result.confidence.value)
(x^2 - y, y^2 + 2*x)
orbit f1 over R (certified); stored input: f1
f1 certified

The map is in the orbit f1, the orbit of the normal form (x^2 + y, y^2 + x):

from quadplane import Field, orbit_info, orbit_representative

print(orbit_representative("f1"))
info = orbit_info("f1", field=Field.REAL)
print(info.dimension, info.mu, info.proper, "|", info.critical_set)
(x^2 + y, y^2 + x)
12 4 True | hyperbola 4xy = 1

With SymPy installed, maps can be written as formulas and classified exactly:

from quadplane import Mode, map_from_expr

f = map_from_expr("x^2 - y", "y^2 + 2*x")
result = classify(f, mode=Mode.EXACT)
print(result.best_orbit_id(), result.confidence.value)
f1 exact

More examples are in examples/ and in the user guide.

Reading the result

classify(f, field=..., mode=...) returns a ClassificationResult.

attribute meaning
orbit_id_real, orbit_id_complex the reported orbit over R and over C (best_orbit_id() returns the real one when field=Field.REAL)
confidence how the answer was obtained: exact, certified, numerical or uncertain (see below)
exact_orbit_id_real, exact_orbit_id_complex the orbit of the stored input: rational coefficients as given, floats as the binary numbers they are
candidates all orbits compatible with the tests when the answer is numerical or uncertain
certificate the invariants behind the decision (Jacobian, the matrices Φ1, Φ2, Ψ1, their determinants and ranks)
diagnostics the individual tests with their margins

Orbits. The identifiers f1, ..., f17 are those of [1]. Over the reals the orbits f1, f4, f7, f13 split in two; the second real orbit is called f1_0, f4_0, f7_0, f13_0. field=Field.REAL (default) classifies up to real affine maps, field=Field.COMPLEX up to complex ones; the coefficients of the input are real in both cases.

orbit normal form critical set over R dim μ
f1 (x^2 + y, y^2 + x) hyperbola 12 4
f1_0 (x^2 - y^2 + x, 2*x*y - y) ellipse 12 4
f2 (x^2 + y, x*y) parabola 11 3
f3 (x^2 + y, y^2) intersecting lines 11 4
f4 (x^2, y^2) intersecting lines 10 4
f4_0 (x^2 - y^2, x*y) point 10 4
f5 (x^2 - x, x*y) parallel lines 10 2
f6 (x^2, x*y) double line 9 2
f7 (x*y, x + y) line 10 2
f7_0 (x^2 + y^2, x) line 10 2
f8 (x, x*y) line 9 1
f9 (x^2, y) line 9 2
f10 (x^2 + y, x) empty 8 1
f11 (x^2, x) plane 7 -
f12 (x, y) empty 6 1
f13 (x*y, 0) plane 8 -
f13_0 (x^2 + y^2, 0) plane 8 -
f14 (x^2 + y, 0) plane 7 -
f15 (x^2, 0) plane 6 -
f16 (x, 0) plane 5 -
f17 (0, 0) plane 2 -

Here "dim" is the dimension of the orbit in the 12-dimensional space of quadratic maps and μ the number of preimages of a generic point over C ("-" if the map is not generically finite). See docs/orbits.md.

Exact mode (mode=Mode.EXACT). Coefficients must be rational: int, fractions.Fraction, decimal.Decimal, SymPy rationals, or floats that are binary fractions with a small denominator (such as 0.5). All computations are rational, and the answer is the orbit of the input (confidence is exact). A float such as 0.1 is rejected, because the stored number is not 1/10 and no rounding is ever applied. Compared with the default mode, exact mode gives no answer at a tolerance, refuses floats that are not short binary fractions instead of taking them as binary numbers, and is the mode in which critical values, discriminants and the lines of a degenerate critical set are computed.

Floating-point mode (mode=Mode.FLOAT, the default). No exact number is rounded: an int, Fraction, Decimal or SymPy rational is used as it is, and a float is the binary number it holds (0.1 is not 1/10); only other real numbers, such as sympy.sqrt(2), are rounded to the nearest float. The orbit of this stored input is computed without rounding errors (exact_orbit_id_*). In addition each step of the decision is checked against perturbations of the coefficients of relative size tol (default 1e-10):

confidence meaning
certified The reported orbit is the orbit of the stored input, and no step of the decision is sensitive to perturbations up to tol. For the two open orbits f1, f1_0 this means: every map whose coefficients differ from the input by at most tol (relative to the largest coefficient of the same component) lies in the same orbit.
numerical The stored input lies in exact_orbit_id_*, but the quantities that distinguish it from a more special orbit are below their perturbation bounds, so the tests cannot tell the two apart at this tolerance. The more special orbit is reported. Typical cause: coefficients of a special map that were rounded or computed in floating point. It is not a proof that a map of the reported orbit lies within the tolerance.
uncertain At least one quantity is too close to its threshold to decide between the two cases; candidates lists the possibilities.
# (x^2 + eps*y, y^2 + eps*x) is in f1 for eps != 0 and equals the normal form f4 for eps = 0.
eps = 1e-12
g = QuadraticMap(g=Coeffs(1, 0, 0, 0, eps, 0), h=Coeffs(0, 0, 1, eps, 0, 0))
result = classify(g)
print(result.orbit_id_real, result.confidence.value, result.exact_orbit_id_real, result.candidates)
f4 numerical f1 ('f1', 'f4')

The precise definitions, the proofs of these statements and advice on the choice of tol are in docs/float_mode.md.

Critical set, critical values, discriminant

from quadplane import critical_type, critical_values

print(critical_type(f))  # type of the critical set {J(f) = 0}, a conic

cv = critical_values(f)  # closure of f(critical set), in target coordinates (u, v)
print(cv.kind.value, cv.degree)
print(cv.generators[0].as_expr())
print(len(cv.singularities))
hyperbola
curve 4
64*u**3 - 16*u**2*v**2 - 72*u*v + 16*v**3 + 27
3

critical_values and discriminant work in exact mode and return generators of an ideal of polynomials in (u, v), together with its factorization, singular points and isolated points. See docs/user_guide.md.

Which mode is the default. classify, critical_type and critical_set use Mode.FLOAT unless mode=Mode.EXACT is given. critical_values, discriminant and critical_analyze return exact objects (polynomials, lines) and use Mode.EXACT: they need SymPy and rational coefficients (int, Fraction, Decimal; a decimal number c can be converted with Fraction(str(c))). critical_analyze(f, mode=Mode.FLOAT) gives the type of the critical set of a map with floating-point coefficients.

Limitations

  • classify and the functions for the critical set, the critical values and the discriminant need real numerical coefficients; complex numbers and symbols are not accepted there. The invariant functions (jacobian_coeffs, phi1_det, phi2_det, psi1_matrix, ...) use only +, - and * and also accept SymPy expressions, for example the coefficients of a family of maps with parameters (see the user guide).
  • The affine maps L and R that bring a map to its normal form are not computed.
  • Critical values and discriminant are given by polynomial equations, i.e. as Zariski closures. Over the reals the actual set of critical values can be smaller than the real zero set of these equations (for (x^2, y^2) it consists of two half-lines, the equation uv = 0 describes two lines).
  • In FLOAT mode the statements certified and exact_orbit_id_* concern the stored input. For a float this is the binary number in the computer, which may differ from the number you typed (0.1 is not 1/10; write Fraction("0.1") or Decimal("0.1") for the exact decimal). A numerical answer says that the tests cannot distinguish the input from a more special orbit at the given tolerance; it is not a proof that a map of that orbit lies within the tolerance.
  • The tolerance is measured in the given source coordinates (x, y). Multiplying g or h by a power of two (for rational coefficients: by any nonzero rational) changes nothing in the result, but rescaling x or y can change the reported orbit and its confidence (exact_orbit_id_* stays the same whenever the rescaled coefficients are stored without rounding). A component that is very small compared with the other one is not treated as zero.
  • Affine equivalence does not preserve the dynamics of a map under iteration; the classification concerns the map as a single map (critical set, critical values, number of preimages).

Documentation

Tests and development

python -m pip install -e ".[exact,dev]"
pytest                 # test suite; also runs every code block of this README and of docs/
ruff check .           # lint
ruff format --check .  # formatting
mypy                   # static types of src/quadplane

pytest also works without installing the package (from the repository root), and without SymPy; the tests that need SymPy are then skipped.

How to cite

If you use quadplane, please cite the software (see CITATION.cff) and the paper containing the classification:

[1] M. Farnik, Z. Jelonek, On quadratic polynomial mappings of the plane, Linear Algebra and its Applications 529 (2017) 441–456, https://doi.org/10.1016/j.laa.2017.05.020.

License

BSD 3-Clause, see LICENSE.txt.

About

Classification of quadratic polynomial maps of the plane up to affine equivalence

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages