Symbolic Derivative — Control Systems/Symbolic
Control_Systems/Symbolic/Symbolic_Derivative · 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.
Symbolic Derivative
Control Systems / Symbolic
Differentiates the expression symbolically and evaluates the result on the
input at every sample: y = ∂Nf / ∂vN, with
v the variable named by Differentiation Variable and N the
Order. This is MATLAB's diff(f, v, N).
It is not Continuous / Derivative, which differentiates a signal with
respect to TIME by a finite difference. Here the differentiation is exact, done once at
configuration load, and what runs per sample is the resulting expression. A matrix
expression is differentiated entry by entry, as MATLAB's own diff does.
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 derivative, the same shape as the expression: [1,1] for a scalar, [r,c] for an r-by-c matrix literal.
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. - Differentiation Variable – which of the declared Variables to differentiate against, by name. It must be one of them.
- Order – how many times, a whole number from 1 to 8.
- 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.
Simulink bridge
None (Support::None). diff 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
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/Symbolic_Derivative |
| family | Control_Systems/Symbolic |
| solver environment class | ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Derivative |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Symbolic_Derivative/ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Derivative.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Symbolic_Derivative/ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Derivative.h |
| default size on canvas | 132 × 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^3*sin(y) + exp(x*y) | — |
Variables | x y | — |
Differentiation Variable | y | — |
Order | 1 | — |
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): diff 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 checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:
B0every stimulus in the sample errored — cross-checks skipped
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).
Symbolic Derivative -- diff on an expression compiled at config load y = d^N f / d v^N evaluated at the input
The EXACT derivative of the expression, taken once when the configuration loads, not the finite difference Control_Systems/Continuous/Derivative takes of a signal in time: the variable differentiated against is one of the block's own variables, and the result is another expression of them.
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 diff on the same expression at the same points. Max |difference| 1.11e-16, which is rounding on the last bit rather than a tolerance.
Sample results#
No stimulus produced a sampled output in this rig — Invalid input size at Symbolic Derivative block: ICore Blocks/Home/Symbolic Derivative. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.
Category unsampled · 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
Sample data: docs/generated/samples/Control_Systems__Symbolic__Symbolic_Derivative.json