Special Matrices

Overview

Special matrices are matrix classes defined by algebraic or structural patterns that make them easier to analyze than arbitrary dense matrices. In applied linear algebra, these patterns often reduce storage, enable faster algorithms, and reveal interpretable behavior in systems from signal processing to numerical approximation. Special matrices matter in data science and engineering because many real operators (convolution, moments, covariance surrogates, combinatorial transforms) naturally produce structured matrices. Recognizing structure early is a practical way to improve both numerical robustness and computational efficiency.

The unifying idea is structure by diagonals, symmetries, or combinatorial rules. Toeplitz and Hankel families are diagonal-constant in opposite directions, circulant matrices add periodic wrap-around structure, Hadamard matrices enforce orthogonality with \pm 1 entries, Hilbert matrices expose extreme ill-conditioning, and Pascal matrices encode binomial identities. These relationships are central in matrix analysis because structure controls properties such as rank behavior, conditioning, and the complexity of solving Ax=b. For example, Toeplitz matrices satisfy A_{i,j}=c_{i-j}, while Hilbert matrices satisfy H_{i,j}=\frac{1}{i+j-1}.

Implementation in this category is powered by SciPy Linear Algebra, specifically the special matrix constructors in scipy.linalg. SciPy provides tested, production-grade routines that mirror standard definitions from numerical linear algebra and integrate cleanly with NumPy arrays. This makes the tools suitable for both exploratory spreadsheet workflows and reproducible scientific computing pipelines.

TOEPLITZ, HANKEL, and CIRCULANT cover the main diagonal-structured families. TOEPLITZ builds matrices with constant descending diagonals and appears naturally in convolution, time-series models, and stationary correlation approximations. HANKEL uses constant ascending diagonals and is common in moment problems, system identification, and signal subspace methods. CIRCULANT is a periodic Toeplitz variant where rows are cyclic shifts; it is especially useful for FFT-based formulations and periodic boundary models.

HADAMARD and PASCAL represent discrete combinatorial structure with strong algebraic utility. HADAMARD returns orthogonal \pm 1 matrices (for orders that are powers of two), used in coding theory, transform methods, and design-of-experiments constructions. PASCAL generates symmetric, lower, or upper Pascal matrices built from binomial coefficients, making it useful for polynomial identities, finite-difference style transforms, and educational demonstrations of combinatorics in linear algebra. Together, they show how integer-valued patterns can still support powerful orthogonality and basis-transform workflows.

HILBERT is the canonical conditioning stress test in this set. Its entries decrease harmonically, and even modest sizes become numerically challenging, so it is widely used to demonstrate floating-point sensitivity, backward error behavior, and solver stability limits. In practice, HILBERT is less about modeling physical systems directly and more about diagnosing whether algorithms and precision choices are reliable under adverse conditioning. Used with the other constructors, it helps distinguish “structured and efficient” from “structured but numerically delicate” cases.

CIRCULANT

Constructs a circulant matrix where each row is a cyclic shift of the previous row. The first row is the cyclic shift of the column provided.

Excel Usage

=CIRCULANT(column)
  • column (list[list], required): First column of the matrix.

Returns (list[list]): 2D array representing the circulant matrix.

Example 1: Circulant matrix from 3 elements

Inputs:

column
1 2 3

Excel formula:

=CIRCULANT({1,2,3})

Expected output:

Result
1 3 2
2 1 3
3 2 1

Python Code

Show Code
import numpy as np
from scipy.linalg import circulant as scipy_circulant

