DynamicSystems - Maple Programming Help

Home : Support : Online Help : Science and Engineering : Dynamic Systems : Linearization : DynamicSystems/Linearize

DynamicSystems

 Linearize
 construct a linear model of a system at a point

 Calling Sequence Linearize( eqs, u, y, linpoint, opts)

Parameters

 eqs - equation, expression, or set or list of equations or expressions; equations to be linearized. An expression expr is interpreted as the equation $\mathrm{expr}=0$. u - list or set; input variables y - list or set; output variables linpoint - list(equation) or set(equation); point around which the linearization is performed opts - (optional) equation(s) of the form option = value; specify options for the Linearize command

Options

 • simplify = truefalse

Specifies whether the given equations need to be simplified to the explicit nonlinear form above (true) or the system is already in this form and this step can be omitted (false). The default is true.

 • functions = list of lists

The user-defined functions present in the system. Each function is described in a list of the form [name, input argument type list, output type, Maple function], where:

 – name is the name of the function used in eqs;
 – input argument type list is a list of valid types accepted by the function (currently, only functions with float arguments are supported);
 – output type is the type of the output returned by the function (currently, only single-float- and void-valued  functions are supported);
 – Maple function is a procedure defined in Maple, see Example 2 below.
 • outputoption = statespace or equation

Specifies whether the linearized system should be returned as a state-space system object (statespace) or as a differential or algebraic equation system object (equation). The default is statespace.

 • checkpoint = truefalse

If outputoption = statespace, a check is performed as to whether the linearized system is fully represented by the state-space object. The checkpoint option disables this check (false), and the state-space object is returned in terms of the original variables. By default, the check is always performed, checkpoint = true.

 • equilibriumtolerance = positive

Specifies the value of $\mathrm{\delta }$ used when checking whether linpoint is an equilibrium point. If $\left|f\left({x}_{0},{u}_{0}\right)\right|\le \mathrm{\delta }$ then linpoint given by $\left({x}_{0},{u}_{0}\right)$ is considered to be an equilibrium point. If $f$ consists of several components, the absolute value of each of them is tested. By default, $\mathrm{\delta }=1.{10}^{-7}$.

 • inputvariable = name

Base name of the input variables of the generated DynamicSystems object. The default value is specified by DynamicSystems[SystemOptions].

 • outputvariable = name

Base name of the output variables of the generated DynamicSystems object. The default value is specified by DynamicSystems[SystemOptions].

 • statevariable = name

Base name of the state variables of the generated DynamicSystems object. The default is specified by DynamicSystems[SystemOptions].

 • lintime = numeric

Specifies the time at which the system is linearized. This value is needed for time-varying systems and for piecewise functions with conditions depending on time. The default value is 0.

Description

 • The Linearize command computes the linearization of eqs about an operating point $\left({x}_{0},{u}_{0}\right)$ specified by linpoint. It is assumed that eqs can be reduced to the form

$\frac{ⅆ}{ⅆt}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}x\left(t\right)=f\left(x\left(t\right),u\left(t\right)\right)$

$y\left(t\right)=g\left(x\left(t\right),u\left(t\right)\right)$

where:

$x\left(t\right)$ represents the state variables of eqs converted to the first-order form;

$u\left(t\right)$ represents the input variables specified by u;

$y\left(t\right)$ represents the output variables specified by y;

$f$ and $g$ are nonlinear functions to be linearized;

t is a continuous time variable as specified by the continuoustimevar option in DynamicSystems[SystemOptions].

The Linearize command simplifies eqs to the above form and computes the following linear model

$\frac{ⅆ}{ⅆt}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}x\left(t\right)=a\left(x\left(t\right)-{x}_{0}\right)+b\left(u\left(t\right)-{u}_{0}\right)+f\left({x}_{0},{u}_{0}\right)$

$y\left(t\right)=c\left(x\left(t\right)-{x}_{0}\right)+d\left(u\left(t\right)-{u}_{0}\right)+g\left({x}_{0},{u}_{0}\right)$

