I’m a little confused about the use of the word “state” (not only in ModelingToolkit). In classic dynamic systems theory, the *state* is the minimum information necessary to describe current time of a dynamic system, so that the model evolution (with model parameters) is uniquely described when the *state* + *future inputs* are specified.

Macroscopic models based on balance laws can often be described by *semi-explicit DAEs* of form:

dx/dt = f(x,z,u;t)

0 = g(x,z,u;t)

Sometimes, an output is added:

y = h(x,z,u;t)

Here, the unknown variables are x and z (and possibly y), while u is a known input.

It may be convenient to classify “x” as a differential (or: differentiated?) variable, and z as an algebraic variable.

Some documentation (not only MTK) suggests that (x,z) is the state. But this is not so if we use the classic definition of “state” as the minimum necessary information.

In DAE literature, it is common to denote (x,z) as the *descriptor* of the system (my books are still in boxes after changing office…, so I can’t find references right now); alternatively, the *unknown variables*.

For examples of DAEs, see, e.g.,

- Brenan, Campbell, Petzold (1987). Numerical Solution of Initial-Value Problems in Differential-Algebraic Equations (see Amazon)
- Ascher, Petzold (1998). Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations, SIAM

Ascher and Petzold, in Example 9.7 gives a stylized model of a 2D pendulum, constrained to move on a circle:

q1’ = v1

q2’ = v2

v1’ = -L.q1

v2’ = -L.q2-g

0 = q1^2 + q2^2 - 1

where L(t) is unknown together with q1, q2 (positions) and v1, v2 (velocities). What is the state of this system? Is it the variables (q1, q2, v1, v2, L)? Or something else? The state should probably be the “differential variables” after index reduction.

Using MTK, the model is:

and function `structural_simplify`

leads to:

Inspecting the resulting simplified model from `structural_simplify`

, some equations must be missing. Yes, we can compute q1 when q2 is known (fourth equation, with an assumption of sign), but we cannot simultaneously compute q2_tt and L from the third equation. And what about v1? In Ascher and Petzold, they propose both:

0 = q1.v1 + q2.v2

-L = q2.g - v1^2 - v2^2

The first of these two additional equations gives us v1, while the second gives us L. Finally, we can compute q2_tt from the third equation provided by MTK.

Both of these additional equations are necessary, but `structural_simplify`

doesn’t spit them out.

In **summary**, it seems to be sufficient to specify initial values for q2 and v2, thus the system has 2 states - based on the classical definition of state from (dynamic) systems theory. It follows that the state is (q2,v2), or any invertible transformation of these two. With the key point being that the system has 2 states.

The original system had 5 unknown variables (q1,v1,q2,v2,L) [sometimes denoted the *descriptor*], but index reduction added a sixth unknown q2_tt.

**Summary** of *summary*: I’m not claiming that the classical definition of “state” in dynamic systems theory is the only valid definition. Maybe other fields use the concept of state differently? Most likely, many users of MTK (and SciML tools) will have a background in classical dynamic systems theory, so it might be useful to keep this in mind in documentation.

[And… am I doing something wrong wrt. `structural_simplify`

in that 2 equations appear to be missing?]