Eigenvalues

Overview

Eigenvalues and eigenvectors describe how a linear transformation scales and reorients special directions in a vector space. In applied math, machine learning, and engineering, eigen-analysis is a core tool for understanding stability, modal behavior, covariance structure, and dimensionality. Instead of treating a matrix only as a grid of numbers, eigenvalue methods reveal its intrinsic spectral structure. This makes them essential for tasks ranging from vibration analysis and control design to principal-component workflows.

The core unifying idea is the spectral relation A v = \lambda v, where \lambda is an eigenvalue and v is a corresponding eigenvector. For general matrices, eigenvalues may be complex and eigenvectors may not form an orthogonal basis, while symmetric (or Hermitian) matrices have real spectra and much stronger numerical properties. In practice, analysts choose solvers based on matrix structure and output needs: eigenvalues only vs. eigenvalues plus eigenvectors, and general vs. symmetric/Hermitian assumptions. These choices directly affect computational cost, numerical stability, and interpretability.

This category is implemented with SciPy Linear Algebra, specifically routines in scipy.linalg that wrap mature LAPACK kernels. SciPy provides robust dense linear algebra algorithms used broadly in scientific computing, optimization, and simulation. The Boardflare tools expose these routines in spreadsheet-ready form while preserving the underlying numerical behavior.

For general square matrices, EIG and EIGVALS provide the standard nonsymmetric eigenvalue workflows. EIG computes both eigenvalues and eigenvectors (or either result based on return type), making it the right choice when mode shapes or invariant directions are required. EIGVALS focuses on eigenvalues alone, which is often sufficient for spectral radius checks, stability screening, and characteristic-root analysis. Because general problems can produce complex roots, these functions support complex-valued outputs that are common in oscillatory and rotation-dominated systems.

For symmetric/Hermitian matrices, EIGH and EIGVALSH exploit structure for better efficiency and numerical reliability. EIGH returns real eigenvalues and, when needed, orthonormal eigenvectors that are especially useful in PCA-style decompositions, covariance analysis, and energy mode interpretation. EIGVALSH computes only the real eigenvalues, which is typically faster when vectors are unnecessary and the goal is spectrum-only diagnostics. Together, these specialized solvers provide a practical path to high-quality results whenever matrix symmetry or Hermitian structure is known in advance.

EIG

Solve an ordinary or generalized eigenvalue problem for a square matrix. Returns eigenvalues or eigenvectors. Since eigenvalues and eigenvectors can be complex for general matrices, any complex values are returned as Excel Data Types with Real, Imaginary, Magnitude, and Phase properties.

Excel Usage

=EIG(matrix, eig_ret_type)
  • matrix (list[list], required): Square 2D array of numeric values.
  • eig_ret_type (str, optional, default: “vals”): The component to return.

Returns (list[list]): 2D array containing the requested component (eigenvalues or eigenvectors). Complex values are Data Types.

Example 1: Eigenvalues of 2x2 matrix

Inputs:

matrix eig_ret_type
1 2 vals
3 4

Excel formula:

=EIG({1,2;3,4}, "vals")

Expected output:

Result
-0.372281 5.37228
Example 2: Eigenvectors of a rotation matrix

Inputs:

matrix eig_ret_type
0 -1 vecs
1 0

Excel formula:

=EIG({0,-1;1,0}, "vecs")

Expected output:

Result
0.707107 0.707107
[object Object] [object Object]

Python Code

Show Code
import numpy as np
from scipy.linalg import eig as scipy_eig

