Generated reference › Nonlinear Equation Solve — Control Systems/Symbolic
kind: generated#block#control-systems-symbolic

Nonlinear Equation Solve — Control Systems/Symbolic

f(x)=0 solve

Control_Systems/Symbolic/Nonlinear_Equation_Solve · 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.

Nonlinear Equation Solve

Control Systems / Symbolic

Solves f = 0 for one variable symbolically and evaluates the root on the input at every sample – MATLAB's solve:

f(x, p) = 0  →  x = r1(p), r2(p), …

The algebra is done once, when the configuration loads. What runs per sample is the closed-form root: no iteration, no start point and no tolerance anywhere in the emitted body, and every root at once rather than the one a search happened to reach.

The factory setting is x² + ax − 4 = 0, whose roots are (−a ± √(a²+16))/2. Its discriminant is a²+16, which is at least 16 for every real a – so the block out of the library never answers with a NaN, which is a property worth having in a worked example.

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. ⚠ The SOLVE variable's entry is not read by the result – solving eliminated it. It is still declared, because the equation that goes IN is written over it.
  • y – the roots: a column [k,1] with one entry per root, in the order the engine answers them, or [1,1] when there is exactly one. The count k is fixed by the configuration, not by the signal.

Parameters

  • Expression – the equation's left-hand side; it is set equal to zero. 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 must be a scalar.
  • Variables – the names of the input's entries, in order: x a. The solve variable and every parameter the roots depend on must all be here. 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.
  • Solve Variable – which of the declared Variables to solve for, by name. It must be one of them.
  • 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 root, printed as one inline expression with its constants folded to 17 significant digits, so a generated core solves nothing and has no start point to tune. The three HDL targets are simulation-only real arithmetic, quantized to Q16.16 only at the ports.

Simulink bridge

None (Support::None). solve 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

  • ⚠ It is NOT a replacement for Base Blocks / Algebraic Constraint, and neither is a replacement for it. That block solves the same shape NUMERICALLY, by relaxation, one step per sample: it takes any equation, needs a start point, and converges to one root. This block does the algebra once: it takes only equations the console can solve in closed form, needs no start point, and answers every root. Reach for the numerical one when the equation is arbitrary; for this one when the roots are wanted in closed form and the per-sample cost must be fixed.
  • ⚠ A COMPLEX root is a configuration error, not a NaN at run time. x²+1 has roots ±i, and the block refuses the configuration by name rather than answering something. No target in this tree carries a complex number.
  • ⚠ A real root can still go NaN at RUN time, and that is arithmetic rather than a defect: the roots of a quadratic carry a square root of the discriminant, and if the discriminant goes negative on some sample the root there is not real. Choose the parameters, or the equation, so it cannot – the factory setting's discriminant is a²+16 for exactly that reason.
  • ⚠ Not every equation can be solved in closed form, and the console says which it can: polynomials exactly, rational equations through their numerator, and equations an elementary function can be peeled off one side of. A parametric cubic or quartic is refused with that reason.
  • abs, sign and heaviside are accepted here, as they are on the family's other algebra blocks: nothing is differentiated.
  • 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/Nonlinear_Equation_Solve
familyControl_Systems/Symbolic
solver environment classICoreBlock_0_Control_Systems_1_Symbolic_2_Nonlinear_Equation_Solve
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Nonlinear_Equation_Solve/ICoreBlock_0_Control_Systems_1_Symbolic_2_Nonlinear_Equation_Solve.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Nonlinear_Equation_Solve/ICoreBlock_0_Control_Systems_1_Symbolic_2_Nonlinear_Equation_Solve.h
default size on canvas150 × 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
Expressionx^2 + a*x - 4—
Variablesx a—
Solve 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): solve 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:

  • B0 every 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).

Nonlinear Equation Solve -- solve(f == 0, x), done once at config load f(x, p) = 0 -> x = r_1(p), r_2(p), ...

The algebra runs ONCE, when the configuration loads; what each of the ten targets carries is the closed-form root, as one inline expression per root. There is no iteration, no start point and no tolerance in the emitted body, and the number of roots is fixed before the run starts -- which is what makes the output's shape knowable at config load, as this family's sizing contract requires.

⚠ IT OVERLAPS Control_Systems/Base_Blocks/Algebraic_Constraint AND THE DIFFERENCE IS THE WHOLE POINT. That block solves the same shape NUMERICALLY, by relaxation, one step per sample: it takes any equation, needs a start point, and converges to ONE root. This one does the algebra once and then evaluates: it takes only equations the console can solve in closed form, needs no start point, and answers EVERY root at once. Neither is a replacement for the other, and the description says so rather than implying this one is better.

⚠ THE ANSWER IS OVER THE OTHER VARIABLES -- the solve variable is eliminated -- so its entry of the input is not read by the result, exactly as a transform's source entry is not. It is still declared, because the equation that goes IN is written over it.

THREE REFUSALS, all of them the right answer and all of them measured:

  • a COMPLEX root -- solve(x^2 + 1) is [-1i; 1i] -- is refused by the family's reader,

because no target in this tree carries one;

  • an equation the console cannot solve in closed form (a parametric cubic or quartic, say)

is refused by the engine with its own reason, naming what it does handle;

  • a root outside the printable function set is refused the same way as anywhere else here.

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

Sample results#

No stimulus produced a sampled output in this rig — Invalid input size at Nonlinear Equation Solve block: ICore Blocks/Home/Nonlinear Equation Solve. 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 dafda1b92 · produced by docsSample --out <folder> --blocks Nonlinear_Equation_Solve --steps 60

Sample data: docs/generated/samples/Control_Systems__Symbolic__Nonlinear_Equation_Solve.json