Invariants

Functions for retrieving invariants of knots and links.

Many of these functions can be called in a more convenient way via methods of the space curve classes (e.g. Knot) or the Representation class.

Mathematica

Functions whose name ends with _mathematica try to create an external Mathematica process to calculate the answer. They may hang or have other problems if Mathematica isn’t available in your $PATH, so be careful using them.

Warning

This module may be broken into multiple components at some point.

API documentation

pyknotid.invariants.alexander(representation, variable=-1, quadrant='lr', simplify=True, mode='python')[source]

Calculates the Alexander polynomial of the given knot. The representation must have just one knot component, or the calculation will fail or potentially give bad results.

The result is returned with whatever numerical precision the algorithm produces, it is not rounded.

The given representation must be simplified (RM1 performed if possible) for this to work, otherwise the matrix has overlapping elements. This is so important that this function automatically calls pyknotid.representations.gausscode.GaussCode.simplify(), you must disable this manually if you don’t want to do it.

Note

If ‘maxima’ or ‘mathematica’ is chosen as the mode, the variable will automatically be set to t.

Note

If the mode is ‘cypari’, the quadrant argument will be ignored and the upper-left quadrant always used.

Parameters:
  • representation (Anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)).
  • variable (float or complex or sympy variable) – The value to caltulate the Alexander polynomial at. Defaults to -1, but may be switched to the sympy variable t in the future. Supports int/float/complex types (fast, works for thousands of crossings) or sympy expressions (much slower, works mostly only for <100 crossings).
  • quadrant (str) – Determines what principal minor of the Alexander matrix should be used in the calculation; all choices should give the same answer. Must be ‘lr’, ‘ur’, ‘ul’ or ‘ll’ for lower-right, upper-right, upper-left or lower-left respectively.
  • simplify (bool) – Whether to call the GaussCode simplify method, defaults to True.
  • mode (string) – One of ‘python’, ‘maxima’, ‘cypari’ or ‘mathematica’. denotes what tools to use; if python, the calculation is performed with numpy or sympy as appropriate. If maxima or mathematica, that program is called by the function - this will only work if the external tool is installed and available. Defaults to python.
pyknotid.invariants.alexander_cypari(representation, quadrant='ul', verbose=False, simplify=True)[source]

Returns the Alexander polynomial of the given representation, by calculating the matrix determinant via cypari, a python interface to Pari-GP.

The function only supports evaluating at the variable t.

The returned object is a cypari query type.

Parameters:
  • representation (Anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)).
  • quadrant (str) – Determines what principal minor of the Alexander matrix should be used in the calculation; all choices should give the same answer. Must be ‘lr’, ‘ur’, ‘ul’ or ‘ll’ for lower-right, upper-right,
  • verbose (bool) – Whether to print information about the procedure. Defaults to False.
  • simplify (bool) – If True, tries to simplify the representation before calculating the polynomial. Defaults to True.
pyknotid.invariants.alexander_mathematica(representation, quadrant='ul', verbose=False, via_file=True)[source]

Returns the Alexander polynomial of the given representation, by creating a Mathematica process and running its knot routines. The Mathematica installation must include the KnotTheory package.

The function only supports evaluating at the variable t.

Parameters:
  • representation (Anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)).
  • quadrant (str) – Determines what principal minor of the Alexander matrix should be used in the calculation; all choices should give the same answer. Must be ‘lr’, ‘ur’, ‘ul’ or ‘ll’ for lower-right, upper-right,
  • verbose (bool) – Whether to print information about the procedure. Defaults to False.
  • via_file (bool) – If True, calls Mathematica via a written file mathematicascript.m, otherwise calls Mathematica directly with runMath. The latter had a nasty bug in at least one recent Mathematica version, so the default is to True.
  • simplify (bool) – If True, tries to simplify the representation before calculating the polynomial. Defaults to True.
pyknotid.invariants.alexander_maxima(representation, quadrant='ul', verbose=False, simplify=True)[source]

Returns the Alexander polynomial of the given representation, by calculating the matrix determinant in maxima.

The function only supports evaluating at the variable t.

Parameters:
  • representation (Anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)).
  • quadrant (str) – Determines what principal minor of the Alexander matrix should be used in the calculation; all choices should give the same answer. Must be ‘lr’, ‘ur’, ‘ul’ or ‘ll’ for lower-right, upper-right,
  • verbose (bool) – Whether to print information about the procedure. Defaults to False.
  • simplify (bool) – If True, tries to simplify the representation before calculating the polynomial. Defaults to True.
pyknotid.invariants.arnold_2St_2Jminus(representation)[source]

Returns J- + 2 * St where J+ and St are Arnold’s invariants of plane curves.

See ‘Invariants of curves and fronts via Gauss diagrams’, M Polyak, Topology 37, 1998.

pyknotid.invariants.arnold_2St_2Jplus(representation)[source]

Returns J+ + 2 * St where J+ and St are Arnold’s invariants of plane curves.

The calculation is performed by transforming the representation into a representation of an unknot by flipping crossings, then calculating the second order writhe.

See ‘Invariants of curves and fronts via Gauss diagrams’, M Polyak, Topology 37, 1998.

pyknotid.invariants.contract_points(planar_diagram)[source]

For appropriately contracting :class: Points in a :class: PlanarDiagram According to the following rules:

P_a,b P_b,c -> P_a,c P_a,b P_a,b -> P_a,a

pyknotid.invariants.hyperbolic_volume(representation)[source]

The hyperbolic volume, calculated by the SnapPy library for studying the topology and geometry of 3-manifolds. This function depends on the Spherogram module, distributed with SnapPy or available separately.

Parameters:representation (A PlanarDiagram, or anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)), or a PlanarDiagram.
pyknotid.invariants.jones_mathematica(representation)[source]

Returns the Jones polynomial of the given representation, by creating a Mathematica process and running its knot routines. The Mathematica installation must include the KnotTheory package.

The function only supports evaluating at the variable q.

Parameters:representation (A PlanarDiagram, or anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)), or a PlanarDiagram.
pyknotid.invariants.second_order_writhe(representation)[source]

Returns the second order writhe (i1,i3,i2,i4) of the representation, as defined in Lin and Wang.

pyknotid.invariants.self_linking(representation)[source]

Returns the self linking number J(K) of the Gauss code, an invariant of virtual knots. See Kauffman 2004 for more information.

Currently only works for knots.

pyknotid.invariants.vassiliev_degree_2(representation)[source]

Calculates the Vassiliev invariant of degree 2 of the given knot. The representation must have just one knot component, this doesn’t work for links.

Parameters:representation (Anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)).
pyknotid.invariants.vassiliev_degree_3(representation, try_cython=True)[source]

Calculates the Vassiliev invariant of degree 3 of the given knot. The representation must have just one knot component, this doesn’t work for links.

Parameters:
  • representation (Anything convertible to a) – GaussCode A pyknotid representation class for the knot, or anything that can automatically be converted into a GaussCode (i.e. by writing GaussCode(your_object)).
  • try_cython (bool) – Whether to try and use an optimised cython version of the routine (takes about 1/3 of the time for complex representations). Defaults to True, but the python fallback will be slower than setting it to False if the cython function is not available.
pyknotid.invariants.virtual_vassiliev_degree_3(representation)[source]

Calculates the virtual Vassiliev invariant of degree 3 (for non-long-knots) of the given representation, as described in ‘Finite type invariants of classical and virtual knots’ by Goussarov, Polyak and Viro.

Parameters:representation (Representation) – A representation class, or anything convertible to one (in principle).