Systems Analysis and Control
Matthew M. Peet
Arizona State University
Lecture 3: Linearization
Introduction
In this Lecture, you will learn:
How to Linearize a Nonlinear System System.
• Taylor Series Expansion
• Derivatives
• L’hoptial’s rule
• Multiple Inputs/ Multiple States
M. Peet Lecture 3: Control Systems 2 / 22
Lets Start with an Example
A Simple Pendulum
Consider the rotational dynamics of a pendulum:
• The input is a motor-driven moment, T (t).
• The output is the angle, θ(t).
• The moment of inertia about the pivot point is J.
• The force of gravity, M g acts on the center of mass.
I Force creates a moment about the pivot (See Figure b)):
l
N (t) = −M g sin θ(t) ·
2
M. Peet Lecture 3: Control Systems 3 / 22
A Simple Pendulum
The governing equation is Newton’s law:
N (t)
θ̈(t) = + T (t)
J
Equations of Motion (EOM): First-order form: Let x1 (t) = θ(t),
x2 (t) = θ̇(t).
M gl T (t) ẋ1 (t) = x2 (t)
θ̈(t) = − sin θ(t) +
2J J
M gl T (t)
y(t) = θ(t) ẋ2 (t) = − sin x1 (t) +
2J J
y(t) = x1 (t)
M. Peet Lecture 3: Control Systems 4 / 22
A Simple Pendulum
The Problem
First-order form:
ẋ1 (t) = x2 (t)
M gl T (t)
ẋ2 (t) = − sin x1 (t) +
2J J
y(t) = x1 (t)
Although we have the system in first-order form, it cannot be put in state-space
because of the sin x1 term.
What to do???
Although sin x is nonlinear,
small sections look linear.
• Near x = 0: sin x ∼
=x
• Near x = π/2: sin x ∼
=1
• Near x = π: sin x ∼
=π−x
We must use these linear approximations very carefully !
M. Peet Lecture 3: Control Systems 5 / 22
Accuracy of the Small Angle Approximation
The approximation will only be accurate for a narrow band of x.
1 1.1
0.8 1
0.6 0.9
0.4 0.8
0.2 0.7
sin(x)
sin(x)
0 0.6
−0.2 0.5
−0.4 0.4
−0.6 0.3
−0.8 0.2
−1 0.1
−1 −0.5 0 0.5 1 0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.4
x x
π
Figure: sin(x) and x near x0 = 0 Figure: sin(x) and x near x0 = 2
0.2 0
0.15 −0.05
0.1 −0.1
0.05 −0.15
error
error
0 −0.2
−0.05 −0.25
−0.1 −0.3
−0.15 −0.35
−0.2 −0.4
−1 −0.5 0 0.5 1 0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.4
x x
π
Figure: Error near x = 0 Figure: Error near x = 2
• 80% Accuracy: x ∈ [−1.2, 1.2] • 80% Accuracy: x ∈ [.9, 2.2]
• 95% Accuracy: x ∈ [−.7, .7] • 95% Accuracy: x ∈ [1.25, 1.9]
M. Peet Lecture 3: Control Systems 6 / 22
Linear Approximation
We can use the tangent to approximate a nonlinear function near a point x0 .
Key Point: The approximation is tangent to the function at the point x0 .
∼ ax + b
f (x) =
• The slope is given by
d
a= f (x)|x=x0
dx
• The y-intercept is given by
b = f (x0 ) − ax0
The linear approximation is given by
d
f (x) ∼
= f (x0 ) + f (x)|x=x0 (x − x0 )
dx
M. Peet Lecture 3: Control Systems 7 / 22
A General Method For Linear Approximation
Problem: Approximate the scalar function f (x) near the point x0 using
y(x) = ax + b
The Linear Approximation is given by
d
y(x) = f (x0 ) + f (x)|x=x0 (x − x0 )
dx
M. Peet Lecture 3: Control Systems 8 / 22
Linear Approximation
Note: The Linear Approximation is just the first two terms in the Taylor Series
representation.
d (x − x0 ) d (x − x0 )2
f (x) = f (x0 ) + f (x)|x=x0 + f (x)|x=x0 + ···
dx 1! dx 2!
M. Peet Lecture 3: Control Systems 9 / 22
Example: Pendulum
Return to the dynamics of a pendulum:
ẋ1 (t) = x2 (t)
M gl 1
ẋ2 (t) = − sin x1 (t) + T (t)
2J J
y(t) = x1 (t)
The nonlinear term is sin x1
• We want to linearize sin x1 .
• Choose an operating point, x0 !
I Depends on what we want to do!
I Options are limited.
Hanging Pendulum: x0 = 0
Inverted Pendulum: x0 = π
Tracking: x0 =???
M. Peet Lecture 3: Control Systems 10 / 22
Example: Balance an Inverted Pendulum
For the inverted pendulum: f (x) = sin x and
x0 = π.
• Slope:
d
a= f (x)|x=x0 = cos(π) = −1 3.5
dx 3
2.5
• f (x0 ) = f (π) = sin(π) = 0 2
1.5
sin(x)
• Thus (for x ∼
= π) 1
0.5
sin(x) ∼
= f (x0 ) + a(x − x0 ) = 0 − 1(x − π) 0
−0.5
=π−x −1
−1 0 1 2 3 4 5
x
This gives the first-order dynamics:
New Problem: How to
ẋ1 (t) = x2 (t)
eliminate the constant term
M gl M gl 1
ẋ2 (t) = x1 (t) − π + T (t) M gl
2J 2J J − π
2J
| {z }
Trouble
y(t) = x1 (t)
M. Peet Lecture 3: Control Systems 11 / 22
Solution: Measure Displacement from Equilibrium
Define the state variable as Displacement from Equilibrium
Definition 1.
x0 is an Equilibrium Point of ẋ = f (x) if f (x0 ) = 0. (Then ẋ = f (x0 ) = 0)
• Nonlinear systems may have many equilibrium points.
• Linear systems only have one equilibrium point (x0 = 0).
M. Peet Lecture 3: Control Systems 12 / 22
A Change of Variables
Consider distance from equilibrium ∆x = x − x0
The pendulum has infinite equilibria.
• Down equilibria: θ0 = 0 + 2πn for n = 1, · · · , ∞
• Up equilibria: θ0 = π + 2πn for n = 1, · · · , ∞
T
Lets choose θ0 = π i.e. x0 = π 0 :
M gl
ẋ1 (t) = x2 (t), ẋ2 (t) = (x1 (t) − π)
2J
Problem: Translate the equilibrium to ∆x0 = 0.
Solution: Define a new variable ∆x = x − x0
(∆x1 = x1 − π, ∆x2 = x2 )
• Then
∆ẋ1 (t) = ẋ1 (t) = x2 (t) = ∆x2 (t)
M gl M gl
∆ẋ2 (t) = ẋ2 (t) = (x1 (t) − π) = ∆x1 (t)
2J 2J
• Thus ∆x0 = 0 is the equilibrium!!!
M. Peet Lecture 3: Control Systems 13 / 22
Measuring Displacement from Equilibrium
Pendulum Example
Summary:
• Linearize about equilibrium
x1 = π, x2 = 0. This yields
ẋ1 (t) = x2 (t)
M gl 1
ẋ2 (t) = (x1 (t) − π) + T (t)
2J J
• Define new states as displacement
from equilibrium:
∆x1 (t) = x1 (t) − π
∆x2 (t) = x2 (t)
• Get the new dynamics:
M gl 1
∆ẋ1 (t) = ∆x2 (t) ∆ẋ2 (t) = ∆x1 (t) + T (t)
2J J
∆x1 is angle from the vertical.
M. Peet Lecture 3: Control Systems 14 / 22
Measuring Displacement from Equilibrium
Pendulum Example
Now we are ready for state-space.
New Dynamics:
∆ẋ1 (t) = ∆x2 (t)
M gl 1
∆ẋ2 (t) = ∆x1 (t) + T (t)
2J J
State-Space Form:
0 1 0
∆ẋ(t) = M gl ∆x(t) + 1 T (t)
2J 0 J
y(t) = 1 0 ∆x(t)
01 0
A = M gl B= 1
2J 0 J
C= 1 0 D= 0
M. Peet Lecture 3: Control Systems 15 / 22
Example: Balance an Inverted Pendulum
Applications: Walking robots.
M. Peet Lecture 3: Control Systems 16 / 22
Example: Balance an Inverted Pendulum
Applications: Segway.
M. Peet Lecture 3: Control Systems 17 / 22
Numerical Example: Using l’Hôpital’s rule
Occasionally you will encounter a 0.8
system such as 0.6
sin2 (x(t))
0.4
ẍ(t) = −ẋ(t) + 0.2
x(t)
sin(x)2/x
0
−0.2
where you want to linearize about the
−0.4
zero equilibrium.
−0.6
−0.8
−6 −4 −2 0 2 4 6
x
sin2 x
The nonlinear term is with equilibrium point x0 = 0.
x
Recall the formula:
f (x) ∼
= f (x0 ) + f 0 (x0 )(x − x0 )
Thus we must calculate f (x0 ) and f 0 (x0 ).
0
Lets start with f (x0 ). Initially, we see that f (0) = , which is indeterminate.
0
To help, we use L’hopital’s Rule.
M. Peet Lecture 3: Control Systems 18 / 22
L’hopital’s Rule
Theorem 2 (l’Hôpital’s Rule).
If g(0) = 0 and h(0) = 0, then
g(x) g 0 (x)
lim = lim 0
x→0 h(x) x→0 h (x)
sin2 x
Lets linearize f (x) = about x0 = 0. We need to find f (x0 ) and f 0 (x0 ).
x
g(x) g 0 (x)
z }| { z }| {
sin2 (x) 2 sin x cos x 0
f (0) = lim = lim = =0
x→0 x
|{z} x→0 1
|{z} 1
h(x) h0 (x)
which is as expected. Now, g(x)
z }| {
2 2
2 sin x cos x sin x 2x sin x cos x − sin x
f 0 (x) = − =
x x2 x2
|{z}
h(x)
So unfortunately, 0
0
f (0) =
0
M. Peet Lecture 3: Control Systems 19 / 22
Example Continued
So once more we apply L’hopital’s rule:
2 sin x cos x + 2x cos2 x − 2x sin2 x − 2 sin x cos x
f 0 (0) = lim f 0 (x) = lim
x→0 x→0 g 0 (x) 2x
z }| {
2x(cos2 x − sin2 x) 0
= lim =
x→0 2x
|{z} 0
h0 (x)
Ooops, we must apply l’Hôpital’s rule AGAIN:
g 00 (x)
z }| {
2x(cos2 x − sin2 x) 2(cos2 x − sin2 x) − 8x cos x sin x 2
lim = lim = =1
x→0 2x x→0 2
|{z} 2
h00 (x)
Which was a lot of work for such a simple answer (easier way?). We have the
linearized equation of motion:
ẍ(t) = −ẋ(t) + 0 + 1 · (x(t) − 0)
0 1
For state-space, let x1 = x, x2 = ẋ. Then ẋ(t) = x(t).
1 −1
M. Peet Lecture 3: Control Systems 20 / 22
Inverted Pendula Videos
Double Inverted Pendulum
Triple Inverted Pendulum
This is actually a switched controller!
1. Linearize about hanging position
1.1 Design Energy Maximizing Controller
1.2 Will cause pendulum to swing up.
2. Linearize about inverted position
2.1 Switch controllers when near inverted position
M. Peet Lecture 3: Control Systems 21 / 22
Summary
What have we learned today?
How to Linearize a Nonlinear System System.
• Taylor Series Expansion
• Derivatives
• L’hoptial’s rule
• Multiple Inputs/ Multiple States
Next Lecture: Laplace Transform
M. Peet Lecture 3: Control Systems 22 / 22