DynamicSystems
Linearize
construct a linear model of a system at a point
Calling Sequence
Parameters
Options
Description
Examples
Linearize( eqs, u, y, linpoint, opts)
eqs
-
equation, expression, or set or list of equations or expressions; equations to be linearized. An expression expr is interpreted as the equation 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
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 δ used when checking whether linpoint is an equilibrium point. If f⁡x0,u0≤δ then linpoint given by x0,u0 is considered to be an equilibrium point. If f consists of several components, the absolute value of each of them is tested. By default, δ=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.
The Linearize command computes the linearization of eqs about an operating point x0,u0 specified by linpoint. It is assumed that eqs can be reduced to the form
ⅆⅆtx⁡t=f⁡x⁡t,u⁡t
y⁡t=g⁡x⁡t,u⁡t
where:
x⁡t represents the state variables of eqs converted to the first-order form;
u⁡t represents the input variables specified by u;
y⁡t 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
ⅆⅆtx⁡t=a⁡x⁡t−x0+b⁡u⁡t−u0+f⁡x0,u0
y⁡t=c⁡x⁡t−x0+d⁡u⁡t−u0+g⁡x0,u0
where a=ⅆfⅆx, b=ⅆfⅆu, c=ⅆgⅆx, and d=ⅆgⅆu 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 ax⁡t, bu⁡t, cx⁡t, and du⁡t. If it does, the Linearize command checks whether the given point was an equilibrium point, f⁡x0,u0=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⁡t−xep, u⁡t−uep, y⁡t−g⁡xep,uep, where xep,uep 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.
with⁡DynamicSystems:
Example 1: Basic usage
sys1≔diff⁡x1⁡t,t=x2⁡t2−4,diff⁡x2⁡t,t=x1⁡t−1+u⁡t,y⁡t=x1⁡t+x2⁡t
sys1≔ⅆⅆtx1⁡t=x2⁡t2−4,ⅆⅆtx2⁡t=x1⁡t−1+u⁡t,y⁡t=x1⁡t+x2⁡t
eq_point1≔EquilibriumPoint⁡sys1,u⁡t,constraints=0<x1⁡t,initialpoint=u⁡t=0,x1⁡t=2,x2⁡t=4
eq_point1≔x1⁡t=1.49999999768708,x2⁡t=−2.00000001053627,ⅆⅆtx1⁡t=4.21450963017378×10−8,ⅆⅆtx2⁡t=−4.62584648364128×10−9,u⁡t=−0.500000002312923,y⁡t=−0.500000012849197
lin_point1≔op⁡eq_point11,op⁡eq_point13
lin_point1≔x1⁡t=1.49999999768708,x2⁡t=−2.00000001053627,u⁡t=−0.500000002312923
lin_model1a≔Linearize⁡sys1,u⁡t,y⁡t,lin_point1
lin_model1a≔State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable=u1⁡toutputvariable=y1⁡tstatevariable=x1⁡t,x2⁡t,x1⁡t=x1⁡t−1.499999998,x2⁡t=x2⁡t+2.000000011,u1⁡t=u⁡t+0.500000002312923,y1⁡t=y⁡t+0.5000000130
PrintSystem⁡lin_model1a1
State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable=u1⁡toutputvariable=y1⁡tstatevariable=x1⁡t,x2⁡ta=0−4000000021100000000010b=01c=11d=0
The linearization point lin_point does not give exact zero. Compute linear model for a tighter tolerance
lin_model1b≔Linearize⁡sys1,u⁡t,y⁡t,lin_point1,equilibriumtolerance=1.×10−10
lin_model1b≔Diff. Equationcontinuous1 output(s); 1 input(s)inputvariable=u1⁡toutputvariable=y1⁡t,x1⁡t=x1⁡t,x2⁡t=x2⁡t,u1⁡t=u⁡t,y1⁡t=y⁡t
PrintSystem⁡lin_model1b1
Diff. Equationcontinuous1 output(s); 1 input(s)inputvariable=u1⁡toutputvariable=y1⁡tde={[ⅆⅆtx1⁡t=−8.000000042−4.000000021⁢x2⁡t, ⅆⅆtx2⁡t=x1⁡t−1.+u1⁡t, y1⁡t=x1⁡t+x2⁡t]
Disable the checkpoint option for the same setting of the tolerance
lin_model1c≔Linearize⁡sys1,u⁡t,y⁡t,lin_point1,equilibriumtolerance=1.×10−10,checkpoint=false
lin_model1c≔State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable=u1⁡toutputvariable=y1⁡tstatevariable=x1⁡t,x2⁡t,x1⁡t=x1⁡t−1.499999998,x2⁡t=x2⁡t+2.,u1⁡t=u⁡t+0.499999998,y1⁡t=y⁡t+0.500000002
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 ];
sys2≔y⁡t−x1⁡t2+u⁡t⁢x1⁡t,x1⁡tx1⁡t<0x2⁡t+x1⁡t2otherwise⁢cos⁡y⁡tu⁡t<0sin⁡y⁡totherwise=sin⁡x1⁡t2+5⁢y⁡t+ⅆ2ⅆt2x1⁡t,ⅆⅆtx2⁡t=f⁡x1⁡t,u⁡t
user_function≔f,float,float,float,procx,ylocald1,d2;d1 ≔ cos⁡x+x^2;d2 ≔ y*d1+y^2;returnx*d1+d2*y − exp⁡d1end proc
eq_point2≔EquilibriumPoint⁡sys2,u⁡t,functions=user_function,initialpoint=x1⁡t=1,x2⁡t=1,u⁡t=1
eq_point2≔x1⁡t=0.853420831346895,x2⁡t=0.687832129312234,ⅆ2ⅆt2x1⁡t=2.43748043970982×10−9,ⅆⅆtx1⁡t=0.,ⅆⅆtx2⁡t=−1.14152598484907×10−9,u⁡t=1.07055911392119,y⁡t=−0.185310333631790
lin_point2≔op⁡eq_point21,op⁡eq_point23
lin_point2≔x1⁡t=0.853420831346895,x2⁡t=0.687832129312234,u⁡t=1.07055911392119
lin_model2a≔Linearize⁡sys2,u⁡t,y⁡t,lin_point2,functions=user_function
lin_model2a≔State Spacecontinuous1 output(s); 1 input(s); 3 state(s)inputvariable=u1⁡toutputvariable=y1⁡tstatevariable=x1⁡t,x2⁡t,x3⁡t,x1⁡t=x1⁡t−0.8534208313,x2⁡t=ⅆⅆtx1⁡t,x3⁡t=x2⁡t−0.6878321293,u1⁡t=u⁡t−1.07055911392119,y1⁡t=y⁡t+0.1853103334
PrintSystem⁡lin_model2a1
State Spacecontinuous1 output(s); 1 input(s); 3 state(s)inputvariable=u1⁡toutputvariable=y1⁡tstatevariable=x1⁡t,x2⁡t,x3⁡ta=010−874609832452496122517998136852480−331918107902983718014398509481984−207684934000000000b=06933778710027625225179981368524864053159171000000000c=2865561850933691450359962737049600d=−853420831310000000000
Example of the statevariable, inputvariable, and outputvariable options
lin_model2b≔Linearize⁡sys2,u⁡t,y⁡t,lin_point2,functions=user_function,statevariable=XX,inputvariable=UU,outputvariable=YY
lin_model2b≔State Spacecontinuous1 output(s); 1 input(s); 3 state(s)inputvariable=UU1⁡toutputvariable=YY1⁡tstatevariable=XX1⁡t,XX2⁡t,XX3⁡t,XX1⁡t=x1⁡t−0.8534208313,XX2⁡t=ⅆⅆtx1⁡t,XX3⁡t=x2⁡t−0.6878321293,UU1⁡t=u⁡t−1.07055911392119,YY1⁡t=y⁡t+0.1853103334
PrintSystem⁡lin_model2b1
State Spacecontinuous1 output(s); 1 input(s); 3 state(s)inputvariable=UU1⁡toutputvariable=YY1⁡tstatevariable=XX1⁡t,XX2⁡t,XX3⁡ta=010−874609832452496122517998136852480−331918107902983718014398509481984−207684934000000000b=06933778710027625225179981368524864053159171000000000c=2865561850933691450359962737049600d=−853420831310000000000
Example 3: Inverted pendulum on a moving cart
Variables
θ⁡t
counter-clockwise angular displacement of the pendulum from the upright position
φ⁡t
angular velocity of the pendulum, φ⁡t=ⅆⅆtθ⁡t
x⁡t
position of the cart
y⁡t
velocity of the cart, y⁡t=ⅆⅆtx⁡t
u⁡t
horizontal force applied to the cart
L
half-length of pendulum
m
mass of the pendulum
M
mass of the cart
g
gravitational constant (9.8 ms2)
sys3≔diff⁡x⁡t,t=y⁡t,diff⁡θ⁡t,t=φ⁡t,diff⁡y⁡t,t=−−3⁢cos⁡θ⁡t⁢sin⁡θ⁡t⁢g−2⁢u⁡t+2⁢m⁢L⁢sin⁡θ⁡t⁢φ⁡t2−3⁢cos⁡θ⁡t⁢m+2⁢M+2⁢m,diff⁡φ⁡t,t=−3⁢−sin⁡θ⁡t⁢g⁢M−sin⁡θ⁡t⁢g⁢m−m⁢u⁡t+m2⁢L⁢sin⁡θ⁡t⁢φ⁡t2−3⁢cos⁡θ⁡t⁢m+2⁢M+2⁢m⁢m⁢L
sys3≔ⅆⅆtx⁡t=y⁡t,ⅆⅆtθ⁡t=φ⁡t,ⅆⅆty⁡t=−−3⁢cos⁡θ⁡t⁢sin⁡θ⁡t⁢g−2⁢u⁡t+2⁢m⁢L⁢sin⁡θ⁡t⁢φ⁡t2−3⁢cos⁡θ⁡t⁢m+2⁢M+2⁢m,ⅆⅆtφ⁡t=−3⁢−sin⁡θ⁡t⁢g⁢M−sin⁡θ⁡t⁢g⁢m−m⁢u⁡t+m2⁢L⁢sin⁡θ⁡t⁢φ⁡t2−3⁢cos⁡θ⁡t⁢m+2⁢M+2⁢m⁢m⁢L
Linearization point is given by:
lin_point3≔φ⁡t=0,x⁡t=0,y⁡t=0,θ⁡t=0,u⁡t=0
lin_model3≔Linearize⁡sys3,u⁡t,φ⁡t,x⁡t,y⁡t,θ⁡t,lin_point3
lin_model3≔State Spacecontinuous4 output(s); 1 input(s); 4 state(s)inputvariable=u1⁡toutputvariable=y1⁡t,y2⁡t,y3⁡t,y4⁡tstatevariable=x1⁡t,x2⁡t,x3⁡t,x4⁡t,x1⁡t=φ⁡t,x2⁡t=θ⁡t,x3⁡t=x⁡t,x4⁡t=y⁡t,u1⁡t=u⁡t,y1⁡t=φ⁡t,y2⁡t=θ⁡t,y3⁡t=x⁡t,y4⁡t=y⁡t
The state-space object given by lin_model3[1] can be used to construct a stabilizing controller using linear control theory.
PrintSystem⁡lin_model31
State Spacecontinuous4 output(s); 1 input(s); 4 state(s)inputvariable=u1⁡toutputvariable=y1⁡t,y2⁡t,y3⁡t,y4⁡tstatevariable=x1⁡t,x2⁡t,x3⁡t,x4⁡ta=03⁢M⁢g+g⁢m−m+2⁢M⁢m⁢L001000000103⁢g−m+2⁢M00b=3−m+2⁢M⁢L002−m+2⁢Mc=1000010000100001d=0000
See Also
DynamicSystems[AlgEquation]
DynamicSystems[DiffEquation]
DynamicSystems[EquilibriumPoint]
DynamicSystems[StateSpace]
Download Help Document