Skip to content

Engineering mode (cp.ee)

Linear systems, drawn with the same machinery. A TransferFunction is a plain callable, so every renderer in the library accepts it — see engineering mode.

complexplorer.ee.TransferFunction

TransferFunction(num, den, system: str = 's')

A rational transfer function H = N/D from polynomial coefficients.

Parameters:

Name Type Description Default
num sequence of numbers

Numerator coefficients in numpy.polyval order (highest degree first).

required
den sequence of numbers

Denominator coefficients (same order). Must not be identically zero.

required
system str

"s" for continuous time (frequency contour and stability boundary are the imaginary axis) or "z" for discrete time (the unit circle).

"s"

Examples:

>>> H = TransferFunction([1], [1, 2, 2])   # 1 / (s^2 + 2s + 2)
>>> H.is_stable
True
>>> import complexplorer as cp
>>> cp.plot(cp.Rectangle(6, 6), H)

zeros property

zeros: ndarray

Roots of the numerator (no pole/zero cancellation is attempted).

poles property

poles: ndarray

Roots of the denominator (no pole/zero cancellation is attempted).

is_stable property

is_stable: bool

Strict stability: all poles in the open left half-plane (s) / unit disk (z).

Marginal poles (on the boundary) count as unstable — the conservative convention.

frequency_response

frequency_response(omega=None) -> tuple[np.ndarray, np.ndarray]

Evaluate H along the frequency contour.

s = jω for continuous systems, z = e^{jω} for discrete systems.

Parameters:

Name Type Description Default
omega array - like

Frequencies (rad/s or rad/sample). If omitted, a log-spaced grid is chosen spanning a decade beyond the smallest and largest nonzero pole/zero magnitude (fallback [0.01, 100]); for "z" systems, one period (0, π].

None

Returns:

Type Description
(omega, response) : tuple of ndarray

The frequency grid and the complex response H along the contour.

complexplorer.ee.transfer_portrait

transfer_portrait(tf: TransferFunction, domain: Rectangle | None = None, resolution: int = 400, ax: Axes | None = None, title: str | None = None, **plot_kwargs)

Phase portrait of H with poles/zeros and the stability boundary overlaid.

Composes the standard 2D plot() path (so options like cmap= and legend=True are honored). When no domain is given, a square domain enclosing all poles and zeros (with margin) is used.

Returns the matplotlib axes.

complexplorer.ee.pole_zero_plot

pole_zero_plot(tf: TransferFunction, ax: Axes | None = None, title: str | None = None)

Pole-zero map: poles ×, zeros ○, stability boundary dashed.

Returns the matplotlib axes.

complexplorer.ee.bode_plot

bode_plot(tf: TransferFunction, omega=None, title: str | None = None) -> Figure

Bode plot: magnitude 20·log10|H| (dB) and phase (degrees) over log frequency.

Returns the matplotlib figure (two stacked panels sharing the frequency axis).

complexplorer.ee.nyquist_plot

nyquist_plot(tf: TransferFunction, omega=None, ax: Axes | None = None, title: str | None = None)

Nyquist plot: the locus of H along the frequency contour, −1 marked.

Positive frequencies are drawn solid; the mirrored negative-frequency branch dashed. Returns the matplotlib axes.

complexplorer.ee.transfer_function

Rational transfer functions H = N/D and their canonical views.

The design center is that :class:TransferFunction is a plain complex callable: tf(s) evaluates polyval(num, s) / polyval(den, s), so the object composes with every complexplorer renderer directly — cp.plot(domain, tf), cp.plot_landscape_pv, cp.riemann_pv, cp.quick_plot, and STL export all accept it as an ordinary function. The views in this module add the EE-specific annotations on top:

  • :func:pole_zero_plot — poles ×, zeros ○, stability boundary
  • :func:bode_plot — magnitude (dB) and phase (degrees) over log frequency
  • :func:nyquist_plot — the H(jω) locus with the critical point −1 marked
  • :func:transfer_portrait — a phase portrait of H with poles/zeros and the stability boundary overlaid (composes the standard 2D plot() path)

Continuous-time systems (system="s") use the imaginary axis as frequency contour and stability boundary; discrete-time systems (system="z") use the unit circle.

TransferFunction

TransferFunction(num, den, system: str = 's')

A rational transfer function H = N/D from polynomial coefficients.

Parameters:

Name Type Description Default
num sequence of numbers

Numerator coefficients in numpy.polyval order (highest degree first).

required
den sequence of numbers

Denominator coefficients (same order). Must not be identically zero.

required
system str

"s" for continuous time (frequency contour and stability boundary are the imaginary axis) or "z" for discrete time (the unit circle).

"s"

Examples:

>>> H = TransferFunction([1], [1, 2, 2])   # 1 / (s^2 + 2s + 2)
>>> H.is_stable
True
>>> import complexplorer as cp
>>> cp.plot(cp.Rectangle(6, 6), H)
zeros property
zeros: ndarray

Roots of the numerator (no pole/zero cancellation is attempted).

poles property
poles: ndarray

Roots of the denominator (no pole/zero cancellation is attempted).

is_stable property
is_stable: bool

Strict stability: all poles in the open left half-plane (s) / unit disk (z).

Marginal poles (on the boundary) count as unstable — the conservative convention.

frequency_response
frequency_response(omega=None) -> tuple[np.ndarray, np.ndarray]

Evaluate H along the frequency contour.

s = jω for continuous systems, z = e^{jω} for discrete systems.

Parameters:

Name Type Description Default
omega array - like

Frequencies (rad/s or rad/sample). If omitted, a log-spaced grid is chosen spanning a decade beyond the smallest and largest nonzero pole/zero magnitude (fallback [0.01, 100]); for "z" systems, one period (0, π].

None

Returns:

Type Description
(omega, response) : tuple of ndarray

The frequency grid and the complex response H along the contour.

pole_zero_plot

pole_zero_plot(tf: TransferFunction, ax: Axes | None = None, title: str | None = None)

Pole-zero map: poles ×, zeros ○, stability boundary dashed.

Returns the matplotlib axes.

bode_plot

bode_plot(tf: TransferFunction, omega=None, title: str | None = None) -> Figure

Bode plot: magnitude 20·log10|H| (dB) and phase (degrees) over log frequency.

Returns the matplotlib figure (two stacked panels sharing the frequency axis).

nyquist_plot

nyquist_plot(tf: TransferFunction, omega=None, ax: Axes | None = None, title: str | None = None)

Nyquist plot: the locus of H along the frequency contour, −1 marked.

Positive frequencies are drawn solid; the mirrored negative-frequency branch dashed. Returns the matplotlib axes.

transfer_portrait

transfer_portrait(tf: TransferFunction, domain: Rectangle | None = None, resolution: int = 400, ax: Axes | None = None, title: str | None = None, **plot_kwargs)

Phase portrait of H with poles/zeros and the stability boundary overlaid.

Composes the standard 2D plot() path (so options like cmap= and legend=True are honored). When no domain is given, a square domain enclosing all poles and zeros (with margin) is used.

Returns the matplotlib axes.