def eig(matrix, eig_ret_type='vals'):
    """
    Compute eigenvalues and eigenvectors of a general square matrix.

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

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

    Args:
        matrix (list[list]): Square 2D array of numeric values.
        eig_ret_type (str, optional): The component to return. Valid options: Eigenvalues, Eigenvectors. Default is 'vals'.

    Returns:
        list[list]: 2D array containing the requested component (eigenvalues or eigenvectors). Complex values are Data Types.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        matrix = to2d(matrix)

        if not isinstance(matrix, list) or not matrix or not all(isinstance(row, list) for row in matrix):
            return "Error: matrix must be a non-empty 2D list"

        n = len(matrix)
        if any(len(row) != n for row in matrix):
            return "Error: matrix must be square (n x n)"

        try:
            a = np.array(matrix, dtype=float)
        except (ValueError, TypeError):
            return "Error: matrix must contain numeric values"

        if not np.all(np.isfinite(a)):
            return "Error: matrix must contain only finite numbers"

        try:
            vals, vecs = scipy_eig(a)
        except Exception as e:
            return f"Error: {str(e)}"

        def format_complex(res):
            if not np.iscomplexobj(res):
                return (res.reshape(1, -1) if res.ndim == 1 else res).tolist()

            out = []
            for row in (res.reshape(1, -1) if res.ndim == 1 else res):
                out_row = []
                for val in row:
                    if val.imag == 0.0:
                        out_row.append(float(val.real))
                    else:
                        out_row.append({
                            "type": "Double",
                            "basicValue": float(val.real),
                            "properties": {
                                "Real": {"type": "Double", "basicValue": float(val.real)},
                                "Imaginary": {"type": "Double", "basicValue": float(val.imag)},
                                "Magnitude": {"type": "Double", "basicValue": float(np.abs(val))},
                                "Phase": {"type": "Double", "basicValue": float(np.angle(val))}
                            }
                        })
                out.append(out_row)
            return out

        rt = eig_ret_type.lower()
        if rt == "vals":
            return format_complex(vals)
        else:
            return format_complex(vecs)

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

Online Calculator

Square 2D array of numeric values.
The component to return.

EIGH

Compute eigenvalues and optionally eigenvectors for a symmetric (real) or Hermitian (complex) matrix. These matrices are guaranteed to have real eigenvalues. This function is more efficient and numerically stable for these matrix types than the general eigenvalue solver.

Excel Usage

=EIGH(matrix, lower, eigh_ret_type)
  • matrix (list[list], required): Square symmetric or Hermitian 2D array of numeric values.
  • lower (bool, optional, default: true): Whether to use the lower or upper triangular part of the matrix.
  • eigh_ret_type (str, optional, default: “vals”): The component to return.

Returns (list[list]): 2D array containing the requested component (eigenvalues or eigenvectors).

Example 1: Eigenvalues of 2x2 symmetric matrix

Inputs:

matrix eigh_ret_type
1 2 vals
2 1

Excel formula:

=EIGH({1,2;2,1}, "vals")

Expected output:

Result
-1 3
Example 2: Eigenvectors of 2x2 symmetric matrix

Inputs:

matrix eigh_ret_type
1 2 vecs
2 1

Excel formula:

=EIGH({1,2;2,1}, "vecs")

Expected output:

Result
-0.707107 0.707107
0.707107 0.707107

Python Code

Show Code
import numpy as np
from scipy.linalg import eigh as scipy_eigh

def eigh(matrix, lower=True, eigh_ret_type='vals'):
    """
    Solve eigenvalue problem for a real symmetric or complex Hermitian matrix.

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

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

    Args:
        matrix (list[list]): Square symmetric or Hermitian 2D array of numeric values.
        lower (bool, optional): Whether to use the lower or upper triangular part of the matrix. Default is True.
        eigh_ret_type (str, optional): The component to return. Valid options: Eigenvalues, Eigenvectors. Default is 'vals'.

    Returns:
        list[list]: 2D array containing the requested component (eigenvalues or eigenvectors).
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        matrix = to2d(matrix)

        if not isinstance(matrix, list) or not matrix or not all(isinstance(row, list) for row in matrix):
            return "Error: matrix must be a non-empty 2D list"

        n = len(matrix)
        if any(len(row) != n for row in matrix):
            return "Error: matrix must be square (n x n)"

        try:
            a = np.array(matrix, dtype=float)
        except (ValueError, TypeError):
            return "Error: matrix must contain numeric values"

        if not np.all(np.isfinite(a)):
            return "Error: matrix must contain only finite numbers"

        try:
            vals, vecs = scipy_eigh(a, lower=lower)
        except Exception as e:
            return f"Error: {str(e)}"

        rt = eigh_ret_type.lower()
        if rt == "vals":
            return [vals.tolist()]
        else:
            return vecs.tolist()

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

Online Calculator

Square symmetric or Hermitian 2D array of numeric values.
Whether to use the lower or upper triangular part of the matrix.
The component to return.

EIGVALS

Compute the eigenvalues of a square matrix. For a general matrix, eigenvalues can be complex. Complex eigenvalues are returned as Excel Data Types, allowing extraction of Real, Imaginary, Magnitude, and Phase properties.

Excel Usage

=EIGVALS(matrix)
  • matrix (list[list], required): Square 2D array of numeric values.

Returns (list[list]): Row vector (1xN) containing the eigenvalues. Complex values are returned as Data Types.

