Taylor Approximation — Control Systems/Symbolic
Control_Systems/Symbolic/Taylor_Approximation · 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.
Taylor Approximation
Control Systems / Symbolic
Replaces the expression by its Taylor polynomial about a point and evaluates
that at every sample:
y = Σk<N f(k)(a)·(x−a)k/k!.
This is MATLAB's taylor(f, x, a, 'Order', N), and Order is MATLAB's
'Order': a truncation order, so the polynomial keeps the powers below it
– the default 6 keeps up to (x−a)⁵.
The derivatives are taken symbolically and the coefficients evaluated at the expansion point, once, when the configuration loads; what runs per sample is a polynomial in (x−a), emitted in Horner form. That is what makes this block worth having on a target with no transcendental library: a sine, a logarithm or an exponential becomes a handful of multiplies and adds.
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.
- y – the polynomial's value at x, [1,1].
Parameters
- Expression – the expression, 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. A matrix is written[f1; f2], with semicolons between rows and commas between the entries of a row.abs,signandheavisideare refused here, unlike on Symbolic Expression: see Notes. - Variables – the names of the input's entries, in order, separated by
spaces or commas:
x y z. 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 Point – the a the polynomial is written about, a finite scalar. Every derivative of the expression must be finite there.
- Order – MATLAB's
'Order', a whole number from 1 to 16: the polynomial keeps the powers below it, so Order 6 keeps (x−a)⁰ through (x−a)⁵. - 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 calculus is done once, at configuration load; what each target carries is
the RESULT, printed as one inline expression per entry with its constants folded to 17
significant digits, so a generated core differentiates nothing and has no parameter to
tune. Where a target lacks a function it gets the identity – Java has no inverse
hyperbolic functions and PLC Structured Text no hyperbolic functions at all, so those are
written through log, exp and sqrt. The three
HDL targets are simulation-only real arithmetic, quantized to
Q16.16 only at the ports: a derivative of a transcendental expression is not a fixed-point
datapath. Taylor's polynomial is the one case where the HDL body holds no transcendental call at all -- it is a Horner nest of multiplies and adds -- and it is still carried in real rather than Q16.16, because the coefficients of a high-order term are far below one quantum.
Simulink bridge
None (Support::None). taylor 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
- One variable. The expansion is in a single variable, so Variables names exactly one and the input is [1,1].
- The polynomial is only good near the point. Away from a it departs from the expression it came from; the block evaluates the polynomial, and does not warn.
- The coefficients are baked in, not tunable. Changing the expansion point or the order re-derives them and changes the exported code.
abs,signandheavisideare refused in the expression. The symbolic engine answersdiff(abs(x))only under an assumption that x is real – console state a block may not depend on – and the derivative ofsignorheavisideis an impulse no sample can carry. Symbolic Expression accepts all three, because it differentiates nothing.- Algebraic, with no state: the output depends only on the current input.
- The calculus is the console's own symbolic engine's (the engine behind
diffandjacobianon the command line), over exact rational arithmetic; constants are folded to doubles only after it. - Size limits are on the generated code: 144 entries, 4000 operations per entry. An expression whose derivatives grow past that is refused with that reason rather than truncated.
- 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/Taylor_Approximation |
| family | Control_Systems/Symbolic |
| solver environment class | ICoreBlock_0_Control_Systems_1_Symbolic_2_Taylor_Approximation |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Taylor_Approximation/ICoreBlock_0_Control_Systems_1_Symbolic_2_Taylor_Approximation.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Taylor_Approximation/ICoreBlock_0_Control_Systems_1_Symbolic_2_Taylor_Approximation.h |
| default size on canvas | 140 × 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 | exp(x)*cos(2*x) | — |
Variables | x | — |
Expansion Point | 0 | — |
Order | 6 | — |
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): taylor 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).
Taylor Approximation -- taylor on an expression compiled at config load y = SUM(k = 0 .. N-1) f^(k)(a) / k! * (x - a)^k
MATLAB's
taylor(f, x, a, 'Order', N): the polynomial that agrees with f to N - 1 powers at a. The coefficients are numbers by the time any generator runs, and the polynomial is emitted in HORNER form -- which is what makes a transcendental expression cheap on a target that has no library to call.The reading, the sizing contract, compute_h and all ten generators are ICoreSymbolicBlockBase's; the calculus is the console's symbolic engine's, reached through ICoreSymbolicProgram. This file is what is genuinely this block's: its operation, its ports, its configs, its description, its icon and its Simulink entry.
VERIFIED OUTSIDE ICORE, because code-export verification compares the block with itself: the block's own C++ evaluation of its rig configuration was compared with MATLAB R2026a's taylor on the same expression at the same points. Max |difference| 8.67e-16, which is rounding on the last bit rather than a tolerance.
Sample results#
| t | in ICoreDouble-Out-0 | out ICoreDouble-Out-0 |
|---|---|---|
| 0 | -2 | -7.933 |
| 0.4 | 0.5 | 0.8883 |
| 0.8 | -2 | -7.933 |
| 1.2 | 0.5 | 0.8883 |
| 1.6 | -2 | -7.933 |
| 2 | 0.5 | 0.8883 |
| 2.4 | -2 | -7.933 |
| 2.8 | 0.5 | 0.8883 |
| 3.2 | -2 | -7.933 |
| 3.6 | 0.5 | 0.8883 |
| 4 | -2 | -7.933 |
| 4.4 | 0.5 | 0.8883 |
| 4.8 | -2 | -7.933 |
| 5.2 | 0.5 | 0.8883 |
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) | -1.283 … 1 |
ramp | Ramp: slope 1 from t = 0 | -13.11 … 1667 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | -1.28 … 1.128 |
step | Step: 0 -> 1 at t = 1 s | -1.283 … 1 |
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 83b4036dc8d5efdf28a47c36be1e27203065c75b · produced by docsSample --out <folder> --blocks Symbolic_Expression Symbolic_Derivative Gradient Jacobian Hessian Divergence_And_Curl Laplacian Taylor_Approximation Linear_Program LTI_System Wind_Turbulence_Model --steps 60 · data docs/generated/samples/Control_Systems__Symbolic__Taylor_Approximation.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).