where $a=\frac{\partial }{\partial x}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}f$, $b=\frac{\partial }{\partial u}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}f$, $c=\frac{\partial }{\partial x}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}g$, and $d=\frac{\partial }{\partial u}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}g$ are the Jacobian matrices evaluated at linpoint.

 • The u parameter is a list or set of the input variables. Each element of u must be a function of t, where t corresponds to the independent time variable set by the continuoustimevar option to DynamicSystems[SystemOptions].
 • The y parameter is a list or set of the output variables. Each element of y must be a function of t, where t corresponds to the independent time variable set by the continuoustimevar option to DynamicSystems[SystemOptions].
 • The output of the Linearize command consists of a DynamicSystems object and three lists. The lists provide a mapping between the state, input, and output variables of the object and the state, input, and output variables of the original equations, respectively.
 • The DynamicSystems object represents the linearized system and is a state-space system object or as a  differential or algebraic equation system object.
 The state-space form does not always represent the linearized system fully, since it includes only $a$, $b$, $c$, and $d$ matrices. The Linearize command performs a check to determine whether the linear model has any terms in addition to $\mathrm{ax}\left(t\right)$, $\mathrm{bu}\left(t\right)$, $\mathrm{cx}\left(t\right)$, and $\mathrm{du}\left(t\right)$. If it does, the Linearize command checks whether the given point was an equilibrium point, $f\left({x}_{0},{u}_{0}\right)=0$. If not, the Linearize command tries to find an equilibrium point for the linear model. If there is an equilibrium point (whether it is the linearization point or a newly found equilibrium point), the shift transformation is performed, and the variables used in the DynamicSystems object are the variables in eqs shifted by the equilibrium point: $x\left(t\right)-{x}_{\mathrm{ep}}$, $u\left(t\right)-{u}_{\mathrm{ep}}$, $y\left(t\right)-g\left({x}_{\mathrm{ep}},{u}_{\mathrm{ep}}\right)$, where $\left({x}_{\mathrm{ep}},{u}_{\mathrm{ep}}\right)$ is an equilibrium point. If there are free terms and no equilibrium point can be found, the linearized equations are returned as a differential equation object. The effect of the check can be disabled using the checkpoint option.
 • The given nonlinear equations eqs and the linearization point linpoint may contain symbolic parameters. Note, however, that if there are symbolic parameters present in eqs or linpoint and there are user-defined functions specified by the functions option, the linearization will likely fail.

Examples

 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$

