H(s)

Transfer Function

Continuous
Run the live example Free · no sign-up · runs in your browser

The TransferFunction block implements arbitrary linear time-invariant (LTI) continuous dynamic systems defined by numerator and denominator polynomials in the Laplace variable ss. It is one of the most fundamental blocks in control engineering, representing physical plants, analog and digital filter networks, sensor dynamics, and compensators. The block parses polynomial strings in standard symbolic notation (e.g. "s + 1" or "s^2 + 2s + 10"), constructs an internal controllable canonical state-space realization, and integrates system states using high-order WASM ODE solvers.

Video tutorial

Mathematical Model

In the Laplace domain (ss), the continuous transfer function relating input U(s)U(s) to output Y(s)Y(s) is:

H(s)=Y(s)U(s)=B(s)A(s)=bmsm+bm−1sm−1+⋯+b1s+b0ansn+an−1sn−1+⋯+a1s+a0H(s) = \frac{Y(s)}{U(s)} = \frac{B(s)}{A(s)} = \frac{b_m s^m + b_{m-1} s^{m-1} + \dots + b_1 s + b_0}{a_n s^n + a_{n-1} s^{n-1} + \dots + a_1 s + a_0}

where B(s)B(s) is defined by numerator and A(s)A(s) is defined by denominator.

For physical causality, the system must be proper (n≥mn \ge m with an≠0a_n \ne 0). If n>mn > m, the system is strictly proper with direct feedthrough D=0D = 0. If n=mn = m, the system has direct feedthrough D=bn/anD = b_n / a_n.

Dividing numerator and denominator by ana_n normalizes the denominator to monic form (sn+aˉn−1sn−1+⋯+aˉ0s^n + \bar{a}_{n-1} s^{n-1} + \dots + \bar{a}_0). The block realizes the system in controllable canonical state-space form:

[x˙1x˙2⋮x˙n]=[010…0001…0⋮⋮⋮⋱⋮−aˉ0−aˉ1−aˉ2…−aˉn−1][x1x2⋮xn]+[00⋮1]u\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \\ \vdots \\ \dot{x}_n \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 & \dots & 0 \\ 0 & 0 & 1 & \dots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ -\bar{a}_0 & -\bar{a}_1 & -\bar{a}_2 & \dots & -\bar{a}_{n-1} \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} + \begin{bmatrix} 0 \\ 0 \\ \vdots \\ 1 \end{bmatrix} u

The output equation is:

y(t)=(bˉ0−aˉ0D)x1+(bˉ1−aˉ1D)x2+⋯+(bˉn−1−aˉn−1D)xn+Du(t)y(t) = (\bar{b}_0 - \bar{a}_0 D) x_1 + (\bar{b}_1 - \bar{a}_1 D) x_2 + \dots + (\bar{b}_{n-1} - \bar{a}_{n-1} D) x_n + D u(t)

System stability is guaranteed if and only if all roots of the characteristic polynomial A(s)=0A(s) = 0 reside strictly in the open left half of the complex plane (Re⁡(s)<0\operatorname{Re}(s) < 0).

Inputs & Outputs

Direction ID Label Type Status
→ In in Input number Required
→ In reset Reset number Optional
← Out out Output number Output

Parameters

Parameters Label Type Default Description
numerator Numerator polynomial 1
denominator Denominator polynomial s+1
initialCondition Initial Condition number 0

Usage Examples

Example 1: Third-Order Butterworth Low-Pass Butterworth Filter

Designing a continuous anti-aliasing low-pass filter with cutoff frequency ωc=10 rad/s\omega_c = 10\text{ rad/s}. The normalized 3rd-order Butterworth polynomial is (s+10)(s2+10s+100)=s3+20s2+200s+1000(s+10)(s^2 + 10s + 100) = s^3 + 20s^2 + 200s + 1000. Configuring numerator = "1000" and denominator = "s^3 + 20s^2 + 200s + 1000" attenuates high-frequency noise at −60 dB/decade-60\text{ dB/decade} while maintaining flat passband gain.

Example 2: Flexible Drive Shaft Resonant Dynamics

Modeling the torsional compliance of an industrial robotic joint with a natural resonance frequency of 50 rad/s50\text{ rad/s} and damping ratio ζ=0.05\zeta = 0.05. Configuring numerator = "2500" and denominator = "s^2 + 5s + 2500" accurately reproduces high-frequency oscillatory torque transients in response to motor acceleration steps.

Remarks & Best Practices

  • Proper System Requirement: The degree of the numerator mm must not exceed the degree of the denominator nn (m≤nm \le n). Non-causal improper systems (m>nm > n) violate physical causality and trigger a configuration error.
  • Continuous State Integration: Implemented as continuous ODE states in Rust/WASM, integrating smoothly with RK4, RK45 (Dormand-Prince), and stiff TR-BDF2 implicit solvers.
  • Symbolic String Parsing Flexibility: The parser natively understands algebraic terms with exponents (e.g. s^2 + 2s + 1), implicit multiplication (2s), explicit multiplication (2*s), and whitespace tolerance.
  • External Reset Support: Connecting a non-zero signal to the optional reset input port immediately zeroes all internal state integrator accumulators, enabling bumpless reset during operating mode transitions.

Frequently Asked Questions (FAQ)

Q: How to simulate high-order transfer functions without numerical instability?

Polynomial transfer functions with degree n>5n > 5 suffer from ill-conditioning in floating-point calculations because polynomial roots are hypersensitive to coefficient perturbations (Wilkinson's phenomenon). Decompose high-order polynomials into a cascade of first-order and second-order sections (biquads), or convert the system into State-Space modal canonical form.

Related Components

  • ZeroPole: Factored pole-zero representation K∏(s−zi)/∏(s−pj)K \prod(s - z_i) / \prod(s - p_j).
  • SecondOrderSystem: Dedicated second-order model parameterized by ωn\omega_n and ζ\zeta.
  • LeadLag: First-order phase lead or phase lag compensator.
  • Integrator: Pure 1/s1/s continuous dynamic integration block.