How this calculation works
LLL reduction replaces an independent integer row basis by another basis of exactly the same lattice. It size-reduces a row using earlier rows and swaps neighboring rows when the Lovász condition fails. This implementation forms Gram–Schmidt coefficients as exact fractions, records an integer transformation U and verifies the final lattice identity B=U*A. Both the size-reduction and Lovász inequalities are checked exactly, rather than inferred from how short the drawn or displayed vectors look.
B=U*A, det(U)=±1; |μ_i,j|≤1/2 and ||b_i*||²≥(delta−μ_i,i−1²)||b_(i−1)*||².A worked example
For row vectors (100,1) and (1,0), an LLL reduction can return (1,0) and (0,1). The first original vector minus one hundred times the second gives (0,1), so these shorter vectors remain integer combinations of the original rows. A valid transformation is [[0,1],[1,−100]], with determinant −1. This hand-check illustrates lattice preservation without assuming that every reduced basis is uniquely determined.
Good to know
Supports 1–4 linearly independent integer rows in at most six coordinates, with entries within ±10⁶. Delta is rational and must satisfy 1/4<delta<1. Exact arithmetic is bounded by 512-bit intermediate integer entries, 2,000 outer iterations and 10,000 logged operations. Dependent rows are rejected rather than silently removed. Tie choices and parameter values can change the reduced basis. LLL reduction is not an exact shortest-vector solver or a canonical lattice normal form.
Reference: SymPy DomainMatrix documentation — LLL and transformation matrices (opens in a new tab) ↗
Gram–Schmidt guides reduction but does not replace the integer basis
Gram–Schmidt vectors and coefficients describe projections that help decide which integer row operations to perform. The orthogonal vectors themselves generally have rational coordinates and need not generate the original integer lattice. The returned basis therefore remains integral, while the squared orthogonal norms are shown separately as diagnostic exact fractions. Confusing those two outputs would turn a lattice reduction into an unrelated real-vector orthogonalization.
Size reduction subtracts a nearest integer multiple of an earlier row, bringing the corresponding projection coefficient into the interval from −1/2 to +1/2. Half-integer ties are rounded away from zero here. Swaps address the Lovász condition and can require earlier rows to be reconsidered, so the visible sequence may revisit an index. The final certificate checks every required coefficient and inequality, including cases where the input was already reduced.
The Hermite normal form calculator for an integer matrix supplies a canonical column-lattice basis instead of an LLL reduced row basis.
A valid reduced basis need not match another implementation row for row
LLL output can depend on tie choices, sign conventions and delta. Two bases can therefore both be valid while their rows differ. The stronger comparison is whether each basis generates the same lattice, whether its transformation is unimodular and whether its own reduction conditions hold. The reference checks compare canonical Hermite forms of the transposed row generators, alongside those exact conditions, instead of rejecting every different but valid reduced basis.
Increasing delta tightens the Lovász condition and can require more swaps; it is not a promise of a uniquely shortest first vector. The reduction also requires independent input rows because zero Gram–Schmidt norm would invalidate a division. This page rejects that case with a clear input error rather than deleting a generator and changing the requested basis silently. For exact shortest-vector enumeration or a canonical basis, a separate algorithm and different output guarantees are required.
A few questions, answered
Does a verified certificate prove the shortest lattice vector was found?
No. It proves lattice preservation and the selected LLL reducedness inequalities. LLL gives a reduced basis under those conditions, not an exhaustive shortest-vector solution.
Why is delta=1 rejected?
This implementation follows the bounded LLL parameter range 1/4<delta<1. Endpoints are not accepted as an undocumented extension of its termination and reduction assumptions.