代写 python theory Homework 1

Homework 1
24-677 Special Topics: Linear Control Systems Prof. D. Zhao
Due: Sept 4, 2019, 8:30 am. Submit within deadline.
• Your online version and its timestamp will be used for assessment. The paper version, will only be used for backup purposes.
• We will use Gradescope ( https://www.gradescope.com/) to grade. The link is on the panel of CANVAS. If you are confused about the tool, post your questions on Piazza.
• At the start of every exercise you will see topic(s) on what the given question is about and what will you be learning.
• Submit the pdf of your written work to Canvas and Gradescope.
• You will need to upload 1. A python script and 2. The programming assignment
script, with this homework. 3. Output file
• The python script for submitting your theory homework answers will be given to you. The script is named ”hw1 answer template.py”. And you have to submit it with your answers. After filling out your answers, rename it to ”hw1 answer.py”. Refer to the further instructions given in the script for submission format.
• For the programming assignment, copy and paste, or export your answer script into a python file named ”hw1.py”. Follow the further instructions given in the jupyter notebook named ”PHW1 qs.ipynb” for information on submission format of your answers. The script should be executable and should provide the required output.
• In total there will be 4 files” to submit in Gradescope. Out of the 4, 3 that is the scripts and output file to be submitted in the Gradescope assignment named ”Programming Assignment 1”. And the last one will be the pdf/images of your written work. Submit to Gradescope assignment named ”Homework 1”. No submission in Canvas.
• We advise you to start with the assignment early. All the submissions are to be done before the respective deadlines of each assignment. For information about the late days and scale of your Final Grade, refer to the Syllabus in Canvas.
1

Exercise 1. Types of Systems
A system has an inputu(t) and an output y(t), which are related by the information pro-
vided below. Classify each system as a linear or non-linear and time invariant or time-varying.
1. y(t)=0forallt 2. y(t) = u3(t)
3. y(t) = u(3t)
4. y(t)=e−tu(t−T) 5. y(t)=u(t−1)
6. y(t)=􏰊t u(τ)dτ −∞
7. y(t)=􏰊t u2(τ)dτ −∞
􏰂0t≤0 8.y(t)= u(t) t>0
Solution:
1. y(t)=0forallt
y1(t) = 0 for u1(t) input y2(t) = 0 for u2(t) input y3(t) = α · 0 + β · 0 for input: αu1(t) + βu2(t)
Hence it is linear.
y(t + τ) = 0
output for u(t + τ ) = 0 Hence time invariant
2. y(t) = u3(t)
(a) Non-linear:
Consider with
u(t) = αu1(t) + βu2(t)
y1(t) = u31(t)
y2(t) = u31(t)
then the output y(t) corresponding to the input u(t) is
y(t) = u3(t)
= (αu1(t) + βu2(t))3
= α3u31(t) + β3u32(t) + 3α2βu21(t)u2(t) + 3αβ2u1(t)u2(t) ̸= αy1(t) + βy2(t)
2

(b) Time-Invariant:
3. y(t) = u(3t) (a) Linear:
Consider with
Dτ {u(t)} = u3(t − τ) (1) Dτ {y(t)} = u3(t − τ) (2) = Dτ {u(t)} (3)
u(3t) = αu1(3t) + βu2(3t) y1(t) = u1(3t)
y2(t) = u1(3t)
then the output y(t) corresponding to the input u(3t) is
(b) Time-Varying:
4. y(t)=e−tu(t−T) (a) Linear:
Consider with
y(t) = u(3t)
= αu1(3t) + βu2(3t) = αy1(t) + βy2(t)
Dτ {u(3t)} = u(3t − τ ) (1) Dτ {y(t)} = u(3(t − τ )) (2) = u(3t − 3τ)) (3) ̸= Dτ {u(t)} (4)
u(t − T) = αu1(t − T) + βu2(t − T) y1(t) = e−tu1(t − T)
y2(t) = e−tu2(t − T) then the output y(t) corresponding to the input is
y(t) = e−tu(t − T)
= e−t (αu1(t − T) + βu2(t − T)) = αy1(t) + βy2(t)
3

