compan: Companion Matrix

Description Usage Arguments Details Value See Also Examples

View source: R/compan.R

Description

Computes the companion matrix of a real or complex vector.

Usage

1
  compan(p)

Arguments

p

vector representing a polynomial

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.

Value

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

See Also

roots

Examples

1
2
3
4
5
  p <- c(1, 0, -7, 6)
  compan(p)
  # 0  7 -6
  # 1  0  0
  # 0  1  0

pracma documentation built on Jan. 17, 2021, 3 a.m.