pracma (version 1.9.9)

compan: Companion Matrix

Description

Computes the companion matrix of a vector.

Usage

compan(p)

Arguments

p
vector representing a polynomial

Value

A square matrix of length(p)-1 rows and columns

Details

Computes the companion matrix corresponding to the vector p with -p[2:length(p)]/p[1] as first row.

The eigenvalues of this matrix are the roots of the polynomial.

See Also

roots

Examples

Run this code
  p <- c(1, 0, -7, 6)
  compan(p)
  # 0  7 -6
  # 1  0  0
  # 0  1  0

Run the code above in your browser using DataCamp Workspace