(b) Time Varying:
5. y(t)=u(t−1) (a) Linear:
Consider with
Dτ {e−tu(t)} = e−tu(t − τ − T ) (1) Dτ{y(t)}=e−(t−τ)u(t−τ −T) (2) ̸= Dτ {u(t)} (3)
u(t − 1) = αu1(t − 1) + βu2(t − 1) y1(t) = u1(t − 1)
y2(t) = u2(t − 1) then the output y(t) corresponding to the input is
(b) Time-Invariant:
6. y(t)=􏰊t u(τ)dτ −∞
(a) Linear: Consider
with
y(t) = u(t − 1)
= (αu1(t − 1) + βu2(t − 1)) = αy1(t) + βy2(t)
Dτ{u(t)}=u(t−τ−1) (1) Dτ{y(t)}=u(t−τ−1) (2) = Dτ {u(t)} (3)
u(t) = αu1(t) + βu2(t) 􏰋t
then the output y(t) corresponding to the input is 􏰋t
y1(t) = y2(t) =
−∞
􏰋t
−∞
u1(τ)dτ u2(τ)dτ
y(t) = =
= αy1(t) + βy2(t) 4
−∞
􏰋t −∞
u(τ)dτ
(αu1(t) + βu2(t)) dτ

(b) Time-Invariant:
7. y(t)=􏰊t −∞
u2(τ)dτ (a) Non-Linear:
8.y(t)=
t < 0 Consider with y(t) = = −∞ 􏰋t −∞ 􏰂 0, u(t) t≥0 DT {u(t)} = DT {y(t)} = 􏰋t −∞ then the output y(t) corresponding to the input is 􏰋t y1(t) = y2(t) = −∞ 􏰋t −∞ u21(τ)dτ u2(τ)dτ u(τ − T )dτ 􏰋 t−T u(τ)dτ (1) (2) (3) (4) u2(τ) (αu1(τ) + βu2(τ))2 dτ 􏰋t􏰋t􏰋t = α2 u21(τ)dτ + β2 u2(τ)dτ + 2αβ −∞ −∞ −∞ ̸= αy1(t) + βy2(t) (b) Time-Invariant: DT {u(t)} = DT {y(t)} = u2(τ − T)dτ (1) (2) (3) (4) −∞ τ′=τ+T 􏰋 t −→ u(τ′ −T)dτ′ = DT {u(t)} u(t) = αu1(t) + βu2(t) 􏰋t 􏰋t −∞ 􏰋 t−T −∞ τ′=τ+T 􏰋 t −→ 5 −∞ u2(τ)dτ u2 (τ ′ − T ) dτ ′ = DT {u(t)} −∞ u1(τ)u2(τ)dτ (a) Linear: Consider with u(t) = αu1(t) + βu2(t) (b) Time-Varying: 􏰂 0, t < τ Dτ{y(t)}= u(t−τ) t≥τ ̸= DT {u(t)} 􏰂 0, y1(t) = u1(t) 􏰂 0, y2(t) = u2(t) t < 0 t ≥ 0 t < 0 t ≥ 0 then the output y(t) corresponding to the input is 􏰂 0, t < 0 t < 0 t ≥ 0 = αy1(t) + βy2(t) t < 0 t ≥ 0 y(t)= u(t) t≥0  0 , αu1(t) + βu2(t) = = αy1(t) + βy2(t)  􏰂 0, Dτ {u(t)} = u(t − τ ) 6 Exercise 2. Fields Is this given set a field? 1. Is N∗ a field ? Where N∗ is set of all Natural numbers. 2. Is Q a field ? Where Q is set of all rational numbers. 3. Set of all polynomials 4. Set of rational functions with real coefficients. Solution: 1. N∗ is a set of all natural numbers without 0. As the set does not contain 0, an element’s additive inverse does not exists. Hence N∗ is not a Field. 2. Q is a set of all Rational numbers (p where p and q ∈ R). As the Q set satisfies all q the rules specified in slides M1-1 for a definition of a field. Hence Q is a Field. 3. The set of polynomials will not consist the multiplicative inverse of an element. Because, by definition of a polynomial, the only polynomial with a negative degree is 0. Hence is not a field 4. The set rational functions with real coefficients satisfies all the rules specified in slides M1-1 for a definition of a field. Hence is a field 7 Exercise 3. Subspace The set W of n × n matrices with real entries is known to be a linear vector space. Determine which of the following set are subspaces of W : 1. The set of n × n skew-symmetric matrices? 2. The set of n × n diagonal matrices? 3. The set of n × n upper-diagonal matrices? 4. The set of n × n singular matrices? Solution: For the given set to be a subspace, it should be a Vector space. Hence it should satisfy all conditions A0 - A4 and SM0 - SM4 as provided in M1 slide. 1. The nxn skew symmetric matrix is in a subspace of W. 2. The nxn diagonal matrix is in a subspace of W . 3. The nxn upper-diagonal matrix is in a subspace of W. 100 000 100 4.0 0 0+0 1 0=0 1 0whichisnonsingular, 000 001 001 The given set is not closed under addition. It violates the condition A0. Hence not a subspace. 8 Exercise 4. Linearization Perform linearization on the given differential equation y ̈+(1+y)y ̇−2y+0.5y3 =0 Solution: Let x = 􏰇x1 x2􏰈T , also x1 = y and x2 = y ̇ gives the state variable model 􏰀x ̇1􏰁 􏰀 x2 􏰁 x ̇ =2x−0.5x3−(1+x)x =f(x) 21112 Equilibrium points are solutions of f(x) = 0, so each must have x2 = 0 and 2x1 − 0.5x13 = 0, three solutions are 􏰀0􏰁 􏰀2􏰁 􏰀−2􏰁 xe1 = 0 xe2 = 0 xe3 = 0 and we have the Jacobian matrix 􏰀01􏰁 2− 3x12 −x2 −(1+x1) 2 such that at (0,0), (2,0) and (-2,0) 􏰀x ̇1􏰁 􏰀0 1􏰁 􏰀x ̇1􏰁 􏰀0 1􏰁 􏰀x ̇1􏰁 􏰀0 1􏰁 x ̇ =2−1x,x ̇ =−4−3x,x ̇ =−41x 222 9 Exercise 5. State space representations 1. What is the dimension (or shape) of the matrix B and D in the given state space representation: 􏰇 y1 x ̇1  a11 a12 a13 x1  b11 b12 b13 b14   x ̇2 = a21 a22 a23  x2 + b21 b22 b23 b24 u(t) x ̇3 a31 a32 a33 x3 b31 b32 b33 b34  x1  y2 􏰈T =[B] x2 +[D]u(t) x3 State how may inputs, states and outputs are present in this system. Solution: The state vector is of shape 3 × 1. Given the [bij] matrix is 3 × 4 the input vector must be 4 × 1 i.e. 4 inputs, for matrix multiplication to be defined. In the 2nd equation, there are 2 outputs y1 and y2. Thus B should be a 2 × 3 matrix and D should be 2 × 4. There are 4 inputs, 3 states and 2 outputs in the system. 10 Exercise 6. Linearization of system Consider the below Inverted pendulum problem, θ m, I F The system dynamics is illustrated as the below equations: 2l 􏰉(m + M)x ̈ + mlθ ̈− mlθ ̇2sinθ = F (I + ml2)θ ̈ + mlx ̈ cos θ − mgl sin θ = 0 M Linearize the state equations about the equilibrium. Derive the A and B matrices by substituting the operating equilibrium point. Here m is mass of the rod, M mass of cart, l is length of the rod, I is moment of inertia of the rod, θ is the swing angle of the rod, g is gravitational acceleration, x is distance along cart, F is Force applied as in the diagram. Solution: The state equations are: (I + ml2)θ ̈ + mlx ̈ cos θ − mgl sin θ = 0 􏰉(m + M)x ̈ + mlθ ̈− mlθ ̇2sinθ = F Differentiate for linearizing and get: dx dt =x ̇ 2 22 2 ̇2 dx ̇ = (ml +I)F−gm l sinθ+ml(ml +I)θ sinθ dt (M +m)(ml2 +I )−m2 l2 cosθ dθ =θ ̇  dt dθ ̇ = glm(M+m)sinθ−mlcosθ(F+mlsinθθ ̇2) dt (M +m)(ml2 +I )−m2 l2 cosθ   x ̇ = 0   θ ̇ = 0 F = (M + m)g tan θ F=gm2l2 sinθ ⇒ θ = nπ,F = 0 The equilibrium is: (ml2 +I ) Look at equilibria: from 1st and 3rd rows x ̇ = θ ̇ = 0 􏰉F = (M + m)gtanθ ⇒ at equilibrium F = gm2l2 sinθ , imply θ = nπ,F = 0 (ml2 +I ) Linearize about the unstable equilibrium θ ≈ 0 Compute Jacobian: 11 The Jacobian is defined as - ∂f1 ∂f1 ∂f1 ∂f1  ∂ x ∂ x ̇ ∂ θ ∂ θ ̇  ∂f2  ∂ θ ̇   ∂f3  ∂ θ ̇    ∂f4 ∂f4 ∂f4 ∂f4 ∂ x ∂ x ̇ ∂ θ ∂ θ ̇ ∂f1 =0,∂f1 =1,∂f1 =0,∂f1 =0 ∂x ∂x ̇ ∂θ ∂θ ̇ ∂f2 =0,∂f2 =0 ∂x ∂x ̇ ∂f2  ∂ x A =  ∂f2 ∂ x ̇ ∂f2 ∂ θ ∂f3  ∂ x ∂f3 ∂ x ̇ ∂f3 ∂ θ Here, ∂f2 =((m+M)(I+ml2)−m2l2cosθ)(−gm2l2cosθ+(I+ml2)mlθ ̇2cosθ) ∂θ ((I + ml2)(m + M) − m2l2cosθ)2 −(F (I + ml2) − gm2l2sinθ + (I + ml2)mlθ ̇2sinθ)(m2l2sinθ) ((I + ml2)(m + M) − m2l2cosθ)2 ∂f2 = 2ml(ml3+I)θ ̇sinθ ∂θ ̇ (M + m)(ml2 + I) − m2l2cosθ ∂f3 =0,∂f3 =0,∂f3 =0,∂f3 =1 ∂ x ∂ x ̇ ∂ θ ∂ θ ̇ ∂f4 =0,∂f4 =0 ∂ x ∂ x ̇ ∂f4 = ((m + M)(I + ml2) − m2l2cosθ)((m + M)mglcosθ + mlFsinθ − m2l2θ ̇2cos2θ + m2l2θ ̇2sin2θ) ∂θ ((I + ml2)(m + M) − m2l2cosθ)2 −((M + m)mglsinθ − mlF cosθ − m2l2θ ̇2sinθcosθ)(m2l2sinθ) ((I + ml2)(m + M) − m2l2cosθ)2 ∂f4 = −2m2l2cosθsinθθ ̇ ∂θ ̇ (M + m)(ml2 + I) − m2l2cosθ 12 Substitute equillibrium point 01 0 0 0  1  0 0  −m2l2g (M +m)(ml2 +I )−m2 l2 ⇒ A =  0 0 00 glm(M+m) 0 (M +m)(ml2 +I )−m2 l2 0  ml2+I  ∂f (M+m)(ml2+I)−l2m2  B=∂F|x ̄0,u ̄0 =  0 −ml (M +m)(ml2 +I )−m2 l2 0 13