How this calculation works
Construct a rational companion realization after exact common-factor cancellation.
G(s)=C(sI−A)⁻¹B+D;reduce numerator and denominator over Q first.A worked example
(1+s)/(2+3s+s²)=1/(s+2),so A=−2,B=C=1,D=0 and one state suffices.
Good to know
Proper rational ascending polynomials degree≤6;exact gcd cancellation and companion construction,constant transfer supported. No near-factor cancellation or internal-stability claim for an unentered physical realization.
Reference: SciPy transfer-function/state-space convention (opens in a new tab) ↗
A transfer function can have redundant factors
A proper rational transfer function describes a SISO input-output relation in the Laplace variable. Its numerator and denominator may share an exact polynomial factor. Cancelling that factor before building a realization removes states that do not affect the reduced rational input-output map.
This page constructs a controllable companion realization after exact rational cancellation. It is different from evaluating a transform or converting an already supplied state model between sample rates. The output matrices are one concrete coordinate representation of the same rational function,not unique physical state variables.
Compare this with the Z transform calculator for finite and rational sequences. Construct and verify a controllable state-space realization from a rational transfer function,with exact cancellation convention.
Enter coefficients with their powers understood
Numerator and denominator lists begin with the constant coefficient and continue in ascending powers of s. Entries can be exact fractions or supported exact decimal values. The denominator must be nonzero,the transfer function proper,and its degree at most six within the stated arithmetic limits.
Proper means the numerator degree is no larger than the denominator degree after trimming trailing zero coefficients. An improper transfer function would require a polynomial input-derivative part outside this state-space convention. The page rejects that case rather than silently dropping its high-order terms.
Exact gcd cancellation determines the order
The polynomial gcd is computed over the rationals,and each polynomial is divided by it exactly. This recognizes exact shared factors rather than cancelling two merely close floating roots. Close but distinct poles and zeros can be important dynamical features and are not removed by a visual tolerance.
The reduced denominator is normalized to monic form. Its degree becomes the state dimension. A constant reduced denominator produces a static gain with no dynamic states. The cancelled factor is returned separately so the difference between the entered presentation and the reduced transfer function remains reviewable.
Build a companion system and feedthrough
The companion state matrix has ones on its superdiagonal and the negated denominator coefficients in the last row. The input enters the final companion state. The output coefficients are adjusted by the direct feedthrough term so equal numerator and denominator degrees are handled correctly.
For strict properness,the feedthrough is zero. For equal degrees,it equals the normalized leading numerator coefficient. The remaining output coefficients represent the strictly proper remainder. Omitting that adjustment would generally reconstruct the wrong transfer function despite a plausible-looking state matrix.
A cancelled pole in the example
The example numerator is1+s and denominator2+3s+s²=(s+1)(s+2). Cancelling s+1 leaves1/(s+2). The minimal rational realization therefore has one state,A=−2,B=1,C=1 and D=0,rather than two dynamic states.
Substituting those matrices gives C(sI−A) inverse B+D=1/(s+2). The cancelled pole at−1 belongs to the original nonminimal polynomial presentation,not an extra mode in the reduced realization. The output retains its factor so this reduction is explicit rather than hidden.
Minimality has a specific rational meaning
For a scalar proper rational function,the coprime reduced numerator and denominator determine its McMillan degree. A controllable companion realization of that reduced form is also observable and has that degree. Different similarity-transformed realizations can have entirely different entries while describing the same input-output function.
This algebraic statement does not decide whether an original physical system has internal hidden modes. Exact transfer cancellation can conceal unstable internal behavior in a nonminimal model. The page constructs the reduced input-output realization;it does not certify the internal safety of an unentered physical realization.
Keep coefficient and state conventions together
When exporting the answer,include the ascending input convention,the companion orientation,the rational normalization and the feedthrough. Another library may use descending coefficients or the transpose companion matrix. Comparing raw entries without aligning those conventions can make equivalent realizations appear inconsistent.
Exact fractions can grow during gcd and division operations,so arithmetic resource limits may reject very large presentations. Such a rejection is not a claim that a minimal realization does not exist. It means the supported exact calculation did not complete for those coefficients.
A few questions, answered
Which coefficient order is entered?
Enter the constant coefficient first, followed by ascending powers.
Are nearly equal factors cancelled?
No. Cancellation is exact over rational coefficients.
What if the reduced function is constant?
It has zero dynamic states and a direct feedthrough gain.
Are the states physical coordinates?
They are companion coordinates;other similarity-equivalent realizations may look different.