Example 1: Basic usage

 > $\mathrm{sys1}≔\left[\frac{ⅆ}{ⅆt}{x}_{1}\left(t\right)={{x}_{2}\left(t\right)}^{2}-4,\frac{ⅆ}{ⅆt}{x}_{2}\left(t\right)={x}_{1}\left(t\right)-1+u\left(t\right),y\left(t\right)={x}_{1}\left(t\right)+{x}_{2}\left(t\right)\right]$
 ${\mathrm{sys1}}{≔}\left[\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){=}{{{x}}_{{2}}{}\left({t}\right)}^{{2}}{-}{4}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{2}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){-}{1}{+}{u}{}\left({t}\right){,}{y}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){+}{{x}}_{{2}}{}\left({t}\right)\right]$ (1)
 > $\mathrm{eq_point1}≔\mathrm{EquilibriumPoint}\left(\mathrm{sys1},\left[u\left(t\right)\right],\mathrm{constraints}=\left[0<{x}_{1}\left(t\right)\right],\mathrm{initialpoint}=\left[u\left(t\right)=0,{x}_{1}\left(t\right)=2,{x}_{2}\left(t\right)=4\right]\right)$
 ${\mathrm{eq_point1}}{≔}\left[{{x}}_{{1}}{}\left({t}\right){=}{1.49999999768708}{,}{{x}}_{{2}}{}\left({t}\right){=}{-2.00000001053627}\right]{,}\left[\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){=}{4.21450963017378}{}{{10}}^{{-8}}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{2}}{}\left({t}\right){=}{-4.62584648364128}{}{{10}}^{{-9}}\right]{,}\left[{u}{}\left({t}\right){=}{-0.500000002312923}\right]{,}\left[{y}{}\left({t}\right){=}{-0.500000012849197}\right]$ (2)
 > $\mathrm{lin_point1}≔\left[\mathrm{op}\left({\mathrm{eq_point1}}_{1}\right),\mathrm{op}\left({\mathrm{eq_point1}}_{3}\right)\right]$
 ${\mathrm{lin_point1}}{≔}\left[{{x}}_{{1}}{}\left({t}\right){=}{1.49999999768708}{,}{{x}}_{{2}}{}\left({t}\right){=}{-2.00000001053627}{,}{u}{}\left({t}\right){=}{-0.500000002312923}\right]$ (3)
 > $\mathrm{lin_model1a}≔\mathrm{Linearize}\left(\mathrm{sys1},\left[u\left(t\right)\right],\left[y\left(t\right)\right],\mathrm{lin_point1}\right)$
 ${\mathrm{lin_model1a}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right)\right]\end{array}\right{,}\left[{{x}}_{{1}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){-}{1.499999998}{,}{{x}}_{{2}}{}\left({t}\right){=}{{x}}_{{2}}{}\left({t}\right){+}{2.000000011}\right]{,}\left[{{u}}_{{1}}{}\left({t}\right){=}{u}{}\left({t}\right){+}{0.500000002312923}\right]{,}\left[{{y}}_{{1}}{}\left({t}\right){=}{y}{}\left({t}\right){+}{0.5000000130}\right]$ (4)
 > $\mathrm{PrintSystem}\left({\mathrm{lin_model1a}}_{1}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cc}{0}& {-}\frac{{4000000021}}{{1000000000}}\\ {1}& {0}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}{0}\\ {1}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cc}{1}& {1}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{0}\end{array}\right]\end{array}\right$ (5)