Example 1: Eigenvalues of 2x2 matrix

Inputs:

matrix
1 2
3 4

Excel formula:

=EIGVALS({1,2;3,4})

Expected output:

Result
-0.372281 5.37228
Example 2: Complex eigenvalues of a rotation matrix

Inputs:

matrix
0 -1
1 0

Excel formula:

=EIGVALS({0,-1;1,0})

Expected output:

Result
[object Object] [object Object]

Python Code

Show Code
import numpy as np
from scipy.linalg import eigvals as scipy_eigvals

def eigvals(matrix):
    """
    Compute eigenvalues of a general square matrix.

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

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

    Args:
        matrix (list[list]): Square 2D array of numeric values.

    Returns:
        list[list]: Row vector (1xN) containing the eigenvalues. Complex values are returned as Data Types.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        matrix = to2d(matrix)

        if not isinstance(matrix, list) or not matrix or not all(isinstance(row, list) for row in matrix):
            return "Error: matrix must be a non-empty 2D list"

        n = len(matrix)
        if any(len(row) != n for row in matrix):
            return "Error: matrix must be square (n x n)"

        try:
            a = np.array(matrix, dtype=float)
        except (ValueError, TypeError):
            return "Error: matrix must contain numeric values"

        if not np.all(np.isfinite(a)):
            return "Error: matrix must contain only finite numbers"

        try:
            ev = scipy_eigvals(a)
        except Exception as e:
            return f"Error: {str(e)}"

        def format_complex(res):
            if not np.iscomplexobj(res):
                return (res.reshape(1, -1) if res.ndim == 1 else res).tolist()

            out = []
            for row in (res.reshape(1, -1) if res.ndim == 1 else res):
                out_row = []
                for val in row:
                    if val.imag == 0.0:
                        out_row.append(float(val.real))
                    else:
                        out_row.append({
                            "type": "Double",
                            "basicValue": float(val.real),
                            "properties": {
                                "Real": {"type": "Double", "basicValue": float(val.real)},
                                "Imaginary": {"type": "Double", "basicValue": float(val.imag)},
                                "Magnitude": {"type": "Double", "basicValue": float(np.abs(val))},
                                "Phase": {"type": "Double", "basicValue": float(np.angle(val))}
                            }
                        })
                out.append(out_row)
            return out

        return format_complex(ev)

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

Online Calculator

Square 2D array of numeric values.

EIGVALSH

Compute only the eigenvalues of a symmetric (real) or Hermitian (complex) matrix. This is more efficient than the full eigenvalue solver when eigenvectors are not needed.

Excel Usage

=EIGVALSH(matrix, lower)
  • matrix (list[list], required): Square symmetric or Hermitian 2D array of numeric values.
  • lower (bool, optional, default: true): Whether to use the lower or upper triangular part of the matrix.

Returns (list[list]): Row vector containing the real eigenvalues.

Example 1: Eigenvalues only of 2x2 symmetric matrix

Inputs:

matrix
1 2
2 1

Excel formula:

=EIGVALSH({1,2;2,1})

Expected output:

Result
-1 3

Python Code

Show Code
import numpy as np
from scipy.linalg import eigvalsh as scipy_eigvalsh

def eigvalsh(matrix, lower=True):
    """
    Compute eigenvalues of a real symmetric or complex Hermitian matrix.

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

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

    Args:
        matrix (list[list]): Square symmetric or Hermitian 2D array of numeric values.
        lower (bool, optional): Whether to use the lower or upper triangular part of the matrix. Default is True.

    Returns:
        list[list]: Row vector containing the real eigenvalues.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        matrix = to2d(matrix)

        if not isinstance(matrix, list) or not matrix or not all(isinstance(row, list) for row in matrix):
            return "Error: matrix must be a non-empty 2D list"

        n = len(matrix)
        if any(len(row) != n for row in matrix):
            return "Error: matrix must be square (n x n)"

        try:
            a = np.array(matrix, dtype=float)
        except (ValueError, TypeError):
            return "Error: matrix must contain numeric values"

        if not np.all(np.isfinite(a)):
            return "Error: matrix must contain only finite numbers"

        try:
            ev = scipy_eigvalsh(a, lower=lower)
        except Exception as e:
            return f"Error: {str(e)}"

        return [ev.tolist()]

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

Online Calculator

Square symmetric or Hermitian 2D array of numeric values.
Whether to use the lower or upper triangular part of the matrix.