Overview
Knot theory. Exact integer arithmetic.
| Area | API |
|---|---|
| Diagrams | LinkDiagram.pd (Knot Atlas / KnotTheory X[i,j,k,l]), .dt (Dowker–Thistlethwaite; the planar embedding is found by Euler's formula), .braid (closures, \sigma_{i} = \pm i), .unlink; orientation, signs, writhe, components, linkingNumbers, faces, isPlanar, isAlternating, isReduced, mirror, reversed, reverseComponent, normalized |
| Reidemeister moves | addKink / removeKink / removeAllKinks (R_{1}), addPoke / removeBigon (R_{2}), triangleMove (R_{3}) with kinks, r2Pokes, r2Bigons, r3Triangles listing where each applies; smoothed (oriented smoothing) |
| Invariants | kauffmanBracket (planar sweep over open-edge matchings; kauffmanBracketStateSum is the 2^{n} reference), jonesHalf / jones, alexander (Fox calculus, Bareiss determinant over \mathbb{Z}[t, t^{-1}], Conway-normalised), conway, determinant, homfly (skein recursion to a descending diagram, memoised), signature (Gordon–Litherland), crossingNumberBounds |
| Polynomials | Laurent (\mathbb{Z}[x, x^{-1}]) and Laurent2 (\mathbb{Z}[a\wedge \pm, z\wedge \pm ]) with exact division and specialisation; to be swapped for the CAS polynomials when they land |
| Table | knotTable: 3_{1}, 4_{1}, 5_{1}, 5_{2}, 6_{1}–6_{3}, 7_{1}–7_{7}, 8_{19}–8_{21}, 10_{124}, L2a1 (Hopf), L4a1 (Solomon), L5a1 (Whitehead), L6a4 (Borromean) |
| 3-D | KnotCurves.torusKnot, .torusLink, .figureEight, .lissajous, .circle, .hopfLink, .borromeanRings; diagramFromCurves (PD code of a projected polyline), projectedCrossings, gaussLinkingNumber (exact per-segment solid angles), curveWrithe |
| Rendering | tubeMesh(points, radius, sides, closed, uScale:) → TubeMesh (positions, normals, uvs, tangents, indices; interleaved is riptide_render's 12-float Geometry layout); rotation-minimising frames with closed-loop twist correction |
final k = LinkDiagram.pd(knotTable['4_1']!.pd);
k.jones(); // t^2 - t + 1 - t^-1 + t^-2
k.alexander(); // -t + 3 - t^-1
k.homfly(); // a^2 - z^2 - 1 + a^-2
final tube = tubeMesh(KnotCurves.torusKnot(2, 3), radius: 0.12, sides: 24);
final geometry = Geometry(vertices: tube.interleaved(), indices: tube.indices); // riptide_render
Validation (raya test, 189 tests)
- Every table entry: Jones, HOMFLY-PT, Alexander, Conway, determinant, signature and linking numbers computed from the Knot Atlas PD code equal the Knot Atlas values; the planar sweep equals the 2^{n} state sum; HOMFLY-PT specialises to Jones and Conway; mirror images give V(\frac{1}{t}), P(\frac{1}{a}, -z), -\sigma; DT codes give the same knots up to mirror image.
- Random sequences of 60 Reidemeister moves (R1, R2, R3 both ways) on 3_{1}, 4_{1}, 5_{2}, 6_{3}, 8_{19} and the three links keep the diagram planar and every invariant unchanged; R1 multiplies the bracket by -A^{\pm3}, R3 keeps it.
- Torus knots T(2, 3\cdots9), T(3, 4), T(3, 5), T(3, 7), T(4, 5) from braids match the closed-form Jones and Alexander polynomials.
- Diagrams read off 3-D curves (torus knots, figure-eight, a Lissajous 7_{4}, Hopf, Solomon, Borromean) have the expected invariants from several projection directions, and the Gauss linking integral equals the diagrammatic linking number.
Data and licences
The table's values (PD codes, DT codes, polynomials, determinants, signatures, unknotting numbers) are published mathematical facts read from the Knot Atlas (D. Bar-Natan, S. Morrison et al. https://katlas.org) and agree with KnotInfo (C. Livingston and A. H. Moore, https://knotinfo.math.indiana.edu). No code was taken from SnapPy, Regina, SageMath (GPL) or KnotTheory\`; the algorithms follow the published papers cited in the doc comments.
Functions and constants
Functions
List<ProjectedCrossing> projectedCrossings(List<SpaceCurve> curves, [Projection? projection])The crossings of closed polylines curves seen through projection (the viewer is on the +w side; the larger w passes over). Adjacent segments of one curve are not compared.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final xs = projectedCrossings([KnotCurves.torusKnot(2, 3)]);
print('${xs.length} crossings in the projection of the (2,3) torus knot');
}3 crossings in the projection of the (2,3) torus knot
LinkDiagram diagramFromCurves(List<SpaceCurve> curves, [Projection? projection])The link diagram of closed polylines curves seen through projection: a PD code with labels running 1, 2, … along each curve in its sampling direction. Curves with no crossing become free loops.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final d = diagramFromCurves([KnotCurves.torusKnot(2, 3)]);
print('${d.crossingCount} crossings, Jones ${d.jones().format('t')}');
}3 crossings, Jones -t^4 + t^3 + t
double gaussLinkingNumber(SpaceCurve a, SpaceCurve b)The Gauss linking integral of two closed polylines, evaluated exactly per segment pair as a signed solid angle (Klenin and Langowski, Biopolymers 54, 2000). An integer (up to rounding) equal to the linking number.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final h = KnotCurves.hopfLink();
print('Hopf link: ${f4(gaussLinkingNumber(h[0], h[1]))}');
}Hopf link: -1.0000
double curveWrithe(SpaceCurve a)The writhe of a closed polyline (the Gauss double integral over the curve with itself); by Călugăreanu–White Lk = Tw + Wr for a ribbon along it. Not an integer in general.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('writhe of the (2,3) torus knot curve: ${f4(curveWrithe(KnotCurves.torusKnot(2, 3)))}');
}writhe of the (2,3) torus knot curve: 3.3368
Map<String, Object?> knotDiagramScene(List<SpaceCurve> curves, {required String id, required String title, Projection? projection, double gap = 0.18, int maxSegments = 160})Pure data, so this package needs no Evelyn; the explainer draws it in light and dark mode with its own palette.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(knotDiagramScene([KnotCurves.torusKnot(2, 3, samples: 60)], id: 'trefoil', title: 'Trefoil').keys.toList());
}[id, title, view, objects, steps]
TubeMesh tubeMesh(Float64List points, {double radius = 0.1, int sides = 16, bool closed = true, double uScale = 8})A tube of radius with sides facets around the polyline points (xyz per point). For a closed curve the last point joins the first.
Frames are rotation-minimising (the double-reflection method of Wang, Jüttler, Zheng and Liu, "Computation of rotation minimizing frames", ACM TOG 27, 2008), so the tube does not twist on its own; on a closed curve the holonomy left after one lap is spread evenly along it, so the last ring meets the first exactly. uScale sets how many texture repeats run along the tube.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final m = tubeMesh(KnotCurves.torusKnot(2, 3, samples: 40), radius: 0.2, sides: 6);
print('${m.interleaved().length} floats');
}3444 floats
Constants and variables
Typedefs
typedef SpaceCurve = Float64ListA closed space curve sampled as a polyline: x, y, z per point; the last point joins back to the first (it is not repeated).
Classes
KnotCurves
abstract final class KnotCurves
Parametric knots and links in \mathbb{R}^{3}.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final k = KnotCurves.torusKnot(3, 5);
print('${k.length ~/ 3} samples; diagram: ${diagramFromCurves([k]).crossingCount} crossings');
}360 samples; diagram: 10 crossings
Static
static SpaceCurve torusKnot(int p, int q, {double major = 2, double minor = 0.8, int samples = 360})The (p, q) torus knot on a torus of radii major and minor: p turns around the axis, q around the tube, x = (R + r cos qt) cos pt, y = (R + r cos qt) sin pt, z = -r sin qt. Projected on the xy-plane it has q(p - 1) crossings, all positive for p, q > 0: T(2, 3) is the right-handed trefoil (the mirror of the Knot Atlas 3_{1}), T(3, 4) is 8_{19} and T(3, 5) is 10_{124}.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final d = diagramFromCurves([KnotCurves.torusKnot(2, 5)]);
print('(2,5) torus knot: determinant ${d.determinant()}, signature ${d.signature()}');
}(2,5) torus knot: determinant 5, signature 4
static List<SpaceCurve> torusLink(int p, int q, {double major = 2, double minor = 0.8, int samples = 360})The (p, q) torus link: \gcd(p, q) parallel copies of the (\frac{p}{d}, \frac{q}{d}) torus knot, spaced evenly around the tube; T(2, 4) is the Solomon link (linking number 2 with these orientations).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final l = KnotCurves.torusLink(2, 4);
print('${l.length} components, linking ${f4(gaussLinkingNumber(l[0], l[1]))}');
}2 components, linking 2.0000
static SpaceCurve figureEight({int samples = 360})The figure-eight knot 4_{1}: x = (2 + \cos 2t) \cos 3t, y = (2 + \cos 2t) \sin 3t, z = \sin 4t.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('Jones ${diagramFromCurves([KnotCurves.figureEight()]).jones().format('t')}');
}Jones t^2 - t + 1 - t^-1 + t^-2
static SpaceCurve lissajous(int nx, int ny, int nz, {double phx = 0.1, double phy = 0.7, double phz = 0, double scale = 2, int samples = 600})A Lissajous knot x = \cos(n_{x}t + \varphi_{x}), y = \cos(n_{y} t + \varphi_{y}), z = \cos(n_{z} t + \varphi_{z}) (frequencies pairwise coprime; with the default phases (3, 2, 7) is a 7-crossing diagram of the mirror of 7_{4}, as the tests check).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final k = KnotCurves.lissajous(3, 2, 7);
print('Lissajous knot: ${diagramFromCurves([k]).crossingCount} crossings');
}Lissajous knot: 7 crossings
static SpaceCurve circle((double, double, double) center, (double, double, double) u, (double, double, double) v, {double radius = 1, int samples = 200})A circle of radius around center in the plane spanned by unit vectors u and v.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final c = KnotCurves.circle((0, 0, 0), (1, 0, 0), (0, 1, 0));
print('writhe of a flat circle: ${f4(curveWrithe(c))}');
}writhe of a flat circle: 0.0000
static List<SpaceCurve> hopfLink({int samples = 200})The Hopf link: two unit circles through each other's centres.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final h = KnotCurves.hopfLink();
print(diagramFromCurves(h).linkingNumbers);
}[-1]
static List<SpaceCurve> borromeanRings({int samples = 240})The Borromean rings as three mutually perpendicular ellipses (semi-axes 2 and 1).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final b = KnotCurves.borromeanRings();
final d = diagramFromCurves(b);
print('pairwise linking ${d.linkingNumbers} (all zero), yet Jones ${d.jonesHalf().format('s')}');
}pairwise linking [0, 0, 0] (all zero), yet Jones -s^6 + 3s^4 - 2s^2 + 4 - 2s^-2 + 3s^-4 - s^-6
Projection
final class Projection
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final p = Projection((1, 0.02, 0.03));
print(diagramFromCurves([KnotCurves.torusKnot(2, 3)], p).crossingCount);
}8
Constructors
factory Projection([(double, double, double) view = (0.0123, 0.0217, 1)])Looking along −view (default a slightly tilted z, so a symmetric curve projects generically).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(projectedCrossings([KnotCurves.torusKnot(2, 3)], Projection((0, 0.01, 1))).length);
}3
Properties
final (double, double, double) ufinal (double, double, double) vfinal (double, double, double) wMethods
(double, double, double) apply(Float64List c, int i)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final c = KnotCurves.torusKnot(2, 3, samples: 12);
print(Projection().apply(c, 0));
}(0.0, 2.7997883176978378, 0.03442929105730846)
ProjectedCrossing
final class ProjectedCrossing
One crossing of a projected curve: where it is on screen and which pieces of the curves pass over and under.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final x = projectedCrossings(KnotCurves.hopfLink()).first;
print('at (${f4(x.x)}, ${f4(x.y)}): component ${x.overComponent} over ${x.underComponent}');
}at (-0.0217, 0.9996): component 0 over 1
Constructors
const ProjectedCrossing(this.x, this.y, this.overComponent, this.overParam, this.underComponent, this.underParam)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(const ProjectedCrossing(0, 0, 0, 0.1, 1, 0.2).underComponent);
}1
Properties
final int overComponentComponent index and position along it (segment index + fraction) of the over- and under-passes.
final int underComponentComponent index and position along it (segment index + fraction) of the over- and under-passes.
final double overParamfinal double underParamCrossing
final class Crossing
One crossing of a planar diagram in the Knot Atlas / KnotTheory PD convention: X[a, b, c, d] lists the four edge labels counterclockwise, starting with the incoming under-strand, so the under-strand runs a \to c. The over-strand runs d \to b at a positive crossing and b \to d at a negative one (which one is decided by orientation, see LinkDiagram.signs).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil crossings: ${trefoil.crossings}');
}trefoil crossings: [X[4,2,5,1], X[2,6,3,5], X[6,4,1,3]]
Constructors
const Crossing(this.a, this.b, this.c, this.d)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Crossing(1, 4, 2, 5).labels);
}[1, 4, 2, 5]
factory Crossing.fromList(List<int> x)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Crossing.fromList([1, 4, 2, 5]));
}X[1,4,2,5]
Properties
final int afinal int bfinal int cfinal int dList<int> get labelsint get hashCodeMethods
Crossing map(int Function(int) f)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Crossing(1, 4, 2, 5).map((l) => l + 10));
}X[11,14,12,15]
String toString()Operators
int operator [](int p)The label at counterclockwise position p (0 = incoming under).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final x = Crossing(1, 4, 2, 5);
print([for (var p = 0; p < 4; p++) x[p]]);
}[1, 4, 2, 5]
bool operator ==(Object other)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Crossing(1, 4, 2, 5) == Crossing.fromList([1, 4, 2, 5]));
}true
LinkDiagram
final class LinkDiagram
An oriented link diagram: crossings in PD notation plus freeLoops crossingless unknotted components.
Every edge label appears exactly twice among the crossings. The orientation of each edge is propagated from the under-strands (which the PD convention orients), so labels need not be consecutive along a component; a component that only passes over is oriented arbitrarily (from its smallest label).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil: ${trefoil.crossingCount} crossings, writhe ${trefoil.writhe}, Jones ${trefoil.jones().format('t')}');
}
String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');trefoil: 3 crossings, writhe 3, Jones -t^4 + t^3 + t
Constructors
LinkDiagram(List<Crossing> crossings, {this.freeLoops = 0, List<int>? overEntries})overEntries optionally fixes, per crossing, the position (1 or 3) where the over-strand enters; it is needed only for components that never pass under (otherwise the orientation follows from the under-strands). Without it such a component is oriented by KnotTheory's rule for consecutive labels.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final d = LinkDiagram([Crossing(1, 4, 2, 5), Crossing(3, 6, 4, 1), Crossing(5, 2, 6, 3)]);
print('${d.isPlanar}, Jones ${d.jones().format('t')}');
}true, Jones t^-1 + t^-3 - t^-4
factory LinkDiagram.pd(List<List<int>> pd, {int freeLoops = 0})From a PD code [[i, j, k, l], …], e.g. the Knot Atlas trefoil [[1, 4, 2, 5], [3, 6, 4, 1], [5, 2, 6, 3]].
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
// The Knot Atlas trefoil.
final d = LinkDiagram.pd([[1, 4, 2, 5], [3, 6, 4, 1], [5, 2, 6, 3]]);
print('Alexander ${d.alexander().format('t')}');
}Alexander t - 1 + t^-1
factory LinkDiagram.unlink([int n = 1])The crossingless unknot (or an n-component unlink).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('2-component unlink: Jones in s ${LinkDiagram.unlink(2).jonesHalf().format('s')}');
}2-component unlink: Jones in s -s - s^-1
factory LinkDiagram.dt(List<int> code)From a Dowker–Thistlethwaite code (the even labels paired with 1, 3, 5, …; a negative entry means the strand is over at its even visit). The planar embedding is found by trying each crossing's two local orientations and keeping one whose faces satisfy Euler's formula (F = n + 2), so it is exponential in the crossing number (fine to ~20). DT codes determine a prime knot only up to mirror image.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('DT 4 6 2: Jones ${LinkDiagram.dt([4, 6, 2]).jones().format('t')}');
}DT 4 6 2: Jones t^-1 + t^-3 - t^-4
factory LinkDiagram.braid(int strands, List<int> word)The closure of a braid on strands strands; word lists generators as \pm i (1-based): +i is \sigma_{i} (strand i passes over strand i + 1, a positive crossing when both run up), -i is \sigma_{i}^{-1}. \sigma_{1}^{3} is the right-handed trefoil.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
// σ1σ2⁻¹ repeated twice on 3 strands closes to the figure-eight knot.
final d = LinkDiagram.braid(3, [1, -2, 1, -2]);
print('Jones ${d.jones().format('t')} = figure-eight: ${d.jones() == fig8.jones()}');
}Jones t^2 - t + 1 - t^-1 + t^-2 = figure-eight: true
Static
static LinkDiagram rebuild(List<Crossing> kept, List<(int, int)> joins, {int freeLoops = 0, List<int>? overEntries})Rebuilds a diagram from kept crossings after joining edge labels in pairs (joins: each pair becomes one edge). Classes of joined labels that no kept crossing uses any more are closed crossingless loops.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final d = LinkDiagram.rebuild(trefoil.crossings, []);
print(d.jones() == trefoil.jones());
}true
Properties
final List<Crossing> crossingsint get crossingCountlate final List<int> signsThe sign of each crossing (+1: the over-strand enters at position 3, i.e. runs d \to b).
List<int> get overEntriesPer crossing, the position (1 or 3) where the over-strand enters.
late final List<List<int>> componentsThe components that have crossings, each as its edge labels in orientation order, starting from the component's smallest label; components are ordered by that label.
int get componentCountThe number of link components, crossingless loops included.
List<int> get linkingNumbersThe pairwise linking numbers (i < j) in the order (0,1), (0,2), …, (1,2), ….
late final List<List<(int, int)>> facesThe faces of the diagram as cycles of half-edges (crossing, position), each traversed counterclockwise (the face on the left). A connected diagram with n \ge 1 crossings has n + 2 faces.
int get projectionPiecesThe number of connected pieces of the projection (crossingless loops excluded).
bool get isPlanarWhether the crossing data is a planar diagram (Euler's formula, per connected piece of the projection).
List<int> get nugatoryCrossingsCrossings that one face touches at two corners (removable by turning a half of the diagram over).
Methods
bool isIncoming(int ci, int p)Whether the edge at crossing ci, position p points into the crossing.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print([for (var p = 0; p < 4; p++) trefoil.isIncoming(0, p)]);
}[true, false, false, true]
(int, int) overStrand(int ci)The crossing ci's over-strand edges, incoming then outgoing.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.overStrand(0));
}(1, 2)
(int next, int crossing, bool under) successor(int label)The edge after label along the orientation, with the crossing it passes through and whether it passed under.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.successor(1));
}(2, 0, false)
int componentOf(int label)The component (index into components) that edge label belongs to.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
print([for (final c in hopf.components) hopf.componentOf(c.first)]);
}[0, 1]
int linkingNumber(int i, int j)The linking number of components i and j: half the sum of the signs of the crossings between them.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
print(hopf.linkingNumber(0, 1));
}-1
LinkDiagram mirror()The mirror image: every crossing switched.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil ${trefoil.jones().format('t')}, mirror ${trefoil.mirror().jones().format('t')}: chiral');
}trefoil -t^4 + t^3 + t, mirror t^-1 + t^-3 - t^-4: chiral
int switchedOverEntry(int ci)The over-strand entry position of switched (ci).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('${trefoil.overEntries[0]} → ${trefoil.switchedOverEntry(0)}');
}3 → 1
Crossing switched(int ci)Crossing ci with over and under exchanged (orientations kept).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('${trefoil.crossings[0]} switched: ${trefoil.switched(0)}');
}X[4,2,5,1] switched: X[1,4,2,5]
LinkDiagram reversed()The same link with the orientation of every component reversed.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil is invertible: ${trefoil.reversed().jones() == trefoil.jones()}');
}trefoil is invertible: true
LinkDiagram reverseComponent(int k)The same link with the orientation of component k (an index into components) reversed.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
print('${hopf.linkingNumbers} → ${hopf.reverseComponent(1).linkingNumbers}');
}[-1] → [1]
LinkDiagram normalized()Labels renumbered 1, 2, … along each component in orientation order (the KnotTheory form).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(LinkDiagram.dt([4, 6, 2]).normalized().pd);
}[[3, 6, 4, 1], [5, 2, 6, 3], [1, 4, 2, 5]]
String toString()KnotInvariants
extension KnotInvariants on LinkDiagram
Exact polynomial invariants of a LinkDiagram.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
for (final n in ['3_1', '4_1', '5_1', '5_2']) {
final d = LinkDiagram.pd(knotTable[n]!.pd);
print('$n: Jones ${d.jones().format('t')}, det ${d.determinant()}');
}
}3_1: Jones t^-1 + t^-3 - t^-4, det 3 4_1: Jones t^2 - t + 1 - t^-1 + t^-2, det 5 5_1: Jones t^-2 + t^-4 - t^-5 + t^-6 - t^-7, det 5 5_2: Jones t^-1 - t^-2 + 2t^-3 - t^-4 + t^-5 - t^-6, det 7
Methods
Laurent kauffmanBracket()The Kauffman bracket ⟨D⟩ in A, normalised so the crossingless unknot is 1 (a regular-isotopy invariant).
Contracted crossing by crossing (a planar-algebra / Temperley–Lieb style sweep): the state is a perfect matching of the edges left open so far, with a polynomial per matching, so the cost grows with the width of the cut rather than 2^{n}. The next crossing is the one sharing the most open edges.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final b = trefoil.kauffmanBracket();
print('⟨trefoil⟩ = ${b.format('A')}');
}
String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');⟨trefoil⟩ = -A^5 - A^-3 + A^-7
Laurent kauffmanBracketStateSum()The plain 2^{n} state sum (a reference for kauffmanBracket; only for small diagrams).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.kauffmanBracketStateSum() == trefoil.kauffmanBracket());
}true
Laurent jonesHalf()The Jones polynomial in s = t^{\tfrac{1}{2}} (= q^{\tfrac{1}{2}}): knots have only even powers of s; see jones for t.
V(t) = (-A^{3})^{-w} \langle D\rangle at A = t^{-\tfrac{1}{4}}, i.e. s = A^{-2}. Normalised V(unknot) = 1, skein t^{-1}V(L_{+}) − tV(L₋) = (t^½ − t^(−½))V(L₀), the Knot Atlas convention.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
print('Hopf: ${hopf.jonesHalf().format('s')} (s = t^½)');
}Hopf: -s^-1 - s^-5 (s = t^½)
Laurent jones()The Jones polynomial in t for a knot (or any link whose powers are integral); throws otherwise.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(fig8.jones().format('t'));
}
String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');t^2 - t + 1 - t^-1 + t^-2
Laurent alexander()The Alexander polynomial of a knot, Conway-normalised: \Delta(t) = \Delta(t^{-1}), \Delta(1) = 1.
From the Alexander matrix of the Wirtinger presentation (Fox calculus): one row per crossing with 1 - t on the over-arc and t, -1 on the incoming and outgoing under-arcs (t - 1, 1, -t at a negative crossing); the determinant of a first minor, by fraction-free (Bareiss) elimination over \mathbb{Z}[t, t^{-1}].
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil ${trefoil.alexander().format('t')}, figure-eight ${fig8.alexander().format('t')}');
}
String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');trefoil t - 1 + t^-1, figure-eight -t + 3 - t^-1
Laurent conway()The Conway polynomial \nabla(z), from HOMFLY-PT at a = 1 (any link); for a knot \Delta(t) = \nabla(t^{\tfrac{1}{2}} - t^{-\tfrac{1}{2}}).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('∇(trefoil) = ${trefoil.conway().format('z')}');
}∇(trefoil) = z^2 + 1
int determinant()The determinant |\Delta(-1)| = |V(-1)| of a knot.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print([for (final n in ['3_1', '4_1', '5_1', '5_2', '6_1']) LinkDiagram.pd(knotTable[n]!.pd).determinant()]);
}[3, 5, 5, 7, 9]
Laurent2 homfly()The HOMFLY-PT polynomial P(a, z): a \cdot P(L_{+}) - a^{-1} \cdot P(L_{-}) = z \cdot P(L_{0}), P(unknot) = 1 (the Knot Atlas convention; Jones is P(a = t^{-1}, z = t^{\tfrac{1}{2}} - t^{-\tfrac{1}{2}}), Conway is P(1, z)).
Skein recursion toward a descending diagram: walk the components from their base points; at the first crossing met first as an under-pass, P(D) = a^{\mp2} P(D switched) \pm a^{\mp1} z P(D smoothed). A descending diagram is an unlink of c components, P = (\frac{a - a^{-1}}{z})^{c - 1}. Kinks are removed first (P is an isotopy invariant), and sub-diagrams are memoised. Exponential in the worst case; fine for the tables (≤ 12 crossings).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('P(trefoil) = ${trefoil.homfly().format()}');
}P(trefoil) = a^-2 z^2 + 2a^-2 - a^-4
({int lower, int upper, bool exact}) crossingNumberBounds()Lower and upper bounds for the crossing number of a knot: span V(t) \le c(K) (Kauffman–Murasugi–Thistlethwaite) and the crossings of this diagram once kinks are removed; equal (exact) for a reduced alternating diagram.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(fig8.crossingNumberBounds());
}(exact: true, lower: 4, upper: 4)
KnotSignature
extension KnotSignature on LinkDiagram
The knot signature by the Gordon–Litherland formula: \sigma = \operatorname{sign}(G) - \mu, with G the Goeritz matrix of a checkerboard colouring (white regions, one deleted) and \mu the correction from the type II crossings (C. McA. Gordon and R. A. Litherland, "On the signature of a link", Invent. Math. 47, 1978). Sign convention: the Knot Atlas's (positive knots have positive signature, e.g. \sigma(7_{3}) = 4).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil σ = ${trefoil.signature()}, mirror ${trefoil.mirror().signature()}, figure-eight ${fig8.signature()}');
}trefoil σ = 2, mirror -2, figure-eight 0
Methods
int signature()import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(LinkDiagram.pd(knotTable['5_1']!.pd).signature());
}-4
Laurent
final class Laurent
A Laurent polynomial \sum c_{k} x^{k} (k \in \mathbb{Z}, c_{k} \in \mathbb{Z}), stored sparse and normalised (no zero coefficients).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final p = Laurent.fromMap({-1: 1, 0: -1, 1: 1});
print('p = ${p.format('t')}, p² = ${(p * p).format('t')}');
}p = t - 1 + t^-1, p² = t^2 - 2t + 3 - 2t^-1 + t^-2
Constructors
factory Laurent.fromMap(Map<int, int> terms)From exponent → coefficient (zeros dropped).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent.fromMap({-2: 3, 1: -1}).format('q'));
}-q + 3q^-2
factory Laurent.monomial(int exponent, [int coefficient = 1])c \cdot x^{e}.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent.monomial(-3, 2).format());
}2x^-3
factory Laurent.constant(int c)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent.constant(5).format());
}5
Static
static final Laurent zerostatic final Laurent oneProperties
bool get isZeroint get maxDegreeint get hashCodeMethods
Laurent scale(int c)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent.fromMap({1: 1, 2: -1}).scale(-3).format());
}3x^2 - 3x
Laurent shift(int k)Multiplies by x^{k}.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent.fromMap({0: 1, 1: 1}).shift(-1).format());
}1 + x^-1
Laurent pow(int n)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent.x + Laurent.monomial(-1)).pow(3).format());
}x^3 + 3x + 3x^-1 + x^-3
Laurent substitutePower(int k)p(x^{k}): every exponent multiplied by k (k = -1 is the mirror substitution x \to \frac{1}{x}).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('V(1/t) for the trefoil: ${trefoil.jones().substitutePower(-1).format('t')}');
}V(1/t) for the trefoil: t^-1 + t^-3 - t^-4
Laurent divideExponents(int k)Exponents all divided by k; throws if one is not a multiple.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent.fromMap({2: 1, -4: 1}).divideExponents(2).format());
}x + x^-2
Laurent exactDiv(Laurent d)The exact quotient by d; throws StateError if d does not divide this in \mathbb{Z}[x, x^{-1}].
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final a = Laurent.fromMap({0: 1, 1: 1}), b = Laurent.fromMap({0: 1, 1: -1});
print((a * b).exactDiv(b).format());
}x + 1
num evaluate(num x)The value at an integer (exact when every exponent is ≥ 0 or x = \pm1).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('V(−1) = ${trefoil.jones().evaluate(-1)}, |Δ(−1)| = ${trefoil.determinant()}');
}V(−1) = -3, |Δ(−1)| = 3
String format([String variable = 'x'])Human-readable, highest power first: -q^-4 + q^-3 + q^-1.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.jones().format('q'));
}-q^4 + q^3 + q
String toString()Operators
int operator [](int exponent)The coefficient of x^{e}.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.jones()[1]);
}1
Laurent operator +(Laurent o)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent.x + Laurent.one).format());
}x + 1
Laurent operator -(Laurent o)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent.x - Laurent.x).format());
}0
Laurent operator -()import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((-Laurent.x).format());
}-x
Laurent operator *(Laurent o)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent.fromMap({1: 1, -1: 1}) * Laurent.fromMap({1: 1, -1: -1})).format());
}x^2 - x^-2
bool operator ==(Object other)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(fig8.jones() == fig8.jones().substitutePower(-1));
}true
Laurent2
final class Laurent2
A Laurent polynomial in two variables \sum c a^{i} z^{j} with integer coefficients (HOMFLY-PT lives here).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final p = trefoil.homfly();
print('${p.format()}; at a = 1: ${p.atAOne().format('z')}');
}a^-2 z^2 + 2a^-2 - a^-4; at a = 1: z^2 + 1
Constructors
factory Laurent2.fromMap(Map<(int, int), int> terms)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent2.fromMap({(1, 0): 2, (-1, 1): -1}).format());
}2a - a^-1 z
factory Laurent2.monomial(int i, int j, [int c = 1])import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent2.monomial(2, -1, 3).format());
}3a^2 z^-1
Static
static final Laurent2 zerostatic final Laurent2 oneProperties
Map<(int, int), int> get termsbool get isZeroint get hashCodeMethods
Laurent2 shift(int i, int j)Multiplies by a^{i} z^{j}.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent2.one.shift(1, 1).format());
}a z
Laurent2 pow(int n)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(Laurent2.fromMap({(1, 0): 1, (0, 1): 1}).pow(2).format());
}a^2 + 2a z + z^2
Laurent2 substitute({int aPower = 1, int zPower = 1, bool negateZ = false})P(a^{ka}, z^{kz} \cdot \operatorname{sign}): the mirror image of a link is P(a^{-1}, -z).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('mirror HOMFLY: ${trefoil.homfly().substitute(aPower: -1).format()}');
}mirror HOMFLY: -a^4 + a^2 z^2 + 2a^2
Laurent specialise({required int aExp, required Laurent z})Sets a = x^aExp and z = z (a one-variable Laurent polynomial in x), exactly. Negative powers of z are cleared by exact division (they must cancel for a genuine specialisation, e.g. HOMFLY-PT → Jones).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
// a = t⁻¹, z = t^½ − t^(−½) gives Jones; in s = t^½: a = s⁻², z = s − s⁻¹.
print(trefoil.homfly().specialise(aExp: -2, z: Laurent.fromMap({1: 1, -1: -1})).format('s'));
}-s^8 + s^6 + s^2
Laurent atAOne()P(a, z) at a fixed a = 1 (the Conway polynomial for HOMFLY-PT), as a polynomial in z.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(fig8.homfly().atAOne().format('z'));
}-z^2 + 1
String format([String a = 'a', String z = 'z'])import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.homfly().format('v', 'z'));
}v^-2 z^2 + 2v^-2 - v^-4
String toString()Operators
int operator [](({int a, int z}) e)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(trefoil.homfly()[(a: -2, z: 0)]);
}2
Laurent2 operator +(Laurent2 o)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent2.one + Laurent2.monomial(1, 1)).format());
}a z + 1
Laurent2 operator -(Laurent2 o)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent2.one - Laurent2.one).format());
}0
Laurent2 operator -()import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((-Laurent2.monomial(1, 2)).format());
}-a z^2
Laurent2 operator *(Laurent2 o)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print((Laurent2.monomial(1, 0) * Laurent2.monomial(-1, 2)).format());
}z^2
bool operator ==(Object other)import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(fig8.homfly() == fig8.mirror().homfly());
}true
ReidemeisterMoves
extension ReidemeisterMoves on LinkDiagram
Reidemeister moves and the other local operations on a LinkDiagram (all keep the planar PD consistent; new edges get labels above the largest one in use).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
// Add two kinks to the unknot, then remove them again.
final one = LinkDiagram.unlink().addKink(null);
final k = one.addKink(one.crossings.first.a, positive: false);
print('${k.crossingCount} crossings, Jones ${k.jones().format('t')}; after R1⁻¹: ${k.removeAllKinks().crossingCount}');
}2 crossings, Jones 1; after R1⁻¹: 0
Properties
List<int> get kinksCrossings that are R1 kinks (an edge from the crossing straight back to it, at adjacent positions).
List<(int, int, int)> get r2PokesThe R2 moves available as (face, raya i, raya j): two different edges on one face that a finger can push across.
List<(int, int)> get r2BigonsBigon faces whose two crossings an R_{2}^{-1} can remove (one strand over at both), as crossing pairs.
List<(int, int)> get r3TrianglesTriangular faces where R3 applies, as (face, side): the strand along that side is over (or under) at both of its triangle crossings and slides across the third crossing.
Methods
LinkDiagram smoothed(int ci)The oriented (Seifert) smoothing of crossing ci: incoming strands joined to the outgoing ones beside them.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print('trefoil smoothed at crossing 0: ${trefoil.smoothed(0).crossingCount} crossings');
}trefoil smoothed at crossing 0: 2 crossings
LinkDiagram removeKink(int ci)R_{1}^{-1}: removes kink ci.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final k = LinkDiagram.unlink().addKink(null);
print(k.removeKink(k.kinks.first).crossingCount);
}0
LinkDiagram removeAllKinks()Removes kinks until none is left.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final k = trefoil.addKink(trefoil.crossings.first.a).addKink(trefoil.crossings.first.b);
print('${k.crossingCount} → ${k.removeAllKinks().crossingCount}');
}5 → 3
LinkDiagram addKink(int? edge, {bool positive = true, bool overFirst = false})R1: adds a kink on edge edge (or, with edge null, on a crossingless loop). positive picks the sign, overFirst whether the strand meets the kink crossing first as the over-strand.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final k = trefoil.addKink(trefoil.crossings.first.a);
print('writhe ${trefoil.writhe} → ${k.writhe}; Jones unchanged: ${k.jones() == trefoil.jones()}');
}writhe 3 → 4; Jones unchanged: true
LinkDiagram addPoke(int face, int i, int j, {bool over = true})R2: pushes a finger of the edge on raya i of face face across the edge on raya j of the same face, creating two crossings; over says whether the pushed strand goes over (true) or under.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final (f, i, j) = trefoil.r2Pokes.first;
final p = trefoil.addPoke(f, i, j);
print('${p.crossingCount} crossings, Jones unchanged: ${p.jones() == trefoil.jones()}');
}5 crossings, Jones unchanged: true
LinkDiagram removeBigon(int c1, int c2)R_{2}^{-1}: removes the bigon between crossings c1 and c2 (see r2Bigons).
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final (f, i, j) = trefoil.r2Pokes.first;
final p = trefoil.addPoke(f, i, j);
final (c1, c2) = p.r2Bigons.first;
print(p.removeBigon(c1, c2).crossingCount);
}3
LinkDiagram triangleMove(int face, int side)R3 on triangle face, sliding the strand along side side (see r3Triangles) across the opposite crossing.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final d = LinkDiagram.braid(3, [1, 2, 1]);
if (d.r3Triangles.isNotEmpty) {
final (f, s) = d.r3Triangles.first;
print('R3 keeps Jones: ${d.triangleMove(f, s).jonesHalf() == d.jonesHalf()}');
} else {
print('no triangle face');
}
}R3 keeps Jones: true
KnotTableEntry
final class KnotTableEntry
One knot or link of the table. jonesHalf is the Jones polynomial in q^{\tfrac{1}{2}} (exponents doubled), homfly maps (power of a, power of z) to the coefficient.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
final e = knotTable['5_2']!;
print('${e.name}: ${e.title}, ${e.crossings} crossings');
}5_2: Three-twist, 5 crossings
Constructors
const KnotTableEntry({required this.name, required this.title, required this.crossings, required this.components, required this.alternating, required this.pd, required this.jonesHalf, required this.homfly, required this.signature, this.dt, this.alexander, this.conway, this.determinant, this.unknotting, this.linking})import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(knotTable.keys.toList());
}[3_1, 4_1, 5_1, 5_2, 6_1, 6_2, 6_3, 7_1, 7_2, 7_3, 7_4, 7_5, 7_6, 7_7, 8_19, 8_20, 8_21, 10_124, L2a1, L4a1, L5a1, L6a4]
Properties
final String namefinal String titlefinal int crossingsfinal int componentsfinal bool alternatingfinal List<List<int>> pdfinal List<int>? dtfinal Map<int, int> jonesHalffinal Map<int, int>? alexanderfinal Map<int, int>? conwayfinal Map<(int, int), int> homflyfinal int? determinantfinal int signaturefinal int? unknottingfinal List<int>? linkingLaurent get jonesHalfPolyLaurent? get alexanderPolyLaurent? get conwayPolyLaurent2 get homflyPolyTubeMesh
final class TubeMesh
A triangle mesh of a tube around a curve: per-vertex positions and unit normals (xyz), uvs (u along the curve, v around it), tangents (the curve direction, xyz) and counter-clockwise (outward-facing) indices.
Properties
final Float32List positionsfinal Float32List normalsfinal Float32List uvsfinal Float32List tangentsfinal Uint32List indicesfinal int ringsRings along the curve (the last repeats the first for a closed curve, so the texture seam has its own vertices) and vertices per ring minus one (the seam around the tube is duplicated too).
final int sidesRings along the curve (the last repeats the first for a closed curve, so the texture seam has its own vertices) and vertices per ring minus one (the seam around the tube is duplicated too).
int get vertexCountMethods
Float32List interleaved()The riptide_render interleaved layout (Geometry(vertices: …, indices: …)): position 3, normal 3, uv 2, tangent 4 (xyz + handedness 1) = 12 floats per vertex.
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';
String f4(num x) => x.toStringAsFixed(4);
void main() {
final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
print(tubeMesh(KnotCurves.circle((0, 0, 0), (1, 0, 0), (0, 1, 0), samples: 8), sides: 4).interleaved().length);
}540