GenerateRandomSearch

Positive Definite Matrix Generator

Random symmetric matrices are usually not positive definite, so generating one means constructing it rather than hoping. These are built as AᵀA plus a multiple of the identity, which is positive definite whatever A turns out to be — and then proved twice over. Cholesky decomposition succeeds exactly when a symmetric matrix is positive definite, so running it is the test, and every leading minor being positive is Sylvester's criterion as an independent second opinion.

What this generator does

Draws a random integer matrix A, forms AᵀA — always positive semi-definite — and adds a positive multiple of the identity to make it strictly positive definite. It then reports the Cholesky factor and every leading minor.

How to use this tool

  1. Choose the matrix size.
  2. Read the matrix and its leading minors.
  3. Check that every leading minor is positive.
  4. Copy it if you need guaranteed positive definite test data.

Understanding the controls

Matrix size
Between 2 and 6. The Cholesky check runs in cubic time so any of these is instant.
Seed
Reproduces exactly the same matrix, which matters when it is being used as a numerical fixture.

Common use cases

  • Test data for solvers that require positive definite input
  • Covariance matrix examples that are actually valid covariance matrices
  • Teaching Cholesky decomposition on matrices where it always succeeds
  • Showing Sylvester's criterion working through the leading minors
  • Reproducing the same matrix from a seed

How this generator works

Cholesky decomposition attempts to write the matrix as L times L transposed with L lower triangular. It fails on a square root of a non-positive number, and that failure happens exactly when the matrix is not positive definite — so the decomposition existing is the proof. The check also rebuilds the matrix from the factor and confirms every leading minor is positive.

Randomness and fairness

The underlying matrix A is random; positive definiteness follows from the construction and is verified by decomposition. Seeded matrices reproduce and are therefore explicitly not cryptographically secure, and unseeded ones use the browser's cryptographically secure generator.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • The construction always adds the same shift, so the matrices are comfortably rather than marginally positive definite.
  • Entries are whole numbers, so this is not a realistic covariance matrix drawn from data.
  • Only real symmetric matrices — the Hermitian complex case is not covered.
  • Eigenvalues are not reported, though all of them are positive by definition.
  • Nothing is retained after the visit; seed the matrix to reuse it in a solver test.

Privacy and your data

The matrix and its decomposition are computed in your browser. Nothing is transmitted or stored.