← LibraryThe LLL Lattice Reduction AlgorithmEngineering · MathematicsLesson 6/7← PrevNext →
GuidePublished 6 Aug 20265 min readBy Kevin JoginComputational Number TheoryLinear Algebra & LatticesLLL AlgorithmLattice Reduction
Skip to the main content

MathematicsLinear Algebra & Lattices

The LLL Lattice Reduction Algorithm

The 1982 result that made a whole generation of number-theoretic algorithms practical: a polynomial-time basis reduction with provable guarantees.

Executive summary

Polynomial time, exponential approximation, and it is enough

LLL takes any basis of a lattice and returns one that is size-reduced and satisfies the Lovász condition, in time polynomial in the dimension and the input size. The first vector of the output is guaranteed within a factor of 2(n−1)/2 of the shortest — a weak-sounding bound that is comprehensively beaten in practice, and that turned polynomial factorisation, integer relation detection and simultaneous Diophantine approximation from research problems into library calls.

Learning objectives

  • State the two LLL reduction conditions and their geometric meaning.
  • Trace the swap-and-reduce loop and explain what each phase achieves.
  • Explain the potential function argument for polynomial termination.
  • State the quality guarantees and contrast them with observed behaviour.
  • Choose between standard LLL, deep insertions and BKZ.

Section 01The reduction conditions

A basis is LLL-reduced for a parameter δ with 1/4 < δ < 1 when both conditions hold.

Condition 1Size reduction: |μij| ≤ 1/2

No basis vector has a large component along an earlier one. Achieved by subtracting the nearest integer multiple — a unimodular operation, so the lattice is unchanged.

Condition 2Lovász condition

‖b*i‖² ≥ (δ − μi,i−1²) ‖b*i−1‖². The orthogonal lengths may not decrease too quickly; where they do, swapping the two vectors improves the basis.

The standard choice δ = 3/4 is what appears in the original analysis; δ close to 1 gives better bases at greater cost, and the running time degrades as δ approaches 1.

Section 02The algorithm

AlgorithmLLL basis reductionin: a basis of L  →  out: an LLL-reduced basis of the same L
  1. Compute the Gram–Schmidt data μij and ‖b*i2. Set k ← 2.
  2. Size-reduce bk against bk−1: subtract ⌊μk,k−1⌉ bk−1. Nearest integer, hence |μ| ≤ 1/2.
  3. If the Lovász condition fails at index k: swap bk and bk−1, update the Gram–Schmidt data, set k ← max(2, k−1) and return to step 2. The only step that can move backwards.
  4. Otherwise size-reduce bk against bk−2, …, b1 in that order.
  5. Set k ← k + 1. If k ≤ n return to step 2.
  6. Return the reduced basis.
Every operation is unimodular, so the lattice is invariant throughout. Only the quality of the basis changes.
Why it terminates in polynomial time

Define the potential D = ∏i di, where di is the determinant of the first i basis vectors. D is a positive integer for an integer lattice, so it cannot decrease forever. Size reduction leaves D unchanged; every swap multiplies it by a factor of at most δ < 1. Hence the number of swaps is bounded by log1/δ of the initial potential — polynomial in the input size. This argument, not the geometry, is the heart of the result.

Section 03Guarantees versus practice

For a δ-reduced basis with δ = 3/4:

b1‖ ≤ 2(n−1)/2 λ1(L),    ‖b1‖ ≤ 2(n−1)/4 (det L)1/n
2(n−1)/2worst-case approximation factor
≈ 1.02ntypical observed factor on random lattices
O(n5 log2B)classical running time bound
The gap between theory and practice

The proven bound is exponential; observed behaviour on random lattices is far better, with the first vector typically within a small polynomial factor. Two consequences follow: LLL is far more useful than its bound suggests, and cryptographic security estimates must be based on observed behaviour, not on the worst-case guarantee.

Section 04Variants

LLL variants and when they earn their cost
VariantChangeEffect
Deep insertionOn failure, insert bk at the best earlier position rather than swapping with its immediate predecessorNoticeably better bases; no polynomial time bound, but usually fast in practice
Floating-point LLLGram–Schmidt in floating point with exact re-verification near thresholdsThe standard production choice; large constant-factor speedup
Integral LLLAll arithmetic in ℤ using scaled μ coefficientsFully exact, slower; the reference implementation for verification
Linearly dependent inputHandles generating sets that are not bases, extracting zero vectorsEssential for integer kernel computation
BKZBlock-wise reduction with exhaustive search inside each blockMuch better bases; cost rises sharply with block size — the standard tool for cryptanalytic estimates
Do not use LLL as a shortest-vector oracle

LLL returns a short vector, not the shortest. Algorithms whose correctness depends on having the true minimum — some CM constructions and exhaustive enumeration steps — require a genuine SVP solver such as Fincke–Pohst enumeration, with LLL used only as preprocessing.

ReferenceFrequently asked questions

What does the parameter delta actually control?

How aggressively the algorithm insists that orthogonal lengths not decrease. Larger delta means stricter conditions, better bases and more swaps. At delta = 1 the running time is no longer provably polynomial, so implementations use values slightly below 1 when quality matters.

Is LLL still competitive?

As a fast preprocessing step, yes — universally. As the final reduction where quality matters, BKZ with a moderate block size has replaced it. The standard pipeline runs LLL first, then BKZ on the already-reduced basis.

Can LLL handle a generating set that is not a basis?

Yes, with the dependent-vector variant, which detects linear dependencies and produces zero vectors that are then removed. This is exactly how integer kernels are computed, so the variant is not a curiosity but a working tool.

NavigateContinue in this stream

Curated next steps from this page. The site also surfaces algorithmically related reading below.

ProvenanceSources and further reading

This page is an original KEVOS explanatory article. It presents the underlying mathematics — definitions, algorithms, complexity results and selection criteria — in KEVOS editorial voice. No text is reproduced from any copyrighted source. Where numerical tables are relevant, KEVOS links to live authoritative databases rather than republishing static values.

Page ID
KV-MATH-0017
Taxonomy
ENG-MATH — Engineering / Mathematics
Collection
COL-CANT-001
Topic stream
CANT-LINALG-LATTICES
Version
1.1.0 / content 2026.08
Last reviewed
2026-08-06

Continue learning

Gram–Schmidt OrthogonalisationGuide · MathematicsNEXT LESSON →Applications of the LLL AlgorithmGuide · MathematicsLattices and Quadratic FormsGuide · MathematicsThe Smith Normal Form and Its ApplicationsGuide · Mathematics