The linearization point $\mathrm{lin_point}$ does not give exact zero. Compute linear model for a tighter tolerance

 > $\mathrm{lin_model1b}≔\mathrm{Linearize}\left(\mathrm{sys1},\left[u\left(t\right)\right],\left[y\left(t\right)\right],\mathrm{lin_point1},'\mathrm{equilibriumtolerance}'=1.{10}^{-10}\right)$
 Warning, linpoint is not an equilibrium point
 ${\mathrm{lin_model1b}}{≔}\left[\begin{array}{c}{\mathbf{Diff. Equation}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\end{array}\right{,}\left[{{x}}_{{1}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right){=}{{x}}_{{2}}{}\left({t}\right)\right]{,}\left[{{u}}_{{1}}{}\left({t}\right){=}{u}{}\left({t}\right)\right]{,}\left[{{y}}_{{1}}{}\left({t}\right){=}{y}{}\left({t}\right)\right]$ (6)
 > $\mathrm{PrintSystem}\left({\mathrm{lin_model1b}}_{1}\right)$
 $\left[\begin{array}{l}{\mathbf{Diff. Equation}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{de}}{=}{{}\begin{array}{l}{[}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){=}{-}{8.000000042}{-}{4.000000021}{}{{x}}_{{2}}{}\left({t}\right){,}\\ {}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{2}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){-}{1.}{+}{{u}}_{{1}}{}\left({t}\right){,}\\ {}{{y}}_{{1}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){+}{{x}}_{{2}}{}\left({t}\right){]}\end{array}\end{array}\right$ (7)

Disable the checkpoint option for the same setting of the tolerance

 > $\mathrm{lin_model1c}≔\mathrm{Linearize}\left(\mathrm{sys1},\left[u\left(t\right)\right],\left[y\left(t\right)\right],\mathrm{lin_point1},'\mathrm{equilibriumtolerance}'=1.{10}^{-10},'\mathrm{checkpoint}'=\mathrm{false}\right)$
 ${\mathrm{lin_model1c}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 2 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right)\right]\end{array}\right{,}\left[{{x}}_{{1}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){-}{1.499999998}{,}{{x}}_{{2}}{}\left({t}\right){=}{{x}}_{{2}}{}\left({t}\right){+}{2.}\right]{,}\left[{{u}}_{{1}}{}\left({t}\right){=}{u}{}\left({t}\right){+}{0.499999998}\right]{,}\left[{{y}}_{{1}}{}\left({t}\right){=}{y}{}\left({t}\right){+}{0.500000002}\right]$ (8)

Example 2: Use of user-defined functions

 > sys2 := {piecewise(x[1](t)<0, x[1](t), x[2](t) + x[1](t)^2) * piecewise(u(t)<0, cos(y(t)), sin(y(t))) = sin(x[1](t)^2) + 5 * y(t) + diff(x[1](t), t, t), y(t) - x[1](t)^2 + u(t)*x[1](t), diff(x[2](t), t) = f(x[1](t), u(t))}; user_function := [     f,     [float, float],     float,     proc(x, y)     local d1, d2;         d1 := cos(x)+x^2;         d2 := y*d1 + y^2;         return d1*x+d2*y- exp(d1);     end proc     ];
 ${\mathrm{sys2}}{≔}\left\{{y}{}\left({t}\right){-}{{{x}}_{{1}}{}\left({t}\right)}^{{2}}{+}{u}{}\left({t}\right){}{{x}}_{{1}}{}\left({t}\right){,}\left(\left\{\begin{array}{cc}{{x}}_{{1}}{}\left({t}\right)& {{x}}_{{1}}{}\left({t}\right){<}{0}\\ {{x}}_{{2}}{}\left({t}\right){+}{{{x}}_{{1}}{}\left({t}\right)}^{{2}}& {\mathrm{otherwise}}\end{array}\right\\right){}\left(\left\{\begin{array}{cc}{\mathrm{cos}}{}\left({y}{}\left({t}\right)\right)& {u}{}\left({t}\right){<}{0}\\ {\mathrm{sin}}{}\left({y}{}\left({t}\right)\right)& {\mathrm{otherwise}}\end{array}\right\\right){=}{\mathrm{sin}}{}\left({{{x}}_{{1}}{}\left({t}\right)}^{{2}}\right){+}{5}{}{y}{}\left({t}\right){+}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{2}}{}\left({t}\right){=}{f}{}\left({{x}}_{{1}}{}\left({t}\right){,}{u}{}\left({t}\right)\right)\right\}$
 ${\mathrm{user_function}}{≔}\left[{f}{,}\left[{\mathrm{float}}{,}{\mathrm{float}}\right]{,}{\mathrm{float}}{,}{\mathbf{proc}}\left({x}{,}{y}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{d1}}{,}{\mathrm{d2}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{d1}}{:=}{\mathrm{cos}}{}\left({x}\right){+}{x}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{d2}}{:=}{y}{*}{\mathrm{d1}}{+}{y}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{d1}}{*}{x}{+}{\mathrm{d2}}{*}{y}{-}{\mathrm{exp}}{}\left({\mathrm{d1}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}\right]$ (9)
 > $\mathrm{eq_point2}≔\mathrm{EquilibriumPoint}\left(\mathrm{sys2},\left[u\left(t\right)\right],\mathrm{functions}=\left[\mathrm{user_function}\right],\mathrm{initialpoint}=\left[{x}_{1}\left(t\right)=1,{x}_{2}\left(t\right)=1,u\left(t\right)=1\right]\right)$
 ${\mathrm{eq_point2}}{≔}\left[{{x}}_{{1}}{}\left({t}\right){=}{0.853420831346895}{,}{{x}}_{{2}}{}\left({t}\right){=}{0.687832129312234}\right]{,}\left[\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){=}{2.43748043970982}{}{{10}}^{{-9}}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){=}{0.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{2}}{}\left({t}\right){=}{-1.14152598484907}{}{{10}}^{{-9}}\right]{,}\left[{u}{}\left({t}\right){=}{1.07055911392119}\right]{,}\left[{y}{}\left({t}\right){=}{-0.185310333631790}\right]$ (10)
 > $\mathrm{lin_point2}≔\left[\mathrm{op}\left({\mathrm{eq_point2}}_{1}\right),\mathrm{op}\left({\mathrm{eq_point2}}_{3}\right)\right]$
 ${\mathrm{lin_point2}}{≔}\left[{{x}}_{{1}}{}\left({t}\right){=}{0.853420831346895}{,}{{x}}_{{2}}{}\left({t}\right){=}{0.687832129312234}{,}{u}{}\left({t}\right){=}{1.07055911392119}\right]$ (11)
 > $\mathrm{lin_model2a}≔\mathrm{Linearize}\left(\mathrm{sys2},\left[u\left(t\right)\right],\left[y\left(t\right)\right],\mathrm{lin_point2},\mathrm{functions}=\left[\mathrm{user_function}\right]\right)$
 ${\mathrm{lin_model2a}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 3 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right){,}{{x}}_{{3}}{}\left({t}\right)\right]\end{array}\right{,}\left[{{x}}_{{1}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){-}{0.8534208313}{,}{{x}}_{{2}}{}\left({t}\right){=}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{3}}{}\left({t}\right){=}{{x}}_{{2}}{}\left({t}\right){-}{0.6878321293}\right]{,}\left[{{u}}_{{1}}{}\left({t}\right){=}{u}{}\left({t}\right){-}{1.07055911392119}\right]{,}\left[{{y}}_{{1}}{}\left({t}\right){=}{y}{}\left({t}\right){+}{0.1853103334}\right]$ (12)
 > $\mathrm{PrintSystem}\left({\mathrm{lin_model2a}}_{1}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 3 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right){,}{{x}}_{{3}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{ccc}{0}& {1}& {0}\\ {-}\frac{{8746098324524961}}{{2251799813685248}}& {0}& {-}\frac{{6638362158059677}}{{36028797018963968}}\\ {-}\frac{{20768493}}{{40000000}}& {0}& {0}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}{0}\\ \frac{{3466889355013813}}{{1125899906842624}}\\ \frac{{6405315917}}{{1000000000}}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{ccc}\frac{{2865561850933691}}{{4503599627370496}}& {0}& {0}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{-}\frac{{8534208313}}{{10000000000}}\end{array}\right]\end{array}\right$ (13)