def circulant(column):
    """
    Construct a circulant matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.circulant.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        column (list[list]): First column of the matrix.

    Returns:
        list[list]: 2D array representing the circulant matrix.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        c = np.array(to2d(column), dtype=float).flatten()

        try:
            res = scipy_circulant(c)
        except Exception as e:
            return f"Error: {str(e)}"

        return res.tolist()

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

First column of the matrix.

HADAMARD

Constructs an n-by-n Hadamard matrix, where n must be a power of 2. A Hadamard matrix is a square matrix whose entries are either +1 or -1 and whose rows are mutually orthogonal.

Excel Usage

=HADAMARD(n)
  • n (int, required): The order of the matrix. Must be a power of 2.

Returns (list[list]): 2D array representing the Hadamard matrix.

Example 1: Hadamard matrix of order 2

Inputs:

n
2

Excel formula:

=HADAMARD(2)

Expected output:

Result
1 1
1 -1
Example 2: Hadamard matrix of order 4

Inputs:

n
4

Excel formula:

=HADAMARD(4)

Expected output:

Result
1 1 1 1
1 -1 1 -1
1 1 -1 -1
1 -1 -1 1

Python Code

Show Code
import numpy as np
from scipy.linalg import hadamard as scipy_hadamard

def hadamard(n):
    """
    Construct a Hadamard matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.hadamard.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        n (int): The order of the matrix. Must be a power of 2.

    Returns:
        list[list]: 2D array representing the Hadamard matrix.
    """
    try:
        # n might be passed as a list from Excel/Pyodide in some cases
        if isinstance(n, list):
             n_val = int(n[0][0])
        else:
             n_val = int(n)

        try:
            res = scipy_hadamard(n_val)
        except Exception as e:
            return f"Error: {str(e)}"

        return res.tolist()

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

The order of the matrix. Must be a power of 2.

HANKEL

Constructs a Hankel matrix, which is a matrix where each ascending diagonal from left to right is constant.

Excel Usage

=HANKEL(column, row)
  • column (list[list], required): First column of the matrix.
  • row (list[list], optional, default: null): Last row of the matrix. The last element of ‘column’ and the first element of ‘row’ should be the same.

Returns (list[list]): 2D array representing the Hankel matrix.

Example 1: Hankel matrix from column only

Inputs:

column
1 2 3

Excel formula:

=HANKEL({1,2,3})

Expected output:

Result
1 2 3
2 3 0
3 0 0
Example 2: Hankel matrix with column and row

Inputs:

column row
1 2 3 3 4 5

Excel formula:

=HANKEL({1,2,3}, {3,4,5})

Expected output:

Result
1 2 3
2 3 4
3 4 5

Python Code

Show Code
import numpy as np
from scipy.linalg import hankel as scipy_hankel

def hankel(column, row=None):
    """
    Construct a Hankel matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.hankel.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        column (list[list]): First column of the matrix.
        row (list[list], optional): Last row of the matrix. The last element of 'column' and the first element of 'row' should be the same. Default is None.

    Returns:
        list[list]: 2D array representing the Hankel matrix.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        c = np.array(to2d(column), dtype=float).flatten()
        if row is not None:
            r = np.array(to2d(row), dtype=float).flatten()
        else:
            r = None

        try:
            res = scipy_hankel(c, r)
        except Exception as e:
            return f"Error: {str(e)}"

        return res.tolist()

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

First column of the matrix.
Last row of the matrix. The last element of 'column' and the first element of 'row' should be the same.

HILBERT

Constructs an n-by-n Hilbert matrix. A Hilbert matrix is a square matrix with entries H_{i,j} = \frac{1}{i+j-1}. Hilbert matrices are notorious for being highly ill-conditioned.

Excel Usage

=HILBERT(n)
  • n (int, required): The order of the matrix.

Returns (list[list]): 2D array representing the Hilbert matrix.

Example 1: Hilbert matrix of order 3

Inputs:

n
3

Excel formula:

=HILBERT(3)

Expected output:

Result
1 0.5 0.333333
0.5 0.333333 0.25
0.333333 0.25 0.2

Python Code

Show Code
import numpy as np
from scipy.linalg import hilbert as scipy_hilbert

