Companion Matrix Calculator

Turn polynomials into matrices for system analysis fast. See steps, checks, and a clean matrix. Download, share, and verify outputs in seconds, anywhere easily.

White theme CSV export PDF export Optional root estimate

Calculator

Companion matrix will be n×n.
Enter a finite number (non‑zero).
Recommended for degree ≤ 10.
Enter coefficients for
p(λ) = aₙ·λⁿ + aₙ₋₁·λⁿ⁻¹ + … + a₁·λ + a₀
Reset

Formula used

For a degree n polynomial normalized to monic form:

p(λ) = λⁿ + aₙ₋₁·λⁿ⁻¹ + … + a₁·λ + a₀

The Frobenius companion matrix C is:

C = [ 0 0 … 0 −a₀ ]
[ 1 0 … 0 −a₁ ]
[ 0 1 … 0 −a₂ ]
[ ⋮ ⋮ ⋱ ⋮ ⋮ ]
[ 0 0 … 1 −aₙ₋₁ ]

Its characteristic polynomial equals p(λ), so its eigenvalues are the polynomial roots.

How to use this calculator

  1. Select the polynomial degree n.
  2. Enter the leading coefficient aₙ (must be non‑zero).
  3. Provide coefficients a₀ through aₙ₋₁.
  4. Optional: enable root estimation for numeric approximations.
  5. Press Submit to view the matrix above the form.
  6. Use CSV or PDF buttons to export your results.

Example data table

Example polynomial: 2·λ⁴ − 3·λ³ + 0·λ² + 5·λ − 7. After normalization, divide coefficients by 2.

Parameter Value Notes
Degree (n) 4 Matrix size is 4×4
Leading aₙ 2 Will be normalized to 1
a₃, a₂, a₁, a₀ −3, 0, 5, −7 Entered in coefficient fields
Normalized coefficients a₃=−1.5, a₂=0, a₁=2.5, a₀=−3.5 Used in the last column as negatives

Why companion matrices matter

A companion matrix converts a polynomial into a state matrix whose eigenvalues match the polynomial roots. This makes it useful for control design, vibration analysis, and discrete-time models, where characteristic equations arise naturally. Because the structure is fixed, you can compare different polynomials consistently, test stability by inspecting eigenvalues, and build canonical realizations. The calculator automates the construction while keeping the mapping between coefficients and matrix entries explicit.

Input normalization and scaling

Most definitions assume a monic polynomial, so the leading coefficient must be nonzero and the remaining coefficients are divided by it. Normalization improves numerical conditioning and ensures the last column is simply the negative normalized coefficients. If your coefficients vary by many orders of magnitude, consider rescaling the variable, for example λ = s·μ, to reduce overflow and improve iterative root estimation. The tool shows both entered and normalized polynomials for traceability.

Interpreting the last column

In the Frobenius form, the subdiagonal contains ones that shift the state, while the final column injects the coefficient information. For p(λ)=λⁿ+aₙ₋₁λⁿ⁻¹+…+a₁λ+a₀, the last column is −a₀, −a₁, …, −aₙ₋₁. Sign mistakes are common when copying formulas, so the “Quick validation” checklist helps confirm the pattern. Once verified, the matrix can be used directly in eigenvalue routines.

Using exports for reporting

CSV export is ideal for spreadsheets, scripts, and numerical packages that accept comma-separated matrices. PDF export is designed for sharing a static snapshot with colleagues, assignments, or audit trails. Including both the entered and normalized polynomials in the PDF reduces ambiguity when coefficients are rounded or units are implied. For repeated studies, keep a consistent degree and use the example-fill button as a template for your own datasets.

Common modelling workflows

Engineers often start with a transfer function denominator, expand it into polynomial coefficients, then build a companion matrix to obtain a state-space realization. Data scientists may use companion matrices to study linear recurrences and to compute roots as eigenvalues for forecasting. In algebra courses, the matrix provides a concrete link between polynomials and linear operators. When combined with eigenvectors, you can also form modal decompositions and sensitivity checks for parameter changes.

FAQs

1) What is a companion matrix used for?

A companion matrix represents a monic polynomial as an n×n matrix whose characteristic polynomial is the original polynomial. It is used to study roots via eigenvalues and to build canonical state‑space models.

2) Why must the leading coefficient be non‑zero?

Normalization divides all coefficients by the leading term to make the polynomial monic. If the leading coefficient is zero, the degree changes and the construction becomes invalid.

3) Does changing the polynomial scale change the matrix?

Scaling all coefficients by the same nonzero factor does not change the normalized polynomial, so the resulting companion matrix is unchanged after normalization.

4) How accurate are the estimated roots?

Root estimates are numerical approximations and can vary with coefficient scaling and problem conditioning. Use them as guidance, and verify critical results with a trusted numerical library when needed.

5) Why are there ones on the subdiagonal?

The ones shift the state basis so that powers of λ align with the state vector. This shift structure is what makes the companion form a canonical realization.

6) What do the export files contain?

The CSV contains only the matrix values, suitable for computation. The PDF includes the entered polynomial, the normalized polynomial, and the matrix rows for clear documentation.

Related Calculators

Row Reduction RREF CalculatorDiagonalization Checker CalculatorLU Decomposition Steps CalculatorQR Decomposition Steps Calculatormatrix calculator with variablesGauss-Jordan inverse calculatorPolynomial linear independence calculatorLinear independence of matrix calculatorComplex matrix inverse calculatorQR decomposition least squares

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.