Advanced maths

Finite horizon reachability Gramian and minimum energy control calculator

Compute the finite-horizon reachability Gramian and the minimum squared-input energy needed to move a linear continuous-time system between specified states.

Your numbers

Finite real values; comma-separated columns and separate lines for matrix rows.
Finite real values; comma-separated columns and separate lines for matrix rows.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Compute the finite-horizon reachability Gramian and the minimum squared-input energy needed to move a linear continuous-time system between specified states. The calculation accounts for free evolution, resolves reachable directions numerically and samples the least-energy control. An unreachable target is rejected rather than replaced by an unexplained approximate transfer.

THE FORMULAd=x_target−exp(AT)x_initial; W=∫₀ᵀ exp(At)BBᵀexp(Aᵀt)dt; E_min=dᵀW⁺d for d in range(W). u*(t)=Bᵀexp(Aᵀ(T−t))W⁺d.

A worked example

The unit-horizon double integrator has A=[[0,1],[0,0]], B=[[0],[1]], initial[0,0] and target[1,0]. W=[[1/3,1/2],[1/2,1]], the least-energy control is u(t)=6−12t, and its energy integral is12. The resulting position3t²−2t³ reaches one with zero terminal velocity.

Good to know

Constant real A of order1–3, B with1–3 input columns and matching rows. Finite initial/target vectors, horizon0<T≤20, and matrix-time exponential norm≤80. Numerical adaptive quadrature and spectral pseudoinverse with relative/absolute rank thresholds. Eleven control samples; no input bounds, state constraints, state costs, nonlinear dynamics, robust uncertainty or exact reachability certificate near rank thresholds.

The terminal target is an equality constraint

The system is x′=Ax+Bu over a fixed horizon. The task is to reach the entered terminal state exactly in the mathematical model while minimizing the integral of uᵀu.

This differs from a quadratic controller that merely penalizes terminal error. Here a target outside the reachable subspace is not an expensive but admissible compromise: it is infeasible under the stated dynamics and input channels.

Finite horizon reachability Gramian and minimum energy control calculator worked exampleA least-energy transfer for the double integratorControl u = 6 − 12tEnergy ∫u²dt = 12Position and velocityPosition → 1Velocity → 0
Scroll across to see the full diagram.
The unit-horizon double integrator has A=[[0,1],[0,0]], B=[[0],[1]], initial[0,0] and target[1,0]. W=[[1/3,1/2],[1/2,1]], the least-energy control is u(t)=6−12t, and its energy integral is12. The resulting position3t²−2t³ reaches one with zero terminal velocity.

Compare this with the Finite horizon linear quadratic control calculator with terminal cost. LQR balances quadratic costs without imposing the same exact terminal-state requirement.

Subtract the free evolution first

With no control, the terminal state is exp(AT)x_initial. The displacement d is the desired target minus that free state, so control energy depends on the correction that the input must produce.

A target equal to the free terminal state requires zero energy even when it differs greatly from the initial state. Ignoring free evolution would incorrectly charge control effort for motion already generated by A.

The Gramian encodes controllable directions

The reachability Gramian sums how input directions propagate through the system over time. Its quadratic form measures how strongly a state direction can be influenced across the horizon.

A small eigenvalue indicates a direction that is expensive to reach. A numerically zero eigenvalue marks a direction omitted by the resolved reachable subspace. The page displays numerical rank and eigenvalues because energy alone would hide this geometry.

Deriving the double-integrator example

A scalar input changes velocity and velocity changes position. Over one time unit the propagated input column is[t,1]ᵀ, so integrating its outer product yields W11=1/3, W12=1/2 and W22=1.

Solving Wz=[1,0]ᵀ gives z=[12,−6]ᵀ. The optimal control Bᵀexp(Aᵀ(1−t))z becomes6−12t. Its squared integral is12, and integrating the dynamics yields the stated terminal position and velocity.

What a singular Gramian permits

A singular Gramian does not make every target impossible. Some displacements lie wholly within its range and have a well-defined minimum-energy control using a pseudoinverse on the positive eigenspace.

The routine checks the residual after projecting the displacement through that spectral solve. A displacement outside the resolved range is rejected. This is a numerical subspace test with tolerances, so almost-singular systems deserve scaling and sensitivity checks.

The displayed control is sampled

The formula defines a continuous-time control, but the output contains eleven evenly spaced samples to make its shape inspectable. Those samples are not an eleven-pulse approximation used to solve the energy problem.

Connecting them visually is appropriate for understanding a smooth profile, while replaying a piecewise-constant version in a physical system changes the trajectory. Accurate implementation requires evaluating or discretizing the continuous control with its own error analysis.

Energy depends on units and horizon

The objective is the squared Euclidean norm of the entered input channels integrated over time. Rescaling one input unit changes its implicit energy weighting, so comparing energies across different unit conventions can be misleading.

Increasing the available horizon can change both free evolution and controllability costs. The calculator uses no actuator limits, so a mathematically optimal transfer can require input magnitudes that a real device cannot supply.

A few questions, answered

Is this an LQR calculation?

No. It minimizes input energy subject to an exact terminal state, without state penalties.

Can a singular Gramian still reach my target?

Yes, if the target displacement lies in its resolved range.

Are the eleven controls piecewise constant?

No. They sample the continuous-time least-energy formula.

Does minimum energy obey actuator limits?

No. Input magnitude and state constraints are outside this calculation.

Find your calculator

Start typing to explore the library.