Example of the statevariable, inputvariable, and outputvariable options

 > $\mathrm{lin_model2b}≔\mathrm{Linearize}\left(\mathrm{sys2},\left[u\left(t\right)\right],\left[y\left(t\right)\right],\mathrm{lin_point2},\mathrm{functions}=\left[\mathrm{user_function}\right],\mathrm{statevariable}=\mathrm{XX},\mathrm{inputvariable}=\mathrm{UU},\mathrm{outputvariable}=\mathrm{YY}\right)$
 ${\mathrm{lin_model2b}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 3 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{\mathrm{UU}}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{\mathrm{YY}}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{\mathrm{XX}}}_{{1}}{}\left({t}\right){,}{{\mathrm{XX}}}_{{2}}{}\left({t}\right){,}{{\mathrm{XX}}}_{{3}}{}\left({t}\right)\right]\end{array}\right{,}\left[{{\mathrm{XX}}}_{{1}}{}\left({t}\right){=}{{x}}_{{1}}{}\left({t}\right){-}{0.8534208313}{,}{{\mathrm{XX}}}_{{2}}{}\left({t}\right){=}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{{x}}_{{1}}{}\left({t}\right){,}{{\mathrm{XX}}}_{{3}}{}\left({t}\right){=}{{x}}_{{2}}{}\left({t}\right){-}{0.6878321293}\right]{,}\left[{{\mathrm{UU}}}_{{1}}{}\left({t}\right){=}{u}{}\left({t}\right){-}{1.07055911392119}\right]{,}\left[{{\mathrm{YY}}}_{{1}}{}\left({t}\right){=}{y}{}\left({t}\right){+}{0.1853103334}\right]$ (14)
 > $\mathrm{PrintSystem}\left({\mathrm{lin_model2b}}_{1}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right); 3 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{\mathrm{UU}}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{\mathrm{YY}}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{\mathrm{XX}}}_{{1}}{}\left({t}\right){,}{{\mathrm{XX}}}_{{2}}{}\left({t}\right){,}{{\mathrm{XX}}}_{{3}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{ccc}{0}& {1}& {0}\\ {-}\frac{{8746098324524961}}{{2251799813685248}}& {0}& {-}\frac{{6638362158059677}}{{36028797018963968}}\\ {-}\frac{{20768493}}{{40000000}}& {0}& {0}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}{0}\\ \frac{{3466889355013813}}{{1125899906842624}}\\ \frac{{6405315917}}{{1000000000}}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{ccc}\frac{{2865561850933691}}{{4503599627370496}}& {0}& {0}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{-}\frac{{8534208313}}{{10000000000}}\end{array}\right]\end{array}\right$ (15)

