Generated reference › Partial Fraction Expansion — Control Systems/Symbolic
kind: generated#block#control-systems-symbolic

Partial Fraction Expansion — Control Systems/Symbolic

Σ r/(x−p) partfrac

Control_Systems/Symbolic/Partial_Fraction_Expansion · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Partial Fraction Expansion

Control Systems / Symbolic

Expands a rational expression into partial fractions symbolically and evaluates the result on the input at every sample – MATLAB's partfrac:

f(x) → Σ r / (x − p)k  +  a polynomial part

The expansion is done once, when the configuration loads, over exact rational arithmetic, including repeated real roots. A pole that cannot be placed exactly – an irreducible quadratic – keeps its quadratic term, which is what MATLAB does too.

The factory setting is (x² + 3x + 5) / ((x−9)(x+7)²), which expands to 113/(256(x−9)) + 143/(256(x+7)) − 33/(16(x+7)²) – a simple root and a repeated one, so the block out of the library is a worked example of both. ⚠ Its poles are at 9 and −7, deliberately far from the origin: a factory default whose pole sits at a round number is one a sample run walks straight into.

Ports

  • x – the variables, a vector of n entries (a column [n,1] or a row [1,n]) where n is the number of names in Variables: entry k is the k-th name. A Mux in front builds it from scalar signals; with one variable the scalar signal IS the input.
  • y – the expanded expression, the same shape as the expression: [1,1] for a scalar, [r,c] for a matrix literal, which is expanded entry by entry.

Parameters

  • Expression – the expression to expand, in MATLAB syntax over the names in Variables: numbers, pi, + - * / ^, parentheses and the functions sin cos tan sec csc cot asin acos atan acot sinh cosh tanh asinh acosh atanh exp log log2 log10 sqrt abs sign heaviside. It is the rational part in the expansion variable that is expanded; anything else is carried along as a coefficient.
  • Variables – the names of the input's entries, in order: x, or x a when the coefficients are variables too. Each is a MATLAB identifier, none may repeat, and none may be a function name or pi, e, i, j, Inf, NaN or eps. At most 12.
  • Expansion Variable – which of the declared Variables the expansion is taken over, by name. It must be one of them. Every other variable is treated as a constant, exactly as MATLAB's second argument does.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The algebra is done once, at configuration load; what each target carries is the expanded form, printed as one inline expression per entry with its constants folded to 17 significant digits, so a generated core expands nothing. The three HDL targets are simulation-only real arithmetic, quantized to Q16.16 only at the ports: a sum of poles divides across many orders of magnitude, which is not a fixed-point datapath.

Simulink bridge

None (Support::None). partfrac is a Symbolic Math Toolbox function, and that toolbox ships no Simulink library at all, so there is no library path a diagram could name; the bridge reports this block rather than dropping it, and it therefore has no parity testbench. Code export verification covers it across all ten languages. No configuration crosses, including "Sampling Time (s)".

Notes

  • ⚠ The result is algebraically EQUAL to the expression, and that is the point. This block does not compute a different number from Symbolic Expression; it computes the same number by different arithmetic. The two disagree only in floating point – and near a pole the expanded form is the better-conditioned one, which is why the residue form is worth having on a wire at all.
  • ⚠ A pole is still a pole. Where the denominator vanishes the value is an infinity, in the expanded form exactly as in the original. Expanding does not remove a singularity, it redistributes it.
  • An irreducible quadratic keeps its quadratic term rather than being split over complex roots, which is MATLAB's behaviour too: this console's arithmetic is over the rationals.
  • abs, sign and heaviside are accepted here, as they are on Symbolic Matrix Inverse: nothing is differentiated. They are carried as opaque coefficients, not expanded.
  • Algebraic, with no state: the output depends only on the current input.
  • Size limits are on the generated code: 144 entries, 4000 operations per entry.
  • No state space: the map is nonlinear in general, so model reduction correctly declines the block.

Code facts#

FactValue
registered typeControl_Systems/Symbolic/Partial_Fraction_Expansion
familyControl_Systems/Symbolic
solver environment classICoreBlock_0_Control_Systems_1_Symbolic_2_Partial_Fraction_Expansion
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Partial_Fraction_Expansion/ICoreBlock_0_Control_Systems_1_Symbolic_2_Partial_Fraction_Expansion.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Partial_Fraction_Expansion/ICoreBlock_0_Control_Systems_1_Symbolic_2_Partial_Fraction_Expansion.h
default size on canvas160 × 70 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublex
2outICoreDoubley

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Expression(x^2 + 3*x + 5)/((x - 9)*(x + 7)^2)—
Variablesx—
Expansion Variablex—

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): partfrac is a Symbolic Math Toolbox function, and that toolbox ships no Simulink library at all, so there is no library path a diagram could name; the block is reported rather than dropped when a model crosses

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Partial Fraction Expansion -- partfrac, expanded once at config load f(x) -> sum of r / (x - p)^k plus a polynomial part

The expansion runs ONCE, when the configuration loads, over exact rational arithmetic; what each of the ten targets carries is the expanded form, as one inline expression.

⚠ THE RESULT IS ALGEBRAICALLY EQUAL TO WHAT WENT IN, AND THAT IS THE POINT. This block does not compute a different number from Symbolic Expression -- it computes the same number by DIFFERENT ARITHMETIC. A ratio of two polynomials and a sum of simple poles disagree in floating point, and near a pole the expanded form is the better-conditioned one, which is the reason the residue form exists. A reader who expects a new value will be disappointed; the description says so plainly rather than implying otherwise.

The reading, the sizing contract, compute_h and all ten generators are ICoreSymbolicBlockBase's; the expansion is the console's own symbolic engine's, reached through ICoreSymbolicProgram. This file is what is genuinely this block's.

⚠ ALGEBRA, NOT CALCULUS, so abs and sign are accepted here as they are on Symbolic Matrix Inverse -- nothing is differentiated.

Sample results#

Partial Fraction Expansion — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per samplePartial Fraction Expansion — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-0.04-0.03-0.02-0.01-2-10123inputoutput
tin ICoreDouble-Out-0out ICoreDouble-Out-0
0-2-0.01091
0.40.5-0.01412
0.8-2-0.01091
1.20.5-0.01412
1.6-2-0.01091
20.5-0.01412
2.4-2-0.01091
2.80.5-0.01412
3.2-2-0.01091
3.60.5-0.01412
4-2-0.01091
4.40.5-0.01412
4.8-2-0.01091
5.20.5-0.01412

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)-0.01758 … -0.01134
rampRamp: slope 1 from t = 0-0.1115 … -0.01134
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-0.01757 … -0.008333
stepStep: 0 -> 1 at t = 1 s-0.01758 … -0.01134

Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample

Category static · sample time 0.1 · 60 steps · commit 47621bb5e · produced by docsSample --out <folder> --blocks Laplace_Transform Z_Transform Partial_Fraction_Expansion --steps 60 · data docs/generated/samples/Control_Systems__Symbolic__Partial_Fraction_Expansion.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).