Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

linalg.cholesky

Computes a Cholesky factor for a Hermitian positive-definite matrix. It returns an upper-triangular factor by default or a lower-triangular factor when lower=True.

How it works

The function factors a Hermitian positive-definite matrix into a triangular factor and its conjugate transpose. Set lower to choose L in A = L L*; otherwise it returns an upper factor U satisfying A = U* U. It can optionally reuse input storage and validate finiteness.

Syntax

scipy.linalg.cholesky(a, lower=False, overwrite_a=False, check_finite=True)

Parameters

NameTypeDescription
a(M, M) array_likeSquare matrix to decompose.
lowerbool, optionalSelects the lower-triangular factor when true; otherwise selects the upper-triangular factor.
overwrite_abool, optionalAllows the input data to be overwritten, which may improve performance.
check_finitebool, optionalChecks whether the entire input contains only finite numbers.

Returns

ndarray of shape (M, M): the upper- or lower-triangular Cholesky factor of a.

Key points

  • Use this function to factor a matrix through Cholesky decomposition.
  • For lower=True, the factor satisfies A = L L*; otherwise it satisfies A = U* U.
  • Without changing lower, the returned factor is upper triangular.
  • The lower argument selects which triangular orientation to compute.
  • overwrite_a may allow input data to be replaced and can improve performance.
  • check_finite determines whether SciPy validates all matrix entries as finite.
  • The return value is an ndarray containing the requested triangular factor.

Common mistakes

  • When lower is selected, only the lower triangle is read; otherwise only the upper triangle is read, so the unused half need not be consistent.
  • Turning off check_finite can improve speed, but unsafe inputs containing NaNs or infinities may cause serious failures.

Example: Lower-triangular factorization

import numpy as np
from scipy.linalg import cholesky

a = np.array([[4.0, 2.0], [2.0, 2.0]])
L = cholesky(a, lower=True)
assert np.allclose(L @ L.T, a)
print(L)

Computes a lower-triangular factor and verifies that multiplying it by its transpose reconstructs the positive-definite input.

When to use it

Positive-definite linear systems

Solve systems involving symmetric or Hermitian positive-definite matrices efficiently.

Covariance factorization

Represent covariance or kernel matrices for Gaussian models.

Correlated random sampling

Generate correlated samples using a triangular matrix.

Interview questions

QWhat does scipy.linalg.cholesky compute?

It computes the Cholesky factorization of a Hermitian positive-definite matrix. With the default, it returns an upper-triangular U such that A = U* U; with lower=True, it returns L such that A = L L*.

Follow-up: What happens for a matrix that is not positive definite? The decomposition fails and SciPy raises LinAlgError.

QHow does lower affect the result?

The default is lower=False, so the result is upper triangular. Passing lower=True requests the lower-triangular factor instead.

Follow-up: Why can the two choices differ for complex matrices? The factorization uses the conjugate transpose, not an ordinary transpose.

QWhat do overwrite_a and check_finite control?

overwrite_a permits SciPy to overwrite the input storage, potentially improving performance. check_finite controls whether SciPy checks that the entire input contains only finite values.

Follow-up: When might check_finite=False be appropriate? Only when finiteness is already guaranteed and avoiding validation is worth the risk.

  • scipy.linalg.cho_factor
  • scipy.linalg.cho_solve
  • scipy.linalg.eigvalsh

Source: cholesky — SciPy v1.18.0 Manual. Checked 2026-10-15.