Variable Types

Variables in pynamics may be grouped into different categories, and used for different things. We must be careful to talk about these different types of variables carefully, as they have vastly different meanings when it comes to how they are used and computed in pynamics

First is the concept of a variable as it is used in the context of Python programming. In python, any piece of data my be stored as a variable and used in subsequent computations. we will be careful when discussing programming variables to distinguish between them and the other types of variables.

When it comes to symbolic variables used in dynamic modeling, we can discuss several more kinds of variables. First are state variables. State variables are the variables which are used to define the dynamic state of the system. If used to describe the position or orientation of a system, we think of these variables as having smooth and continuous second derivatives. If state variables are used to describe velocities or angular velocities of a system, they must have a smooth and continuous derivative. State variables must be differentiable to at least describe the acceleration of a system. Why? Because $F=ma$, and these variables constitute the variables, that, when derivated, contain that $a$ information.

There are also constants. Constants, from the perspective of a dynamics simulation, never change their value. In your program, you may change them each time you run a new simulation. But in the simulation, they don’t change. they don’t have a derivative, or it is considered to be 0.

Sometimes it is useful to work with constants throughout the computation of dynamics, so that the resulting expressions have a general form. Take g, for example. We often use $g$ to represent 9.81 $\frac{m}{s^2}$, because writing and working with $g$ is simpler and easier when transferring it around on paper. The same is true for

Other times it is useful to work with constants in their literal form. A literal constant is a constant for which a numerical value is stored and used immediately. You can use a Python program variable, for example, to store “l=2”, which, when used in an expression, replaces on first use, and in all subsequent expressions which use it the program variable “l” for the value “2”. Why would it be useful? For starters, often the symbolic expressions which are generated by pynamics can be littered with layered and nested expressions consisiting of many repeated elements. Sometimes these expressions get unwieldy and slow to work with. In the cases that these complex expressions may contain symbolic constants which get computed near the end of a simulation, sometimes it is useful and even necessary to replace these constants with their literal values in order to collapse and simplify these nested expressions.

There are also general purpose sympy symbols. These may be used as scalar variables within expressions and must be replaced with either an explicit value or another pynamics variable such as a constant or differentiable