Qu

eig

Builtin index · Core maths

result = eig(A)

Input: A · Output: result

What it is

Eigenvalues (and, for symmetric A, real eigenvectors) of a square n×n Mat A.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = eig(A)
A Matnot documented yet
Model —kind "eig"
values Vec or CVeca length-n Vec if all eigenvalues are real, otherwise a length-n CVec
vectors Matan n×n Mat of eigenvectors as columns when A is symmetric, otherwise Nothing
Returns a Model (kind "eig") with fields values (a length-n Vec if all eigenvalues are real, otherwise a length-n CVec) and vectors (an n×n Mat of eigenvectors as columns when A is symmetric, otherwise Nothing).

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

sym = [2, 0; 0, 3]
e = eig(sym)
print("eigenvalues = {e.values}")
print("eigenvectors = {e.vectors}")

rot = [0, -1; 1, 0]     # a rotation-like matrix: eigenvalues +-i

er = eig(rot)
print("complex eigenvalues = {er.values}")
print("eigenvectors = {er.vectors}")   # none: rot isn't symmetric

output
eigenvalues = [2, 3]
eigenvectors = [1, 0; 0, 1]
complex eigenvalues = [1j, -1j]
eigenvectors = none

from numerics-dsp

How it works

eig(A) — eigenvalues (and, for a symmetric A, real eigenvectors — dispatched on symmetry, checked directly, not assumed). Model kind "eig", fields values (real if the input is symmetric, otherwise a CVec) and vectors (a Mat when symmetric, Nothing otherwise — a general matrix's eigenvectors would themselves be complex-valued, which isn't computed here, not silently approximated).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.