Example 3: Inverted pendulum on a moving cart

Variables

 $\mathrm{\theta }\left(t\right)$ counter-clockwise angular displacement of the pendulum from the upright position $\mathrm{\phi }\left(t\right)$ angular velocity of the pendulum, $\mathrm{\phi }\left(t\right)=\frac{ⅆ}{ⅆt}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}\mathrm{\theta }\left(t\right)$ $x\left(t\right)$ position of the cart $y\left(t\right)$ velocity of the cart, $y\left(t\right)=\frac{ⅆ}{ⅆt}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}x\left(t\right)$ $u\left(t\right)$ horizontal force applied to the cart

Parameters

 $L$ half-length of pendulum $m$ mass of the pendulum $M$ mass of the cart $g$ gravitational constant (9.8 $\frac{m}{{s}^{2}}$)

 > $\mathrm{sys3}≔\left[\frac{ⅆ}{ⅆt}x\left(t\right)=y\left(t\right),\frac{ⅆ}{ⅆt}\mathrm{θ}\left(t\right)=\mathrm{φ}\left(t\right),\frac{ⅆ}{ⅆt}y\left(t\right)=-\frac{-3\mathrm{cos}\left(\mathrm{θ}\left(t\right)\right)\mathrm{sin}\left(\mathrm{θ}\left(t\right)\right)g-2u\left(t\right)+2mL\mathrm{sin}\left(\mathrm{θ}\left(t\right)\right){\mathrm{φ}\left(t\right)}^{2}}{-3\mathrm{cos}\left(\mathrm{θ}\left(t\right)\right)m+2M+2m},\frac{ⅆ}{ⅆt}\mathrm{φ}\left(t\right)=-\frac{3\left(-\mathrm{sin}\left(\mathrm{θ}\left(t\right)\right)gM-\mathrm{sin}\left(\mathrm{θ}\left(t\right)\right)gm-mu\left(t\right)+{m}^{2}L\mathrm{sin}\left(\mathrm{θ}\left(t\right)\right){\mathrm{φ}\left(t\right)}^{2}\right)}{\left(-3\mathrm{cos}\left(\mathrm{θ}\left(t\right)\right)m+2M+2m\right)mL}\right]$
 ${\mathrm{sys3}}{≔}\left[\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{y}{}\left({t}\right){,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{\theta }}{}\left({t}\right){=}{\mathrm{\phi }}{}\left({t}\right){,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{-}\frac{{-}{3}{}{\mathrm{cos}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{\mathrm{sin}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{g}{-}{2}{}{u}{}\left({t}\right){+}{2}{}{m}{}{L}{}{\mathrm{sin}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{{\mathrm{\phi }}{}\left({t}\right)}^{{2}}}{{-}{3}{}{\mathrm{cos}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{m}{+}{2}{}{M}{+}{2}{}{m}}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{\phi }}{}\left({t}\right){=}{-}\frac{{3}{}\left({-}{\mathrm{sin}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{g}{}{M}{-}{\mathrm{sin}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{g}{}{m}{-}{m}{}{u}{}\left({t}\right){+}{{m}}^{{2}}{}{L}{}{\mathrm{sin}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{{\mathrm{\phi }}{}\left({t}\right)}^{{2}}\right)}{\left({-}{3}{}{\mathrm{cos}}{}\left({\mathrm{\theta }}{}\left({t}\right)\right){}{m}{+}{2}{}{M}{+}{2}{}{m}\right){}{m}{}{L}}\right]$ (16)

Linearization point is given by:

 > $\mathrm{lin_point3}≔\left[\mathrm{φ}\left(t\right)=0,x\left(t\right)=0,y\left(t\right)=0,\mathrm{θ}\left(t\right)=0,u\left(t\right)=0\right]$
 ${\mathrm{lin_point3}}{≔}\left[{\mathrm{\phi }}{}\left({t}\right){=}{0}{,}{x}{}\left({t}\right){=}{0}{,}{y}{}\left({t}\right){=}{0}{,}{\mathrm{\theta }}{}\left({t}\right){=}{0}{,}{u}{}\left({t}\right){=}{0}\right]$ (17)
 > $\mathrm{lin_model3}≔\mathrm{Linearize}\left(\mathrm{sys3},\left[u\left(t\right)\right],\left[\mathrm{φ}\left(t\right),x\left(t\right),y\left(t\right),\mathrm{θ}\left(t\right)\right],\mathrm{lin_point3}\right)$
 ${\mathrm{lin_model3}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{4 output\left(s\right); 1 input\left(s\right); 4 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right){,}{{y}}_{{2}}{}\left({t}\right){,}{{y}}_{{3}}{}\left({t}\right){,}{{y}}_{{4}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right){,}{{x}}_{{3}}{}\left({t}\right){,}{{x}}_{{4}}{}\left({t}\right)\right]\end{array}\right{,}\left[{{x}}_{{1}}{}\left({t}\right){=}{\mathrm{\phi }}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right){=}{\mathrm{\theta }}{}\left({t}\right){,}{{x}}_{{3}}{}\left({t}\right){=}{x}{}\left({t}\right){,}{{x}}_{{4}}{}\left({t}\right){=}{y}{}\left({t}\right)\right]{,}\left[{{u}}_{{1}}{}\left({t}\right){=}{u}{}\left({t}\right)\right]{,}\left[{{y}}_{{1}}{}\left({t}\right){=}{\mathrm{\phi }}{}\left({t}\right){,}{{y}}_{{2}}{}\left({t}\right){=}{\mathrm{\theta }}{}\left({t}\right){,}{{y}}_{{3}}{}\left({t}\right){=}{x}{}\left({t}\right){,}{{y}}_{{4}}{}\left({t}\right){=}{y}{}\left({t}\right)\right]$ (18)

The state-space object given by lin_model3[1] can be used to construct a stabilizing controller using linear control theory.

 > $\mathrm{PrintSystem}\left({\mathrm{lin_model3}}_{1}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{4 output\left(s\right); 1 input\left(s\right); 4 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{{u}}_{{1}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{{y}}_{{1}}{}\left({t}\right){,}{{y}}_{{2}}{}\left({t}\right){,}{{y}}_{{3}}{}\left({t}\right){,}{{y}}_{{4}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{{x}}_{{1}}{}\left({t}\right){,}{{x}}_{{2}}{}\left({t}\right){,}{{x}}_{{3}}{}\left({t}\right){,}{{x}}_{{4}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cccc}{0}& \frac{{3}{}\left({g}{}{M}{+}{g}{}{m}\right)}{\left({-}{m}{+}{2}{}{M}\right){}{m}{}{L}}& {0}& {0}\\ {1}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}\\ {0}& \frac{{3}{}{g}}{{-}{m}{+}{2}{}{M}}& {0}& {0}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{c}\frac{{3}}{\left({-}{m}{+}{2}{}{M}\right){}{L}}\\ {0}\\ {0}\\ \frac{{2}}{{-}{m}{+}{2}{}{M}}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cccc}{1}& {0}& {0}& {0}\\ {0}& {1}& {0}& {0}\\ {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {1}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{c}{0}\\ {0}\\ {0}\\ {0}\end{array}\right]\end{array}\right$ (19)