Integral

Shippingstateful
integral

Cumulative integration with running accumulator persistence

Signature

Inputs

  • signalSignalrequired

Outputs

  • resultSignal

Parameters

KeyTypeDefaultNotes
methodenumtrapezoidalone of: trapezoidal, rectangular
initial_valuefloat0.0

Description

Integral computes the running cumulative integral of its signal input with respect to time, . It emits one output sample per input sample, so result has the same length as signal; the value at each sample is the accumulated area up to and including that sample.

The node is stateful. Its IntegralState persists a running accumulator and the last sample across evaluation runs, so integration continues seamlessly when a signal is processed block-by-block or across simulation ticks. The initial_value parameter seeds the accumulator as the constant of integration , but only on the first run; on subsequent runs the persisted accumulator is used. The method parameter selects the numerical rule: trapezoidal (default, second-order accurate, averages successive samples) or rectangular (first-order left-hand sum).

Units are propagated by multiplying the input unit by seconds: integrating a signal in volts yields , a current in amperes yields ampere-seconds (charge). Measurement uncertainty accumulates through the weighted sums; because each output depends on the running accumulator, sigma grows monotonically along the window as independent per-sample contributions are added in quadrature.

Mathematics

Examples

Charge from current

Feed a current signal in amperes into integral with method = trapezoidal. The output is accumulated charge in (coulombs). A constant current over integrates to .

Seeding the constant of integration

To model a capacitor voltage starting at , set initial_value = 5.0 and integrate the (scaled) current. The first output block begins accumulating from ; later blocks resume from the persisted accumulator rather than re-seeding.

x = [1, 1, 1, 1]  dt = 1s  initial_value = 5
trapezoidal -> [5.5, 6.5, 7.5, 8.5]

Applications

  • Integrating acceleration to velocity and velocity to position in inertial navigation and motion analysis.
  • Computing accumulated charge from a measured current, or energy from instantaneous power ($\int P\,dt$).
  • Building the integral term of a PID controller from a running error signal.
  • Estimating total dose, flow volume, or accumulated exposure from a rate signal in scientific instrumentation.

Neat

Because the accumulator persists across runs, chaining two Integral nodes yields a true double integral ($\iint x\,dt^2$) with correct state continuity across blocks — no windowing artifacts at block boundaries.

Trapezoidal integration is exact for any piecewise-linear input, so a ramp signal is integrated with zero method error regardless of $\Delta t$.

Known issues

As a running accumulator, any DC offset or bias in the input integrates without bound (integrator drift); over long runs the accumulator, and its uncertainty, grow monotonically and can dominate the signal.

Rectangular (left-hand) integration is only first-order accurate and systematically lags the true integral for non-constant signals; prefer trapezoidal unless matching a specific discrete convention.

See also

integrationcumulativestatefulaccumulatortrapezoidalcalculus