ReferenceeigenDecomposition

<eigenDecomposition>

Computes the eigenvalues and eigenvectors of a square matrix

<eigenDecomposition> takes a square matrix supplied as a single <math> child (or a reference to one). It produces no visible output of its own; instead it exposes the results as the properties eigenvalues, eigenvectors, and numEigenvectors so they can be rendered, used in computations, or referenced from other components. The returned eigenvectors are normalized to unit length, and complex eigenvalues/eigenvectors are supported.

Attributes and Properties

Attributes for <eigenDecomposition>

Number display (5)
avoidScientificNotation

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

integer. Default value: 2. Number of decimal places to display when rendering this number.

displayDigits

integer. Default value: 3. Number of significant digits to display when rendering this number.

displaySmallAsZero

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

padZeros

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <eigenDecomposition name="e">

Number display (5)
$e.avoidScientificNotation

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$e.displayDecimals

integer. Number of decimal places to display when rendering this number.

$e.displayDigits

integer. Number of significant digits to display when rendering this number.

$e.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$e.padZeros

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Other (7)
$e.disabled

boolean. Whether this component is disabled and cannot be interacted with.

[ number ]. The eigenvalues of the matrix.

[ number ]. The eigenvectors of the matrix, as a 2D array (one column per eigenvalue).

$e.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$e.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$e.hidden

boolean. Whether this component is hidden from the rendered output.

$e.numEigenvectors

integer. The number of eigenvectors found in the decomposition.

Common to all components (4)
$e.doenetML

text. The DoenetML source code that produced this component.

$e.hide

boolean. Whether to hide this component from the rendered output.

$e.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$e.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Eigenvalues and eigenvectors of a 2×2 matrix

The matrix is provided as a <math> child of <eigenDecomposition>. The eigenvalues and eigenvectors properties are lists.


Example: Individual eigenvalues and eigenvectors

The list properties can also be indexed: eigenvalues[1], eigenvalues[2], … select individual eigenvalues, and eigenvectors[1], eigenvectors[2], … select individual eigenvectors. Each indexed eigenvector is itself a vector whose components can be accessed via .x, .y, (and .z for 3×3 matrices).


Example: Complex eigenvalues

The eigendecomposition handles complex eigenvalues/eigenvectors natively. The matrix above is a rotation-scaling matrix with eigenvalues 1±2i1 \pm 2i and complex eigenvectors.


Example: Visualizing real eigenvectors in a phase plane

Because each eigenvector is exposed as a coordinate, it can be passed directly to a graphical component such as <vector>. This makes <eigenDecomposition> useful for illustrating the eigenstructure of a 2×2 system matrix in a phase plane.


Example: Using the decomposition with a user-input matrix

The matrix child can be a literal <math>, a reference, or any expression that evaluates to a square matrix — including the value of a <matrixInput>. The numEigenvectors property reports the number of eigenvectors found; it is 0 when the child cannot be interpreted as a square numeric matrix.

Property Examples

Property Example: eigenvalues

eigenvalues is the list of eigenvalues. It can be rendered as a list or accessed by index with eigenvalues[i].


Property Example: eigenvectors

eigenvectors is a 2-D array (one row per eigenvector). Each eigenvector is normalized to unit length; access an individual eigenvector with eigenvectors[1], eigenvectors[2], … and its components with .x, .y, .z.