def hilbert(n):
    """
    Construct a Hilbert matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.hilbert.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        n (int): The order of the matrix.

    Returns:
        list[list]: 2D array representing the Hilbert matrix.
    """
    try:
        if isinstance(n, list):
             n_val = int(n[0][0])
        else:
             n_val = int(n)

        try:
            res = scipy_hilbert(n_val)
        except Exception as e:
            return f"Error: {str(e)}"

        return res.tolist()

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

The order of the matrix.

PASCAL

Constructs an n-by-n Pascal matrix. A Pascal matrix contains the binomial coefficients as its entries.

Excel Usage

=PASCAL(n, pascal_kind)
  • n (int, required): The order of the matrix.
  • pascal_kind (str, optional, default: “symmetric”): Type of Pascal matrix to return (symmetric, lower, or upper).

Returns (list[list]): 2D array representing the Pascal matrix.

Example 1: Symmetric Pascal matrix of order 3

Inputs:

n pascal_kind
3 symmetric

Excel formula:

=PASCAL(3, "symmetric")

Expected output:

Result
1 1 1
1 2 3
1 3 6
Example 2: Lower triangular Pascal matrix

Inputs:

n pascal_kind
3 lower

Excel formula:

=PASCAL(3, "lower")

Expected output:

Result
1 0 0
1 1 0
1 2 1

Python Code

Show Code
import numpy as np
from scipy.linalg import pascal as scipy_pascal

def pascal(n, pascal_kind='symmetric'):
    """
    Construct a Pascal matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.pascal.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        n (int): The order of the matrix.
        pascal_kind (str, optional): Type of Pascal matrix to return (symmetric, lower, or upper). Valid options: Symmetric, Lower Triangular, Upper Triangular. Default is 'symmetric'.

    Returns:
        list[list]: 2D array representing the Pascal matrix.
    """
    try:
        if isinstance(n, list):
             n_val = int(n[0][0])
        else:
             n_val = int(n)

        try:
            res = scipy_pascal(n_val, kind=pascal_kind.lower())
        except Exception as e:
            return f"Error: {str(e)}"

        return res.tolist()

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

The order of the matrix.
Type of Pascal matrix to return (symmetric, lower, or upper).

TOEPLITZ

Constructs a Toeplitz matrix, which is a matrix where each descending diagonal from left to right is constant.

Excel Usage

=TOEPLITZ(column, row)
  • column (list[list], required): First column of the matrix.
  • row (list[list], optional, default: null): First row of the matrix. If omitted, the matrix is assumed symmetric/Hermitian based on the column.

Returns (list[list]): 2D array representing the Toeplitz matrix.

Example 1: Symmetric Toeplitz matrix

Inputs:

column
1 2 3

Excel formula:

=TOEPLITZ({1,2,3})

Expected output:

Result
1 2 3
2 1 2
3 2 1
Example 2: Asymmetric Toeplitz matrix

Inputs:

column row
1 2 3 1 4 5

Excel formula:

=TOEPLITZ({1,2,3}, {1,4,5})

Expected output:

Result
1 4 5
2 1 4
3 2 1

Python Code

Show Code
import numpy as np
from scipy.linalg import toeplitz as scipy_toeplitz

def toeplitz(column, row=None):
    """
    Construct a Toeplitz matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.toeplitz.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        column (list[list]): First column of the matrix.
        row (list[list], optional): First row of the matrix. If omitted, the matrix is assumed symmetric/Hermitian based on the column. Default is None.

    Returns:
        list[list]: 2D array representing the Toeplitz matrix.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        c = np.array(to2d(column), dtype=float).flatten()
        if row is not None:
            r = np.array(to2d(row), dtype=float).flatten()
        else:
            r = None

        try:
            res = scipy_toeplitz(c, r)
        except Exception as e:
            return f"Error: {str(e)}"

        return res.tolist()

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

First column of the matrix.
First row of the matrix. If omitted, the matrix is assumed symmetric/Hermitian based on the column.