Partial Fraction Expansion — Control Systems/Symbolic
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 functionssin 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, orx awhen the coefficients are variables too. Each is a MATLAB identifier, none may repeat, and none may be a function name orpi,e,i,j,Inf,NaNoreps. 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,signandheavisideare 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#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Symbolic/Partial_Fraction_Expansion |
| family | Control_Systems/Symbolic |
| solver environment class | ICoreBlock_0_Control_Systems_1_Symbolic_2_Partial_Fraction_Expansion |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Partial_Fraction_Expansion/ICoreBlock_0_Control_Systems_1_Symbolic_2_Partial_Fraction_Expansion.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Partial_Fraction_Expansion/ICoreBlock_0_Control_Systems_1_Symbolic_2_Partial_Fraction_Expansion.h |
| default size on canvas | 160 × 70 px |
| ports at insert | 1 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | x |
| 2 | out | ICoreDouble | y |
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 variable | Default | Simulink parameter |
|---|---|---|
Expression | (x^2 + 3*x + 5)/((x - 9)*(x + 7)^2) | — |
Variables | x | — |
Expansion Variable | x | — |
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.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
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#
| t | in ICoreDouble-Out-0 | out ICoreDouble-Out-0 |
|---|---|---|
| 0 | -2 | -0.01091 |
| 0.4 | 0.5 | -0.01412 |
| 0.8 | -2 | -0.01091 |
| 1.2 | 0.5 | -0.01412 |
| 1.6 | -2 | -0.01091 |
| 2 | 0.5 | -0.01412 |
| 2.4 | -2 | -0.01091 |
| 2.8 | 0.5 | -0.01412 |
| 3.2 | -2 | -0.01091 |
| 3.6 | 0.5 | -0.01412 |
| 4 | -2 | -0.01091 |
| 4.4 | 0.5 | -0.01412 |
| 4.8 | -2 | -0.01091 |
| 5.2 | 0.5 | -0.01412 |
Every 4th of 60 samples, from the table stimulus.
The same rig also ran:
| Stimulus | What it is | Output range |
|---|---|---|
impulse | Impulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair) | -0.01758 … -0.01134 |
ramp | Ramp: slope 1 from t = 0 | -0.1115 … -0.01134 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | -0.01757 … -0.008333 |
step | Step: 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).