0% found this document useful (0 votes)
184 views

Everything Is The Same Modeling Engineered Systems

This document provides an introduction and overview of the course "Everything is the Same: Modeling Engineered Systems". The course aims to teach students to synthesize analytical reasoning, computational skills, and physical knowledge to solve engineering problems. It will cover modeling techniques including linear models, differential equations, mathematical analysis, and computational evaluation. The goal is for students to be able to develop models of physical systems, perform analyses and computations, and think critically about the results by applying their physical intuition and experience. Participation in online discussions is encouraged to help students learn from each other's experiences.

Uploaded by

yashar2500
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views

Everything Is The Same Modeling Engineered Systems

This document provides an introduction and overview of the course "Everything is the Same: Modeling Engineered Systems". The course aims to teach students to synthesize analytical reasoning, computational skills, and physical knowledge to solve engineering problems. It will cover modeling techniques including linear models, differential equations, mathematical analysis, and computational evaluation. The goal is for students to be able to develop models of physical systems, perform analyses and computations, and think critically about the results by applying their physical intuition and experience. Participation in online discussions is encouraged to help students learn from each other's experiences.

Uploaded by

yashar2500
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

Everything is the Same: Modeling Engineered Systems

Lecture Notes
Todd D. Murphey
c Todd D. Murphey
Contents
Calculus Review ii
1 Everything Is The Same 2
2 Modeling Components 5
3 Newtons Laws 9
4 Euler Integration 13
5 Exponential Solutions 16
6 Superposition 20
7 Newtons Laws with Mass 23
8 Newtons Laws with Several Masses 25
9 Imaginary Numbers and Eulers Formula 28
10 Imaginary Numbers Continued 30
11 Vector and Matrix Representations 34
12 Vector Solutions to Ordinary Differential Equations 38
13 Chemical Diffusion and Ficks Law 42
14 The Diffusion Equation with No Accumulation 44
15 The Diffusion Equation with Accumulation 47
16 Time-Varying Diffusion 50
17 The Convolution Equation 53
18 Modeling Electrical Components 57
19 Kirchhoffs Laws 60
20 Kirchhoffs Laws with Inductors 63
21 Vector and Matrix Representations in Kirchhoffs Laws 66
22 Mechanical/Electrical Analogies 69
23 Interpretation of Mathematical Expressions as Physical Systems 72
24 Everything Is The SameAlmost 75
i
Calculus Review
There are not that many things you need to remember from calculus, but the few that you do need
are extremely important. These notes are intended to serve as a reminder of what you learned in
calculus, and I will reference these facts during the rest of the class.
Derivatives, Derivative Notation, and Integrals
First, you have to know what a derivative of a function with respect to a scalar is. For instance, if
I have a function f(x)where x is an unknown numberthe derivative of f(x) with respect to x
is dened to be
d
dx
f(x) =
df
dx
(x) =
df(x)
dx
= lim
dx0
f(x + dx) f(x)
dx
.
This denition says that if I change x by a small amount dx, then the value of the function will
change as well, and the amount of that change is encoded by the derivative if dx is small enough.
Other notation for the derivative of f(x) with respect to x includes
df
dx
(x) and
df(x)
dx
these are
just notational choices; the limit above is the actual denition. Another notation that I will use one
time during the class is the prime notation
d
dx
f(x) = f

(x).
Most of the time we will be taking derivatives of a function with respect to time t. In this case,
special notation is sometimes used, called dot notation. If I have a variable y that is a function
of t (that is, it is of the form y(t)), then I can write the rst derivative of y with respect to t as
d
dt
y = y.
Moreover, I can write the second derivative of y with respect to t as
d
2
dt
2
y = y.
This notation is very common in engineering. Lastly, if I differentiate a function with respect to
multiple variables, I will need to be able to identify the variable in question. Lets say I have
f(x, y) and I want to take the derivative with respect to x and the derivative with respect to y, then
I use the partial derivative notation

x
f(x, y)

y
f(x, y)
to represent those derivatives.
Integrals are simply the opposite of differentiation. If
d
dx
g(x) = f(x), then
_
f(x) = g(x).
ii
Examples
If n is an integer (n = 1, 2, 3, . . .) and h is a scalar parameter (it is a number), then
d
dt
t
n
= nt
n1
d
dt
sin(t) = cos(t)
d
dt
cos(t) = sin(t)
d
dt
e
ht
= he
ht
If x(t) represents the position of an object as a function of time. Its rst derivative is velocity
v(t) =
d
dt
x(t) = x(t) = x.
Its second derivative is acceleration
a(t) = v(t) = v = x(t) = x.
Product Rule, Chain Rule, and Leibniz Rule
There are three rules you need to remember from calculus. One of them is product rule: that if f
and g are both functions of x, then the derivative of the product f(x)g(x) is equal to
d
dx
(f(x)g(x)) =
_
d
dx
f(x)
_
g(x) + f(x)
_
d
dx
g(x)
_
.
The chain rule says that if one composes f(y) and g(x) (i.e., has the function h(x) = f(g(x))),
then the derivative is:
d
dx
f(g(x)) =
d
dy
f(g(x))
_
d
dx
g(x)
_
.
This is often very confusing because it isnt clear what y is. The key is that g(x) must have its
output be the same type of variable as y isso if g(x) is a number, then y must be a number and if
g(x) is a vector, then y is a vector.
Lastly, Leibniz rule will play a role at one particular point. People are often a bit scared by
Leibniz rule, but it is tremendously useful. Lets say that f(t) is actually a function that involves
an integral. For example
f(t) =
_
t
0
sin()d
is a function that involves an integral. For any given t, this function will return a number, and that
means that you can differentiate with respect to t. Leibniz rule tells us that the derivative can be
found by:
d
dt
_
t
0
h()d = h(t).
This says that the derivative of this integral is equal to the function being integrated at the time t.
iii
Examples
d
dx
sin(x) = cos(x)
d
dt
_
t
0
sin()d = sin(t)
Taylor Series
Yes, Taylor series are really, really important! The Taylor series of a function f(x) is an
approximation of the function f at a value of x that only involves derivatives of f evaluated at that
value of x (in this case x = 0).
f(x) = f(0)+
_
d
dx
f(x)
_
x+
1
2!
_
d
2
dx
2
f(x)
_
x
2
+
1
3!
_
d
3
dx
3
f(x)
_
x
3
+ +
1
n!
_
d
n
dx
n
f(x)
_
x
n
+
Examples of Taylor series that are particularly relevant to this class are derivatives of e
ht
, sin(t),
and cos(t).
e
ht
= 1 + ht +
1
2!
h
2
t
2
+
1
3!
h
3
t
3
+
1
4!
h
4
t
4
+
1
5!
h
5
t
5
+
1
6!
h
6
t
6

sin(t) = t
1
3!

3
t
3
+
1
5!

5
t
5
+
cos(t) = 1
1
2!

2
t
2
+
1
4!

4
t
4

1
6!

6
t
6
+
Other Useful Facts
Lastly, here are some facts worth knowing:
1. e
a+b
= e
a
e
b
2. If we have three coefcients , , and , then
h
2
+ h + = 0
implies that
h =

_

2
4
2
.
This is called the quadratic formula.
3. The imaginary numbers involve j =

1.
1
1 Everything Is The Same
Welcome to my Coursera class Everything is the Same: Modeling Engineered Systems. I hope you
are looking forward to the class!
1
One of the most fundamental goals of this class is to train you to synthesize different aspects of
engineering skills. In particular, good engineers typically employ a combination of Analytical Rea-
soning, Computational Skills, and Physical Knowledge to solve problems. The more critical the
engineering problem issuch as making sure that the power grid does not experience failuresthe
more important it becomes to combine these skills rather than just using one.
By Analytical Reasoning, I mean the ability to write down mathematical expressions that rep-
resent a physical system. By Computational Skills, Im referring to the ability to use a computer to
either evaluate or predict characteristics of a model that are too challenging to solve analytically.
And by Physical Knowledgepossibly the most important of the threeI mean the crucial ability
of an engineer to think critically about analysis and computations in the context of real, physical
knowledge about the world. This last piece can only come from experience, so in this class Im
going to rely on examples that you either already have experience with or examples that you can
easily reproduce on your own.
For those of you that saw the promotional video for this class, you saw the examples of the
power grid (a snapshot of which is in Fig.1) and the biomechanics of the hand.
Figure 1: A snapshot of the powergrid animation from the class promotional video.
Both of these examples are, of course, very complex to understand. Using physics-based mod-
eling, we can use analysis to come up with a model of the hand and we can use computations to
make predictions using that model, seen on the left in Fig. 2.
But what happens when we compute something that doesnt make sense, like on the right of
Fig. 2? When I look at this numerical simulation of the hand, I certainly dont think that I ever
want my hand to behave that way!
The reason we know that there is something wrong is because of our physical experiencewe
simply know that a real hand doesnt behave the way this movie suggests, despite the fact that the
analysis and computation was all done carefully. This physical knowledge tells us that there is
1
If you are reading these notes after listening to the rst lecture, you will notice that the class notes nearly perfectly
follow the online lecturesthis is intentional! However, these class notes will have many additional footnotes, like
this one, to explain and/or clarify concepts as we go.
2
Figure 2: A simulation of the hand from the class promotional video. The simulation on the left
looks plausible, but the simulation on the right doe not!
something wrong with either our analysis or our computations or possibly both, and synthesizing
physical knowledge into our engineering judgement is a critical aspect of engineering safe, reliable
systems.
One of the challenging things about physical knowledge is that we all have different experi-
ences, so learning together is critical. Because of that, I really encourage you all to participate in
online discussions andif at all possible. This social aspect of learning is, I think, critical to be-
coming uent in modeling engineered systems and, simultaneously, thinking critically about that
modeling process.
In this class, you will learn different aspects of engineering modeling techniques. You will
learn Analytical Reasoning, including the importance of linear models, that differential equations
are nearly universal in engineering models, and that mathematical analysis of those models can
both help you understand systems better and make your life quite a bit easier. To be prepared for
this analytical part of the class, you should have had some pre-calculus; in particular, you should
know that position and velocity are related by the time derivativethat the velocity v is the time
derivative of the position x.
2
Aside from that, you really only need to be prepared to do some
algebra.
You will learn Computational Skills, including numerical integration methods that you will
implement in either MATLAB or Python and the use of vector representationsthese also make
your life quite a bit easier. You dont need any experience with programming for this part of the
class, but you will need to either purchase a MATLAB license or download Python, which is free.
We will provide short MATLAB tutorials to help you get started and provide sample MATLAB
code to guide you through the class.
Lastly, you will learn Physical Knowledge, which will help you internalize when you can use
the mathematical modeling tools we are learning, when you cannot, and improve your engineering
judgment as a result. Whatever experience you already have will prepare you for this part of the
class.
Throughout the class, you will test the development of these skills by trying out the exercises
directly following the lectures and the homework. These will help you investigate the material in
more depth and solidify the material presented in the lectures.
2
If you havent already, you should look at the calculus review we have posted to make sure you are familiar with
the ideas that are there.
3
Combining analytical reasoning, computational reasoning, and physical reasoning is an essen-
tial part of being an engineer, and I hope that as you take this class you learn how to synthesize
these skills for your future as engineers.
4
2 Modeling Components
Last time I mentioned that Analytical Reasoning, Computational Skills, and Physical Knowledge
are all critical components of an engineers judgment. Building those skills starts with understand-
ing how to model components of a physical system.
3
Figure 3: Force is related to position or velocity through a constitutive law, often a linear constitu-
tive law for engineered systems.
Today we are going to investigate how we model components of a mechanical system. In gen-
eral, we use what are called constitutive laws to model individual components. These constitutive
laws relate variables of interest, like position x and velocity vthe derivative of position with re-
spect to timeto forces. For instance, a plot of a constitutive law might look like the one in Fig. 3,
where the force F is on the vertical axis and the variable x or v is on the horizontal axis. If you
think of pulling on a springlike the slinky I showed in lecturethe spring only exerts a force if
3
You will notice that there are lots of footnotes in these lectures notes. The reason for so many footnotes is that I
want the main text of the lecture notes to perfectly track the online lectures, so that it is easier to nd the relevant place
that you have questions about. As questions come up, I will add footnotes explaining small points or add sections at
the end of each lecture explaining bigger points.
5
it is either compressed or extended away from its natural length, so if the amount of extension is
exactly zero, we expect the force to be zero. Thats why this curve goes through the origin. If we
pull on a spring extending it some set amount, then the amount of force we will feel will be nonzero
and might be up and to the right. Now the thing to hope for is that if we draw a line between the
origin and that point, we get a prediction of how much force we should feel for any given amount
of extension of the spring. A relationship that has a line relating the two variables is called a linear
relationship. A linear relationship is a lot to hope for, and in general natural systems do not behave
that way.
But engineered systems have some engineers brain involved, and that engineers brain knows
that we would prefer the relationship to be a line. Thats why engineered systems typically do
end up with constitutive laws that can be described by a nice line like this. By the way, thats also
why this class is about modeling engineered systems; only engineered systemssystems that have
been designed by someoneactually behave this way.
Figure 4: This course will focus on the 3 types of elements shown in the diagramsprings, masses,
and dampers
Mechanical diagrams play a critical role in how we set up models of mechanical systems,
and in this class we are going to always assume that we have three types of componentssprings,
dampers, and masses. We will always use the three symbols in Fig. 4 to represent the three types of
idealized components. We will always use the same sign conventions as well. Whenever a spring,
like the slinky from lecture, is in extension, its position x
s
is dened to be positive. Whenever a
damper, like the syringe I showed in lecture, is in extension, its velocity v
d
is dened to be positive.
Moreover, the relationship between force and position of a spring is always a line represented
by the constitutive law F
s
= kx
s
(where the positive number k is called the spring constant).
The the relationship between force and velocity of damper is also always a line represented by the
constitutive law F
d
= bv
d
(where the positive number b is called the damping constant). Hence,
the force of a spring being positive means that the position must be positive and the spring must be
in extension. The force of a damper being positive means that the velocity of the damper must be
positive and the damper must be extending.
F
s
> 0 x
s
> 0 F
d
> 0 v
d
> 0
Example: With these sign conventions in mind, we can combine elements into combinations
of elements, in this case a spring and a damper in parallel. Note that the spring and damper, both
connected to a wall on the left, must move in unisonthe only allowed motion is horizonal motion.
No matter how many elements are in parallel with each other, they must move just to the left or the
rightthey cannot move up and down in the diagram.
6
Figure 5: A spring-damper system with an external force. You will see this more than you would
probably prefer by the end of the class.
That implies that the end of the spring is attached to the end of the damper, which implies a
relationship between the position of the spring x
s
and the velocity of the damper v
d
. In particular,
the time derivative of the position of the spring must be equal to the velocity of the damper.
Lastly, you should know that we always dene positive acceleration of a mass to be to the right
and external forces are always positive if the force is acting to the rightthat is, the force would
cause a positive acceleration of a mass.
Figure 6: A spring with an external force. If the force changes instantaneously, so does the position
of the spring. This is unintuitive because this is an ideal spring.
Example: Now, sometimes our understanding of a physical system will not be well aligned with
our understanding of idealized elements. As an example, consider this very simple system in Fig. 6
that consists of a spring with no mass and an external force. When the spring is in extension, the
force is dened to be positive, and when the external force is positive, it is pulling the spring into
extension. What does our constitutive law say about what happens if F
ext
starts out at zero and
then suddenly becomes positive? Specically, what if F
ext
= 0N until t = 1 and then becomes
F
ext
= 1N?
While the external force is zero, the force on the spring is zero and its position is zero. Hope-
fully this makes sense because the spring will only be extended or compressed if something is
forcing it to be. However, if we make the force jump up to one Newton, the position of the spring
will instantaneously jump as well. That probably seems unintuitive, but thats because real springs
have ideal spring properties plus damping properties and mass properties! Keeping in mind the
difference between these idealized elements and the real physical objects they represent, is one of
the key skills you will develop over the course of this class; this difference forces us to bridge the
gap between Analytical Reasoning and Physical Knowledge.
What should you remember from today? Keep in mind that constitutive laws are linear be-
7
cause we engineer systems to make them linear, that sign conventions matter, and that idealized
mechanical elements can have unintuitive behavior.
Example: As another example, think about Fig. 5 for a moment, with F
ext
= 0. Which of the two
plots below is even plausible?
The one on the left implies that, as a function of time, x
s
gets smaller and smaller, very slowly.
The one on the right implies that, as a function of time, x
s
gets bigger and bigger, very quickly.
Therefore the one on the right doesnt really make sense for a physical system, but the one on the
left does.
8
3 Newtons Laws
Last time we learned how constitutive laws relate forces to variables describing components, but
what principles do we use to combine those constitutive laws into models of mechanical systems?
Newtons laws
4
provide the basis for everything we do. You probably knowNewtons laws already:
they say that the sum of the forces at a point must be equal to the mass of that point times its
acceleration.

F = ma (1)
Something we often do not acknowledge is that Newtons laws are really only interesting or
deep if there are multiple forces involvedthat is, the statement that F = ma is not all that
interesting because of course the second derivative of position must be equal to something.
5
But
the sum of forces being equal to mass times acceleration is very deep, because that means there
can be multiple components that all interact with each other through this magical relationship!
Figure 7: A spring with an external force equal to zero.
As an example, lets go back to our spring and damper system where we assume that the
external force is equal to zero. This spring-damper system could represent a shock absorber on a
vehicle that has a load of an external force on it or a bungee cord like the one I showed in lecture
that I can stretch by pulling on the end with an external force. Newtons laws tell us that the sum
of forces at the point where the spring and the damper meet must be equal to the mass times the
acceleration of that point.
A positive external force will cause the point mass to accelerate to the right. On the other
hand, a positive spring forceindicating that the spring is in extensionwill accelerate the point
to the left.
6
Similarly, a positive damping force would act to the left. Hence, the sign conventions
we chose for the individual mechanical elements have consequences for the signs in Newtons
equations
F
ext
F
s
F
d
= ma = 0
and I strongly recommend that you get in the habit of making sure that you think about the physical
meaning of each force as you incorporate it into Newtons laws.
7
Now, if we assume that the
4
It is pretty amazing the Newtons laws have held up as well as they haveNewtons laws lasted as the only real
candidate for macroscopic physical law until Euler and then eventually Einstein.
5
I think this confused me as an undergraduate for at least two years!
6
Note that this is only true because the spring is on the left. If it were on the right, then a positive spring force
would accelerate the point mass to the right, in the positive direction.
7
The generalization of keeping track of sign conventions in this way is called a free body diagram. For us, free
body diagrams are unnecessarily complicated and dont really help very much, but as soon as you are trying to add up
forces acting on a body in three dimensions they become really useful.
9
external force is zero and that the mass of the point is zero, we are left with a much simpler
expression of Newtons laws F
s
F
d
= 0.
If we use the constitutive laws from Lecture 2 that relate the spring force to the spring position
and the damper force to the damper velocity,
F
s
= kx
s
F
d
= bv
d
and substitute these constitutive relations into Newtons laws, we get an equation involving x
s
and
v
d
.
F
s
F
d
= 0
kx
s
bv
d
= 0
If we additionally keep in mind that the time derivative of the position of spring is equal to the
velocity of the damper (i.e., x
s
= v
d
), we get a simple equation involving only the position of the
spring.
kx
s
b x
s
= 0
Now, if we dene x to be the position of the spring (just dropping the s), we get
kx b x = 0
and if we then solve for x (remembering that the dot notion is the same as
d
dt
x), we get what is
called an ordinary differential equation or ODE for short.
x =
k
b
x x = f(x)
This ODE says that the derivative of the position is equal to the negative spring constant divided
by the damping constant multiplied by the position.
8
Note that this means that the derivative of the variable x is equal to a function of the variable x.
This is the form of an ODEit is always the derivative of something being equal to a function
of that something.
d
dt
(something) = f(something) (2)
In this case, that something is the position x and f(x) is equal to
k
b
x. In general the some-
thing is called the state of the ODE.
States of mechanical systems do not have to be positionslater we will also use velocity of
masses as states. Engineers get good at choosing the state of an ODE with experience, and you
will get good at this as well.
In principle, an ODE can be very complex. For instance, it could look something like
x = tanh
1
(x
2
)
which is clearly a huge mess! But for us we will always focus on what are called linear, constant
coefcient, rst-order ordinary differential equations. Linear means that the dependence of a state
8
As you get accustomed to looking at ODEs, it can be very, very helpful to say what the ODE means out loud. If I
am looking at an equation I nd confusing, I still do this.
10
velocity on a state is always a line. Constant coefcient means that the slope of that line is always
constant. First order means that there is only one time derivative. That is, we should only see one
dot over x rather than two.
Lets nish with another example and go back to the model of the spring and damper, but now
allow the external force to be nonzero. This would be like we take the bungee cord from lecture
and pull on it with a constant force.
Nowwe have the external force in the equation but the mass is still zero. If we replace the spring
and damper forces by their constitutive laws, we can solve for an ordinary differential equation that
now includes the external force.
0 = F
ext
F
s
F
d
0 = F
ext
kx b x
x =
k
b
x +
F
ext
b
It is worth thinking about this differential equation and what it means. It says that if the position of
the spring starts out less than zero, making the left hand term greater than zero, and if the external
force is greater than zero, then the velocity of the position of the spring must be positive. If the
position of the spring is positive and the external force is negative, then the velocity of the spring
must be negative.
But if both position and force are positive, we dont know which direction the spring will
moveit depends on the magnitudes of the external force, the spring constant k, and the damping
constant b.
The most important thing from today to remember is that Newtons laws lead to ordinary dif-
ferential equations and that if the constitutive laws are linear, you should expect a linear, constant
coefcient differential equation.
Example: Suppose one just has a damper (no spring and no mass) and applies a force to itwhat
happens?
The diagram might look like the one above. Applying force balance to this example leads
to a potentially surprising outcome. We know that the damper force is dened to be F
d
= bv
d
,
where v
d
is the velocity of the damper. Hence, F
d
> 0 when the damper is extending and F
d
< 0
when the damper is compressing. Moreover, if we write force balance at the drawn node, we get
F
ext
F
d
= 0, so v
d
=
1
b
F
ext
. This means that if one applies F
ext
= 1N of force to a damper, it
will extend at a constant rate forever, until F
ext
changes.
11
State Choices and Sign Conventions
Something that can be very annoying about all of this is how arbitrary the state choices and sign
conventions seem. Let me discuss rst what it means to have a sign convention and then discuss
separatelywhy we choose states and signs the way we do.
First, it is worth admitting that conventions are arbitrary. Everything in this class could be done
under a different set of conventions, and one could make everything work out. For instance, we
will always choose the position of a spring to be a state, and we will always choose the position to
be positive if the spring is in extension and negative if the spring is in compression. This choice
is largely to make the constitutive laws work out nicely. If the spring transitions from extension to
compression, we would like the force generated by the spring to change sign as well, so choosing
the position x to be positive in extension and negative in compression allows us to use a constitutive
law of the form F = kx.
Of course, we could make other choices. We could choose x to be the distance between the
ends of the spring, but that would mean that the constitutive law would be F = k(x L)so that
whenever the spring is extended beyond its natural length L we get a positive force and whenever
it is compressed we get a negative force. But this convention means we have to know L! So really,
the convention we use is to make book keeping easier. It also turns out that with our choice of
state, we will always get a linear ordinary differential equation, whereas if we use this one we get
a form of ordinary differential equation that is harder to work with. The choice of state is largely
to make our lives a bit easier, but in this class I am making the choice for us.
Choice of sign convention for forces works similarly. Here, it is worth noting that the spring
force is not the same thing as the Newtonian force. Newtonian forces are dened as positive if the
force is to the right and negative if the force is to the left. Spring forces are positive if the spring
is in extension and negative if the spring is in compression. Spring forces are dened the way they
are to enable the use of F = kx as the constitutive law, but Newtonian forces are dened the way
they are so that we can use

F = ma. That means we will have to convert between them when
we are solving problems.
12
4 Euler Integration
Last time we learned that Newtons second law leads to a differential equation. If we have a
differential equation, how should we numerically approximate its solution?
To answer this question, lets go back to our example of the spring and damper, which Im sure
you are getting sick of by now.
9
The differential equation, as Im sure you remember, is
x =
k
b
x = f(x) x(t) =
k
b
x(t) = f(x(t))
where Im going to rewrite the differential equation to keep in mind that the position of the spring,
denoted by x, specically depends on timethe position is allowed to change as a function of
time.
Moreover, Im going to refer to the right hand side of the differential equation as f(x(t)). If we
now look at the left hand side, we see the derivative of x(t) with respect to t, which by denition
is equal to
x(t) := lim
dt0
x(t + dt) x(t)
dt
= f(x(t)) (3)
(where := is the notation used to say that the left hand side is dened to be the right hand side).
This says that the derivative of x is equal to the limit as dt goes to zero of x(t + dt) minus x(t)
divided by dt. So far I havent changed anythingthis is still a differential equation and it is still
equal to f(x(t)).
However, if I do not take the limit, and instead simply say that dt is some rather small number
where Im not going to say exactly what I mean by smallwe get an expression that only
approximates x and is therefore approximately equal to f(x(t)).
x(t + dt) x(t)
dt
f(x(t)) (4)
If I rearrange this approximate equation, I get that x(t +dt) is approximately equal to x(t) plus dt
times f(x(t)).
x(t + dt) x(t) + dtf(x(t))
This formula, called Euler integration, means that if we knowx at some time t, we can approximate
x at t + dt. This also means that you should expect to need to know x at some time in order to get
the algorithm started.
Euler integration is the easiest method for numerically approximating a solution to an ordinary
differential equation, but there are certainly other options. You will see in homework that some-
times Euler integration doesnt do a very good job, but if you make dt small enough, you will
always end up approximating the limit in the denition of the time derivative well enough to give
you a decent approximation of the solution to the ODE.
Example: To practically see how Euler integration works, lets look at the spring/damper system
again. Assume that we start out with x at time t = 0 equal to 0.5, k = 1, and b = 1, dt = 0.1.
Then x(0) is, of course, equal to 0.5. What is x(0.1) approximately equal to? Well, using Euler
9
I really am sure you are getting sick of this by this point, and you are probably wondering how everything is the
same if we are only looking at one example. I promise, using just one example for a bit will help to make sure we get
everything straight from the start and I promise that you will be looking at more exciting examples soon!
13
integration we know that x(0.1) is approximately equal to x(0) plus dt times
k
b
x(0). Once we
know that, we can approximately x(0.2) by taking x(0.1) and adding dt times
k
b
x(0.1) to it.
x =
k
b
x x(0) = 0.5 dt = 0.1 k = 1 b = 1
x(0) = 0.5
x(0.1) x(0) + dt
k
b
x(0) = 0.5 + 0.1(0.5) = 0.45
x(0.2) x(0.1) + dt
k
b
x(0.1) = 0.45 + 0.1(0.45) = 0.405
x(0.3) x(0.2) + dt
k
b
x(0.2) = 0.405 + 0.1(0.405) = 0.3645
.
.
. and so on . . .
We could continue this process for x(0.3), x(0.4), x(0.5), and so on. In case you havent
guessed, this process could get really annoying over time, so this is why we will have a computer
do it.
Example: Lets look at two pieces of code, one in MATLAB and one in Python, since those
are the two choices you all have to use. Both pieces of code implement Euler integration for the
spring-damper system.
Figure 8: Euler integration code in MATLAB (left) and Python (right)
Note that at the top of the code we declare the initial conditions to be x(0) = 0.5, that dt = 0.1,
that k = 1 and b = 1. Then we create an array to store all the variables for all time. Then a loop
executes Euler integration and stores the values in the array. After exiting the loop, we plot the
14
results. You will do code very similar to this in your homework assignment, so looking at this
example several times will be helpful!
What should you remember from today? Euler integration provides a means for you to approx-
imate the solution to an ordinary differential equation and it doesnt matter whether the differential
equation is linear or not!
Example: Lets do another example of Euler integration. Lets say that x = 2x and x
0
= 1.
Moreover, lets assume we are going to use a dt of 0.1. How can we approximate x(0.1)?
x(t + dt) x(t) + dtf(x(t))
x(0.1) x(0) + 0.1f(x(0))
= 1 + 0.1(2 1)
= 0.8.
So x(0.1) is approximately 0.8.
15
5 Exponential Solutions
Last time we learned that Euler integration allows one to approximately solve a ordinary differen-
tial equation. What do we do if we have an ordinary differential equation that we want to solve
exactly? For general f(x) in x = f(x), we cannot expect an exact solution, but for linear, constant
coefcient, rst-order ODEs we can.
Having a good guess matters a lot, and for us that guess will always be the exponential solution
x(t) = e
ht
x
0
(5)
where h is an unknown parameter.
This says that we expect a solution to an ordinary differential equation to be an exponential
times the initial condition x
0
which is x(t) at time t = 0 (which we assume to be the initial
time
10
). Notice that if h > 0, this solution will blow up and go to innity if x
0
= 0. If h < 0, then
it will go to zero. This observation is a good way to have some physical intuition about what the
exponential function means and if it makes any sense.
What does it mean to solve a differential equation, anyhow? We didnt really get into this
question in the last lecture, but it is helpful to think of x as the time derivative
x(t) = f(x(t)) means
d
dt
x(t) = f(x(t))
so that you see that we are really saying that x solves the differential equation if plugging it into
the left hand sidethat is, taking its time derivativeis the same as plugging it into the right hand
sidethat is, evaluating f at x(t) for all time.
Figure 9: Spring-damper system with an external force that is zero.
Example: To see how this works, lets assume that our spring-damper system has an exponential
solution and plug into the differential equation to nd the value of h. If we plug into to both sides,
we get
x =
k
b
x

d
dt
x(t) = f(x(t))

d
dt
e
ht
x
0
=
k
b
e
ht
x
0
10
One can do all of the notation so that the initial time is t
0
, but it makes it a little annoying to look at and annoying
for me to write in lectures, so we will assume that t
0
= 0. However, if we were not working with constant coefcient
ODEs, we would have to be more careful about specifying the initial time.
16
Taking the derivative of the exponential drops the h down, and since we know that the exponential
is never zero we can divide by both sides.
he
ht
x
0
=
k
b
e
ht
x
0
h =
k
b
This means that h is equal to
k
b
(assuming x
0
= 0)! So we know that the solution is
x(t) = e

k
b
t
x
0
.
If we now specify that k = 1, b = 1, x = 0.5 then we see that
k = 1 b = 1 x
0
= 0.5 x(t) = e
t
0.5
Note that this behavior is somewhat unintuitive. It says that if I extend the spring-damper system
by 0.5 units, then I will see it move forever, which of course a real system will never do. This
is largely because damping tends to be nonlinear at very low velocitysuggesting we can never
fully believe our analytical models or computational modelsbut this solution x(t) = e

k
b
t
x
0
will
capture the behavior of many spring-damper systems.
Figure 10: Two simulations at dt = X and dt = Y as well as the analytical solution for x = x
with an initial condition of 0.5.
We can now compare the results of the analytical solution to the results of Euler integration
an example is in Fig. 10. At large dt the approximation to the solution is not very close to the
analytical solution but at small dt it is. This means that you have to use your judgement when
choosing the dt for your simulation.
Today we learned about exponential solutions to ordinary differential equations. Exponential
solutions are valid for any linear, constant coefcient rst-order differential equation where the
external force is zero, and we will be talking about them occassionally for the rest of the class.
17
For now, keep in mind that an analytic solution exists for many engineered systems that you will
encounter and certainly all the ones we will see during the rest of this class.
Example: Lets nd the analytic solution of x = 2x with x(0) = 1, and use it to nd the exact
value of x(0.1). We know the solution is of the form of an exponential e
rt
A, where r and A are
constants. Plugging into the differential equation, we get re
rt
A = 2e
rt
A, which implies that r = 2.
Setting t = 0 implies that A = 1. So the solution is x(t) = e
2t
, which implies that x(0.1) = e
0.2
.
18
What Does The Word Linear Mean?
The word linear in linear, constant coefcient, rst-order ODEs can cause a lot of confusion.
In many respects, that is because the word linear has two primary uses. One use is descriptive
so that when we see an equation of a particular form, we know what to call it. The other use is
based on properties that we might want. I want to describe what I mean in a context that is a bit
simpler than ODEs, and instead focus on algebraic equations. I will come back to ODEs with a
similar discussion of linearity after the next section on superposition.
Look, for a moment, at the following equations.
y =
1
2
x
y =
1
2
x + 1
Here both x and y are variables, and the graph relating them is shown in this picture.
In both cases y is related to x through a constant of proportionality
1
2
. Now, lets assume that
we have four choices of x values we are interested inx
1
, x
2
, x
3
, and x
4
. Each of these maps to a
y valuey
1
, y
2
, y
3
, and y
4
. Lastly, assume that we know that x
3
= 2x
1
and x
4
= x
1
+ x
2
. What
might we hope? It would be helpful if knowing y
1
and y
2
helped predict y
3
and y
4
. Specically,
we might hope that y
3
= 2y
1
and y
4
= y
1
+y
2
. In general, this relationship does not hold, even for
y =
1
2
x + 1.
An equation with a mapping between y and x that satises both the scaling property
11
and the
additive property
12
is linear. It happens that all equations of the form y = ax are linear in this
sense, but other types of relationships are linear as well. However, relationships like y =
1
2
x + 1
are not linear, because the 1 added to the equation makes the properties disappear (y =
1
2
x + 1 is
called linear afne).
All of this may sound very academic when talking about a relationship between y and x, but if y
and x are vectors, or curves, oras in the next sectionsolutions to ODEs, suddenly scaling and
additive properties can matter a lot, both in terms of conceptually understanding and concretely
doing calculations.
11
Formally, that if y = g(x), then ay = g(ax).
12
Formally, that if y
1
= g(x
1
) and y
2
= g(x
2
), then y
1
+ y
2
= g(x
1
+ x
2
).
19
6 Superposition
Why do we bother being so careful to design systems to have constitutive laws that are linear?
It is a reasonable question, particularly considering that we just learned in Lecture 4 that Euler
integration allows us to approximate solutions to ordinary differential equations whether they are
linear or notas long as dt is small enough. Maybe having an exact, analytical solution isnt worth
the trouble! The real value of linear constitutive laws comes from the fact that we get to use what
is called the principle of superposition.
The key thing about linear constitutive laws and the resulting linear ODEs is that if I give
you two solutionsregardless of how I obtained themyou can get a whole bunch of potential
solutions from those two. We know that Euler integration requires having an intitial condition to
get started, but superposition allows us to solve for everything we need without worrying about the
initial condition until the end, after we have done most of the calculations. This ends up being a
really powerful idea.
Example: Starting with our favorite example, the spring-damper system, with k = 2 and b = 1.
x =
k
b
x x
1
(0) = 1 x
2
(0) = 2 k = 2 b = 1
lets say we have two solutions, x
1
(t) and x
2
(t). How can we even have two solutions? Well,
every initial condition gives us a different time evolution, so every initial conditions corresponds
to a different solution to the differential equation. In this case, we might have x
1
(0) = 1 and
x
2
(0) = 2. From this, using the fact that the solution for each initial condition is exponential, we
can conclude that
x
1
(t) = e
2t
x
2
(t) = 2e
2t
x
1
is an exponential and x
2
is an exponential.
13
Now lets assume that and are constant numbersthat is, they are numbers like 1 or 1/2
or or, later, we will even allow these numbers to be imaginary numbers.
14
Then the principle of
superposition tells us that if and are numbers, and if x
1
(t) and x
2
(t) are both solutions to the
same linear, constant coefcient, rst order ordinary differential equation, then:
1. x(t) = x
1
(t) + x
2
(t) is a solution as well;
2. x(t) = x
1
(t) is a solution for any choice of number ;
3. x(t) = x
2
(t) is a solution for any choice of number ;
4. and that if we combine these into a single expression, that
x(t) = x
1
(t) + x
2
(t) (6)
is a solution.
13
Note that in this expression of the solutions, x
2
(t) is multiplied by 2 because the initial condition for x
2
is 2.
14
Remember from the calculus review that the imaginary numbers involve j =

1.
20
That means that if I give you two solutions, you can generate a whole bunch of other solutions
with them! Lets say that x = ax and we had two solutions x
1
(t) and x
2
(t) and dened x(t) =
x
1
(t) + x
2
(t). Then
d
dt
x(t) =
d
dt
(x
1
(t) + x
2
(t)) = x
1
+ x
2
= ax
1
+ ax
2
= a(x(t))
so x(t) really is a solution to the differential equation.
Lets look at our specic example. We have the two solutions I just mentioned
x
1
(t) = e
2t
x
2
(t) = 2e
2t
and if we add them together we get the sum of the two solutions. Now lets check that these two
solutions added together really are a solution to the differential equation. We do this by taking the
resulting sum
x(t) = x
1
(t) + x
2
(t) = e
2t
+
_
2e
2t
_
and substituting it into the differential equation
d
dt
x(t) =
d
dt
_
e
2t
2e
2t
_
= 2e
2t
+ 4e
2t
= 2
_
e
2t
2e
2t
_
=
k
b
x(t)
and we nd that we still get that
d
dt
of x(t) is equal to
k
b
times x(t), so x(t) = x
1
+ x
2
is indeed
a solution to the differential equation. We can do the same thing with x(t) = x
1
(t) where = 3
and nd that this also solves the differential equation. That is,
x(t) = x
1
(t) x(t) = 3e
2t
and we can take this and substitute it into the differential equation
d
dt
x(t) =
d
dt
_
3e
2t
_
= 6e
2t
= 2(3e
2t
) = 2x(t) =
k
b
x(t).
What should you remember from today? Remember that when you have a linear constitutive
law, and the resulting linear, constant coefcient ordinary differential equation, you get to use
solutions you have already computed to nd new solutions. Why would you need to do this? You
might have already calculated the solution for one initial condition, and then someone tells you
that the original initial condition was wrong and you need to do it again for a new initial condition.
If you can write the new initial condition as a function of adding and scaling initial conditions for
which you have already computed solutions, superposition allows you to use those solutions for the
new initial condition. For a simple system, you would probably just calculate the whole solution
again, but as systems get more complexif there were thousands or millions of spring-damper
components all connected togetherrecomputing the solution might take a very long time.
21
What Does The Word Linear Mean for Ordinary Differential
Equations?
At the end of Lecture 5, I talked about linearity in the context of algebraic equations. What should
linearity mean in the context of ordinary differential equations? Just as in the case of algebraic
equations, we want the word linear to imply a property rather than only be used a description of
the form of the equation.
Look, for a moment, at the following equations.
x =
1
2
x
x =
1
2
x + 1
Here x(t) is a solution to the ODE. In both cases x is related to x through a constant of proportion-
ality
1
2
. Now, lets assume that for a particular initial condition x
1
we have solved this ODE and
obtained x
1
(t) that has x
1
(0) = x
1
. Moreover, lets assume we have done so for an initial condition
x
2
as well. What if we now have a new initial condition x
3
= 2x
1
or x
4
= x
1
+x
2
? We would like
the resulting solution to the ODE to be x
3
(t) = 2x
1
(t) and x
4
(t) = x
1
(t) + x
2
(t). This linearity
property in the context of ODEs is exactly the property of superposition. Moreover, notice that it
does not hold for x =
1
2
x+1, so in general we do not call x =
1
2
x+1 a linear differential equation.
Instead, we call it a linear afne ordinary differential equation, and we will see later in the class
how to work with equations like these.
22
7 Newtons Laws with Mass
Previously, we learned about Newtons laws in Lecture 3, but in the absence of mass. Today we
are going to look at what happens when the mass at a point is nonzero. That is, we are going to
look at

F = ma
where m = 0. Remember that here F are the forces acting on a point, always dened to be positive
if the force would cause a positive acceleration. The variable a is the accelerationthe second time
derivative of the position of the point, dened to be positive if the acceleration is to the right. The
acceleration a is also the rst time derivative of the velocity v
m
of the point. Lastly, remember that
v
m
of the mass is always assumed to be measured relative to what is called an inertial reference
frame. In the case of the spring-mass-damper system the inertial reference frame is the wallthat
is, we measure velocities with respect to the wall.
Figure 11: A system with a spring and damper in parallel, attached to a mass with an external
force.
This diagram could represent a lot of things, like the shocks on a car or bicycle, or even the
slinky I showed in lecture, where the bottom of the slinky is connected together so that we think
of the bottom of the slinky as having a xed mass. If I hold the slinky horizontally, then the force
due to gravity has no effect on the linear motion, but if I hold it vertically, then gravity introduces
an external force on the system. The slinky is a good example to keep in mind because the model
we choose to use really depends on what behavior we are trying to model; if the slinky oscillates
with only one frequency of oscillation, the model that we get from just a spring, damper, and mass
will do a good job. If, however, we create extra oscillations, like I did in lecture, we might have
more trouble with such a simple model. Hence, your engineering judgment mattersyou cannot
just blindly write down a model and expect it to be valid.
Lets look at a model of a mass with a spring and damper. The sum of the forces are equal to
the mass times acceleration.
F
ext
F
s
F
d
= ma = m x
s
We already know from Lecture 3 that v
d
is equal to x
s
, giving
F
ext
kx
s
b v
d
..
xs
= ma = m x
s
so if we solve for x
s
we get
x
s
=
k
m
x
s

b
m
x
s
+
F
ext
m
23
which is a linear, constant coefcient, second-order ordinary differential equation in the position
of the spring x
s
. We know that we need a rst-order ODE if we are going to use Euler integration
from Lecture 4 and the analytic solutions from Lecture 5, so we need to convert this system to a
rst-order ODE.
To do so, it is helpful to note that the equation
x
s
= f(x
s
, x
s
)
can be rewritten as
d
dt
( x
s
) = f(x
s
, x
s
)
where now we have written
d
dt
in two different ways. The nice thing is that we can recognize x
s
as
v
m
, so we are going to relabel x
s
as v.
Now we have the differential equation
v = f(x
s
, v) =
k
m
x
s

b
m
v +
F
ext
m
x
s
= v
where x
s
= v comes from the relabeling we just did. This exercise of converting from a second-
order differential equation to a rst-order differential equation is something you will do a lot as an
engineer. It is worth practicing.
What should you remember fromtoday. First, that Newtons equations allowyou to incorporate
mass into a linear constant coefcient ordinary differential equation; second, hopefully the slinky
convinced you that when you have mass you should expect the possibility of oscillation; and third,
that ODEs have to be converted into rst-order differential equations, which will mean increasing
the number of differential equations.
Example: Consider the following mechanical diagram.
What does force balance say about this system? It says that the sum of the forces is equal to
mass times acceleration, so we get
F
3
+ F
4
F
1
F
2
= m v
m
where v
m
is the velocity of the mass. Note the negative signs in front of F
1
and F
2
, both of which
are dened to be positive whenever the spring is extension or the damper is extending; in the force
balance equation these forces must have a negative sign in front of them since the force acting on
the mass is to the left whenever F
1
and F
2
are positive.
24
8 Newtons Laws with Several Masses
Last time we learned that Newtons laws with mass lead to second-order ODEs that we convert
into rst-order ODEs with multiple equations. What if we want to go backwards from a rst-order
ODE with multiple equations to a second-order ODE? Using the same example as before, we have
Figure 12: A system with a spring and damper in parallel, attached to a mass with an external
force.
equations of the form
x = v
v = f(x, v)
and since we can take the top equation and take the time derivative of both sides, we know that
x = v x = v x = f(x, x)
which implies that x = f(x, x), which is the equation we started with before. This procedure of
going back and forth between rst-order and second-order ODEs is confusing primarily because it
is so simpleit is just a relabeling trick that you have to get used to.
As an example, consider
y = z
z = ay + bz.
The same trick as before gives us
y = z y = z y = ay + b y.
Last time I talked about Newtons Laws with mass, but how do we model several masses? For
instance, lets say that we have a slinky, but with both the end and the middle bound so that it is
like two massesthis is what I showed you in the lecture. Lets say we have a two mass and three
spring system like the one seen in Fig. 13. Newtons laws tell us that the sum of forces at each
mass must be equal to the mass times the acceleration of each mass, where acceleration is dened
to be positive if the mass is moving to the right and the velocity of each mass is measured relative
to the left wall.

F = m
2
a
2

F = m
4
a
4
Also note that the springs positions are not independent of each other. If the distance between the
walls is L, then the sum of the spring positions needs to be equal to L.
x
1
+ x
3
+ x
5
= L
25
Figure 13: Two masses and three springs
Now, Im going to choose the states of my ODE to be
states: x
1
, v
2
, x
3
, and v
4
.
You could make other choices, like replacing x
3
with x
5
.
Note that
a
2
= v
2
a
4
= v
4
x
5
= L x
1
x
3
v
4
= x
1
+ x
3
x
3
= v
4
v
2
Note that the acceleration of each mass is equal to the time derivative of the velocity of that mass,
and that because v
4
is measured relative to the left wall, it is equal to the sum of the x
1
and x
3
,
which implies that x
3
= v
4
v
2
. Plugging in constitutive laws for Newtons equations gives us
m
2
v
2
= k
1
x
1
+ k
3
x
3
m
4
v
4
= k
3
x
3
+ k
5
x
5
m
4
v
4
= k
3
x
3
+ k
5
(L x
1
x
3
)
To make things simpler, lets set all the spring constants to be the same k and set the masses equal
to 1. If we rearrange this we get a linear, constant coefcient, rst-order differential equation with
four equationsone for each state!
x
1
= v
2
v
2
= kx
1
+ kx
3
x
3
= v
4
v
2
v
4
= kx
3
+ k(L x
1
x
3
)
That is, we have an equation that is of the form
d
dt
(something) = f(something)just like
I mentioned in the rst lecture on Newtons lawsbut the something has four variables instead of
just one. If we made a mistake and made a bad choice of state, we would not be able to get an
ODE with these four variables as the state. As you might guess, if we had lots of masses we would
end up with lots of equations and lots of states, which might make keeping track of things a bit
unmanageablewe are going to address this in Lectures 11 and 12.
26
Things to remember from today: Newtons laws will give you ODEs describing the time evo-
lution of a system that has multiple masses, but the number of rst-order differential equations you
get increases (or goes up) as the number of masses increases. Typically, you should expect to have
two equations for every mass. Lastly, note that in the equation for the masses, the total distance
between walls, L, is playing the role of an external force in the equation, and this is quite common
any time there is a constraint between variablesin this case x
1
, x
3
, and x
5
.
27
9 Imaginary Numbers and Eulers Formula
Last time we learned that Newtons laws give us linear, constant-coefcient, rst-order ODEs
for systems with masses. We know that 1) we want to model mechanical systems using masses,
springs, and dampers; and 2) real systems, like the slinky I showed in lecture, oscillate. However,
I told you in Lecture 5 that we would use exponential solutions for linear, constant-coefcient,
rst-order ODEs, so that should be true here as well. But how do we get an exponential function
like e
ht
to give us cos() and sin()? The answer is that we use the unfortunately named
imaginary numbersplease dont get derailed by the name! The idea is really simple and magical
and very, very cool, and it all hinges on the Taylor seriesone of the few things from calculus I
said you should remember, and this is the moment you need it. We are going to Taylor expand e
ht
and sin(t) and cos(t).
e
ht
= 1 +ht +
1
2!
h
2
t
2
+
1
3!
h
3
t
3
+
1
4!
h
4
t
4
+
1
5!
h
5
t
5
+
1
6!
h
6
t
6

sin(t) = +t
1
3!

3
t
3
+
1
5!

5
t
5

cos(t) = 1
1
2!

2
t
2
+
1
4!

4
t
4

1
6!

6
t
6

The thing to note here is that the sin(t) term has every other termevery odd power of t of
the exponential, and the cos(t) terms have the left over termsall the even powers of t. Moreover,
the signs changesometimes they are plus signs and sometimes they are negative signs. If you
think of this as being a requirement on h, it would imply that
h
0
= 1, h
1
= , h
2
=
2
, h
3
=
3
, h
4
=
4
,
while keeping even powers separate from odd powers.
What function of could force these relationships to hold? Amazingly, the choice of
h = j with j =

1
accomplishes all of this! Plug h = j into the exponential and see what happens. We get the
exponential with powers of j, , and t in the Taylor expansion.
e
jt
= 1 + jt +
1
2!
(j)
2
t
2
+
1
3!
(j)
3
t
3
+
1
4!
(j)
4
t
4
+
1
5!
(j)
5
t
5
+
1
6!
(j)
6
t
6

We know that j =

1, so j
2
= 1, j
3
= j, and j
4
= 1. This gives us a bunch of terms that
alternate sign and half of them include a j.
e
jt
= 1 + jt +
1
2!
(1)
2
t
2
+
1
3!
(j)
3
t
3
+
1
4!
(1)
4
t
4
+
1
5!
(j)
5
t
5
+
1
6!
(1)
6
t
6

If we split these into the terms that have j and the terms that dont have j,
e
jt
=
_
1
1
2!

2
t
2
+
1
4!

4
t
4

1
6!

6
t
6
+
_
+ j
_
t
1
3!

3
t
3
+
1
5!

5
t
5
+
_
we get exactly the Taylor expansion of cos() and sin().
e
jt
= cos(t) + j sin(t)
28
This formula e
jt
= cos(t) + j sin(t) is called Eulers formula and you will use it many times
while taking this course.
Now we get to use Eulers formula when we say that an ODE has an exponential solution.
For instance, looking at a spring-mass system, we get x =
k
m
x. If we plug in an exponential
x(t) = e
ht
wwhere w is some constantwe see that h
2
e
ht
w =
k
m
e
ht
w, so h
2
=
k
m
which
implies that
h =
_
k
m
j.
This means that
x(t) = e
ht
w = e
j

k
m
t
w.
Hence, by Eulers Formula, we know that
x(t) = (cos(
_
k
m
t) j sin(
_
k
m
t))w.
This means we have two possible equationsone with a positive sign and one with a negative sign.
Also, this equation still involves j, which we would like to get rid of because x and v are the state
variables, and x and v do not involve imaginary numbers.
Now remember superposition from Lecture 6. If I have two solutions, I can add them together
and scale them. So
x(t) = (cos(
_
k
m
t) + j sin(
_
k
m
t))w
is one solution and
x(t) = (cos(
_
k
m
t) j sin(
_
k
m
t))w
is another solution. If I multiply both by 1/2 and add them, I just get cos(
_
k
m
t)w. If I multiply
both by 1/2j and subtract them, I get sin(
_
k
m
t)w. So the exponential solution gives me two
types of solutiona cos term and a sin term, just as we hoped! Moreover, any solution can be
written as a constant times the cos term plus a constant times the sin termthese constants will
depend on the initial conditions of the states x(t) and v(t) at t = 0. You will learn how to use
initial conditions to nd these constants in the Exercises following this lecture.
The main thing to remember from today is that the imaginary number j comes from wanting
the exponential function to represent oscillation. With it, we can assume an exponential function
is the solution to a linear, constant-coefcient ODE and we can plug it in to the ODE to obtain
a solution. It is also worth noting that in this class, and in the systems view of an engineered
system, numbers rarely count things. Instead, they are more like adjectives, in that they are used
to describe things.
29
10 Imaginary Numbers Continued
Last time we talked about imaginary numbers and using imaginary numbers as a way of encoding
oscillation into the exponential solution of an ordinary differential equation. But most systems
do not just oscillate foreverthey typically experience decaying oscillation due to damping. For
instance, the slinky I showed in lecture oscillates in gravity. How should we adapt the exponential
solution so that a spring-mass-damper system like this one can decay.
Lets look at our model of the spring-mass-damper again. Again, we have the wall on the left,
a spring, a damper, and a mass at the end, as seen in Fig.14.
Figure 14: Spring-Mass-Damper System
The equations of motion are
x =
k
m
x
b
m
x
and we assume that the solution is of the form of the exponential function
x(t) = e
ht
w,
where w is just a constant.
If we plug this solution into the differential equation abovekeeping it in its second-order
form with two time derivatives of x(t)we get
h
2
e
ht
w =
k
m
e
ht
w
b
m
he
ht
w
and we can factor out the e
ht
term as well as the constant w.
_
h
2
+
b
m
h +
k
m
_
e
ht
w = 0
If w = 0and we know that the exponential is always nonzerothen we know that h
2
+
b
m
h +
k
m
must be equal to zero.
h
2
+
b
m
h +
k
m
= 0
Hopefully, you recognize that this is in quadratic form, so we can use the the quadratic formula
that says that if we have three coefcients , , and , then
h
2
+ h + = 0
implies that
h =

_

2
4
2
.
30
In our case, the quadratic formula tells us that
h =

b
m

_
b
2
m
2
4
k
m
2
.
This means that the h in the exponential solution is a solution to the quadratic formula. Note
that the plus or minus sign means that there will be two solutionsone that corresponds to the
plus sign and one that corresponds to the minus sign. If b = 0, (that is, there is no damper in the
system) this simplies to something we have seen before.
b = 0 h =
_
k
m
j.
This is the same solution that we found last time, so we know that it will give us sin() and cos()
terms and that the system will oscillate forever. However, if b = 0, then something else can happen.
Lets set k = 1 and m = 1. Then we get
h =
b

b
2
4
2
.
If b 2, then h has no imaginary values because the term in the square root is positive. When h
does not have an imaginary number, the system is called overdamped because it will not experience
any oscillations at all. If b < 2, then h will have imaginary values because the term in the square
root is negative. When h does have an imaginary component, the system is called underdamped.
For instance, if b = 3, that implies that
h =
3

5
2
,
so I get two values, neither of which involve the imaginary number j. This will give me an expo-
nential solution of the form
x
1
(t) = e
3+

5
2
t
w and x
2
(t) = e
3

5
2
t
w
depending on the plus or minus. If I instead choose b = 1,
b = 1 h =
1

3
2
=
1

3j
2
,
I get 3 in the square root, so I get the imaginary number j showing up in h. This means that I get
two terms in the exponential solutiona term that includes j and a term that does not.
x
1
(t) = e
1+

3j
2
t
w and x
2
(t) = e
1

3j
2
t
w
Now, remember from calculus that
e
r+s
= e
r
e
s
,
so we can nd out that
e
r+s
= e
r
e
s
e
1+

3j
2
t
= e
1
2
t
e

3j
2
t
= e
1
2
t
_
cos
_

3
2
t
_
+ j sin
_

3
2
t
__
31
so I can separate the terms that involve the imaginary number j from the terms that do not. For
instance, I can take e
(
1
2
+

3
2
j)t
and separate it into e

1
2
t
e

3
2
jt
, and we know that the right hand term
is equal to cos

3
2
+ sin

3
2
j.
Using the same trick as last time to get rid of j, we can conclude that solutions are of the form
of an exponential times cos() and sin() terms.
To visualize this, a plot of e

1
2
t
cos (

3
2
t)w (where I have set w = 1) might look like a com-
bination of the exponential plot and the cos() plot. Together, they would look like a decaying
oscillation.
+
=
Figure 15: An exponential times a cosine is a decaying cosine curve.
What should you remember from today? Remember that exponential solutions can both repre-
sent oscillation and decaying oscillation.
Example: Consider again the following mechanical diagram.
32
Figure 16: One mass with four elements attached to it
If k = 1 and m = 2, for which values of b will this system have oscillations (assuming the
system does not start in steady-state)? First, we need to nd a differential equation.
As before, force balance gives us
F
3
+ F
4
F
1
F
2
= m v
m
where v
m
is the velocity of the mass. Choosing states x
1
and v
m
, we get
x
1
= v
m
v
m
=
k
m
x
1

b
m
v
2
+
k
m
x
2
+
b
m
v
4
=
k
m
x
1

b
m
v
m
+
k
m
(x
1
) +
b
m
(v
m
)
=
2k
m
x
1

2b
m
v
m
.
Hence, we know that x
1
+
2b
m
x
1
+
2k
m
x
1
= 0. Choosing k = 1 and m = 2, and plugging in
x(t) = e
rt
A as a solution, we get
(r
2
+ br + 1)e
rt
A = 0.
Hence, from the quadratic formla,
r =
b

b
2
4
2
.
From this we can conclude that oscillations occur whenever 0 < b < 2.
33
11 Vector and Matrix Representations
So far, we have only worked with very, very simple systems. But you can imagine that if we have
lots of springs, dampers, and masses all connected togetherlike the slinky I used in the class
lecture where I connected several sections togetherthen we have an ordinary differential equation
that has a separate equation for every state. Here is where things might get a bit complicated; and,
therefore vector and matrix representations become really useful. You should think of these as
largely being useful notation; that is, vector representations and matrix representations of ordinary
differential equations primarily serve as a way of organizing information in a nice, convenient way
that helps with computations.
Lets say we have a linear, constant coefcient, rst-order differential equation that has states
x, y, and z.
x = x +2y +3z
y = y +4z
z = x +z
I have spaced these numbers and letters in a way that will help us in a moment. You can imagine
that if I had fty or a hundred or a thousand states here, this could become very challenging to
manage. Im going to group the states into a single vector
_
_
x
y
z
_
_
and by denition the time derivative of this vector of states is equal to the vector of time derivatives
of the states.
d
dt
_
_
x
y
z
_
_
=
_
_
x
y
z
_
_
So far, I have not done anything very interestingIm just putting variables into a list. Now comes
the useful part. Im going to dene a matrix to be an array of numbers, like
A =
_
_
1 2 3
4 5 6
7 8 9
_
_
.
This is a matrix that has three rows and three columns, with a total of nine numbers.
Our goal is to dene some notion of multiplication between the matrix A and the vector of
states so that if I take
A
_
_
x
y
z
_
_
I will get the right hand side of the differential equation. In fact, if I just relabel the state vector as
w =
_
_
x
y
z
_
_
, I can write Aw to represent the multiplication.
34
The right way to dene multiplication between A and w is to take elements of the rows of A
and multiply them by their corresponding elements of the state vector and sum them together. For
instance, if I take the A matrix I just dened and multiply A and w, I get
Aw =
_
_
1 2 3
4 5 6
7 8 9
_
_
_
_
x
y
z
_
_
=
_
_
1 x + 2 y + 3 z
4 x + 5 y + 6 z
7 x + 8 y + 9 z
_
_
Note that the result is a vector again, so multiplying a matrix times a vector gives a vector. Now,
lets go back to the differential equation and see how we could choose different values in the com-
ponents of A so that we get the right hand side of the differential equation we started with. The
idea is to choose the elements of A so that when you multiply A and the state vector you get the
right hand side of the differential equation.
If you look at how I wrote the differential equation in the rst place, it is reasonably easy to do
this. In particular, if I choose
15
A =
_
_
1 2 3
0 1 4
1 0 1
_
_
Aw =
_
_
1 2 3
0 1 4
1 0 1
_
_
_
_
x
y
z
_
_
=
_
_
1 x + 2 y + 3 z
0 x + 1 y + 4 z
1 x + 0 y + 1 z
_
_
I get Aw equal to a vector that is exactly the right hand side of the differential equation.
This has important consequences, because now I can rewrite the differential equation as
w = Aw.
This is exactly the same equation as the one I started with, but with a different notation being used.
Now, how is this useful? Lets think back to Lecture 4. Id like to use this vector and matrix
notation in my Euler integration code. The initial condition for the differential equation needs to
include initial conditions of all the states
w
0
=
_
_
x
0
y
0
z
0
_
_
and Euler integrationexpressed in terms of vectors and matriceswill look like
w(t + dt) = w(t) + dtAw(t).
The great thing about this formula is that once you have the matrix A, the code for your Euler
integration will always look the same! As an example, lets look at the vector and matrix notation
for the spring-mass system. We know from Lecture 7 that we get a second-order differential
equation
x =
k
m
x
15
Choosing the elements of A comes down to just reading off the coefcients of x, y, and z in each element of the
vector, but this often is not obvious at rst.
35
Figure 17: A spring-mass system
and if we rewrite that equation in rst order form we get two rst-order differential equations with
a state of position x and velocity v.
x = v
v =
k
m
x
If we set w =
_
x
v
_
, and choose A =
_
0 1

k
m
0
_
, then Aw gives us the right hand side of the
differential equation.
Lets say that x
0
= 0.5 and v
0
= 0 and we want to use this vector notation in Euler integration
with a time step of dt = 0.1. We set w
0
to be the vector of intial conditions of the two states and
then
w
0
=
_
x
0
v
0
_
w(0.1)
_
0.5
0
_
+ 0.1
..
dt
_
0 1

k
m
0
_ _
0.5
0
_
=
_
0.5

k
20m
_
If I multiply this out, I get an approximation of w(0.1). Just as in Lecture 4, we can repeat this
process as many times as we like to get an approximate solution of the differential equation at any
time.
What should you remember from today? Vector and Matrix representations are really, really
useful for organizing information. The more complex a system is, the more useful this notation
becomes. If you nd yourself dealing with really complicated systems a lotand as engineers we
use them all the timeyou probably will eventually want to take a class that focuses on them. But
for now, just think of them as a notational convenience that simplies your life.
Example: Consider (again!) the mechanical diagram.
Figure 18: One mass with four elements attached to it
36
We already saw that if we choose states x
1
and v
m
, we get
x
1
= v
m
v
m
=
k
m
x
1

b
m
v
2
+
k
m
x
2
+
b
m
v
4
=
k
m
x
1

b
m
v
m
+
k
m
(x
1
) +
b
m
(v
m
)
=
2k
m
x
1

2b
m
v
m
.
How can we write this as a vector-valued differential equation? Lets choose the state vector x to
be x =
_
x
1
v
m
_
. Then the choice of
A =
_
0 1

2k
m

2b
m
_
makes x = Ax equivalent to the ODE above because
x = Ax =
_
0 1

2k
m

2b
m
_ _
x
1
v
m
_
=
_
v
m

2k
m
x
1

2b
m
v
m
_
.
37
12 Vector Solutions to Ordinary Differential Equations
Last time we learned that vector and matrix representations can make your life easier, specically
when you implement Euler integration for a complicated system involving many states. But how
do we use vector and matrix representations to nd analytic solutions?
Lets say we have a spring-mass-damper system like the one with three masses in lecture that I
created by portions of the slinky together.
How many states would we expect? We should have six states totalthree for the positions
of each spring and three for the velocities of each mass. This means that the vector and matrix
representation would include a state vector that has six componentsthe six statesand a matrix
that has six rows and six columns. What type of solution to the differential equation w = Aw do
we expect? Hopefully, you are expecting an exponential soluton!
w(t) = e
ht
w
0
Keep in mind that this exponential solution is a vector because w
0
is a vector. However, the
exponential term itself is still just a number for any given t. If I plug this exponential into w = Aw,
I get
w = Aw
d
dt
_
e
ht
w
0
_
= Ae
ht
w
0
If I then differentiate, I get
he
ht
w
0
= Ae
ht
w
0
Note that h is a number, e
ht
is a number, w
0
is a vector, A is a matrix, e
ht
is again a number, and
w
0
is again a vector.
h
..
number
e
ht
..
number
w
0
..
vector
= A
..
matrix
e
ht
..
number
w
0
..
vector
If I divide both sides by the exponential term (which is nonzero, so I am allowed to do so), I see
that
hw
0
= Aw
0
.
This is a special situation where a matrix Amultiplying the vector w
0
is the same as just multiplying
that vector by h! Such a vector is called an eigenvector of A and h is called an eigenvalue of A. If
there are n states there will always be n eigenvector-eigenvalue pairs.
The nice thing about this is that you can use MATLAB or Python to calculate eigenvector-
eigenvalue pairs easily!
Lets go back to our spring-mass-damper system and assume that the damping is reasonably
Figure 19: spring mass damper system
38
high, giving us an A matrix of
A =
_
0 1
1 3
_
To use an exponential solution, we need to solve Aw
0
= hw
0
, so I use MATLAB to compute
the eigenvectors and eigenvalues. (See the lecture video for an example of this.) MATLAB returns
an eigenvector-eigenvalue pair.
w
0,1
=
_
0.4
1
_
h = 2.6
w
0,2
=
_
2.6
1
_
h = 0.4
(Note that I have scaled these to make the second component equal to one in each case. I can do
this because any scalar multiple of an eigenvector is also an eigenvector.)
What does this tell us? It says that if
w
0,1
=
_
0.4
1
_
w(t) = e
2.6t
_
0.4
1
_
and if
w
0,2
=
_
2.6
1
_
w(t) = e
0.4t
_
2.6
1
_
Moreover, if w
0
is three times one of these vectors, then I would just multiply that exponential
solution by three because of superposition.
Lastly, if
w
0
=
_
3
2
_
,
that is, w
0
is the sum of the two eigenvectorsthen the solution would be the sum of the two
exponential solutions!
w
0
=
_
3
2
_
= w
0,1
+ w
0,2
w(t) = e
2.6t
_
0.4
1
_
+ e
0.4t
_
2.6
1
_
This example suggests that we should be able to compute any solution of a differential equation
from the exponential solutions for each eigenvector-eigenvalue pair, which is in fact true!
What should you remember from today? Remember that vector and matrix representations
are useful for computing analytical solutionsas well as Euler integrationfor complex systems
with many states. And remember that eigenvectors and eigenvalues provide the means by which
we compute those solutions as exponential solutions.
39
Superposition in Vector Linear ODEs with Complex Eigenvalues
On the previous page, and in the lecture video, I talk about superposition of solutions to ODEs
when the eigenvalues are real-valued, but I dont say anything about what happens when the eigen-
values are complex. The amazing thing is that nothing changes! Let me do an example to convince
you of why this makes sense.
Lets take a spring-mass system as an example with k = m = 1. We know that x = x and
that in rst-order form this is x = v, v = x. So we can write it as
w = Aw, where A =
_
0 1
1 0
_
.
The eigenvalues/eigenvector pairs are
r
1
= j, w
1
=
_
j
1
_
and r
2
= j, w
2
=
_
j
1
_
.
We know that we therefore get two solutions:
x
1
(t) = e
jt
w
1
and x
2
(t) = e
jt
w
2
.
Moreover, we also know from Eulers formula that
e
jt
= cos(t) + j sin(t) and e
jt
= cos(t) j sin(t).
How can we now construct real-valued solutions from x
1
(t) and x
2
(t)? Specically, how can we
use superposition to construct real-valued solutions from x
1
(t) and x
2
(t)? By superposition, we
can add and scale x
1
(t) and x
2
(t), so consider the following quantities:
j
2
(x
1
(t) x
2
(t)) and
1
2
(x
1
(t) + x
2
(t)).
The expression
j
2
(x
1
(t)x
2
(t)) simplies to the vector
_
cos(t)
sin(t)
_
while the expression
1
2
(x
1
(t)+
x
2
(t)) simplies to
_
sin(t)
cos(t)
_
. Both of these are real-valued andagain, by superpositionare
solutions to the ODE. Just as importantly, they are what we should expect from plugging the ex-
ponential solution into the second-order system x = x.
Example: Now assume that w(0) =
_
1
0
_
. What is the analytic solution for w(t)? It must be
of the form a
1
_
cos(t)
sin(t)
_
+ a
2
_
sin(t)
cos(t)
_
, but what are the constants a
1
and a
2
? At t = 0, this
simplies to a
1
_
1
0
_
+ a
2
_
0
1
_
, so
_
a
1
a
2
_
=
_
1
0
_
. Therefore, we get that a
1
= 1 and
a
2
= 0 and w(t) =
_
cos(t)
sin(t)
_
.
40
Why We Use Exponential Solutions
A very reasonable question that comes up is what is so special about e
rt
? Why not use a different
number than e, like 2.5 or or something else? And why an exponential? Why not arctan(rt) or
sin(rt)? There are a couple of ways of understanding answers to this question, but I want to focus
on one in particularthe question of existence and uniqueness of ordinary differential equations.
Mathematicians can tell us that if we have an ordinary differential equation
x = f(x, t) and x(0) = x
0
,
the solution both exists and is unique if f satises certain properties. (Roughly speaking, these
properties are that the rst derivative of f with respect to x and t exists; however, the actual
conditions are more general.)
Our case of x = Ax (and later x = Ax+Bu(t)) with x(0) = x
0
always satisfy these conditions
because

x
Ax = A (so the derivative of f with respect to x exists and is A). We therefore can
conclude both that a solution to x = Ax exists and that it is uniqueno other solution can exist
once we have found one. Why does this matter?
We know, fromthe previous sections, that we can construct solutions to x = Ax with x(0) = x
0
using exponential solutions. In fact, by solving for eigenvalues and eigenvectors, we can get a
solution for any choice of initial condition. And once we have that solution, there cannot be
another solution with the same initial condition. So no other choice of function could work, unless
it was the same as an exponential function.
41
13 Chemical Diffusion and Ficks Law
For the last 12 lectures we have been learning about mechanical systems and how to model me-
chanical systems that have linear constitutive laws relating mechanical variables, like position x
and velocity v, to forces. Today we are going to start in a new areachemical systemswhere
we will see that many of the lessons we learned from mechanical systems also apply in chemical
diffusion.
To understand the question we are going to try and answer, it is helpful to visualize a tank of
water that has uid in it. The tank has length, depth, and width, but we are only going to consider
the uid in one dimension along its length which we will call x. If there is a chemical in the
uid, the concentration C of that chemical can change as a function of position in the tank; that is,
C can depend on x, so we will denote it by C(x). However, the concentration C(x) is assumed
not to vary with width or depth. We can plot C(x) over the tank, so that the value of the curve
represents the concentration of the chemical at the position x.
For today, we are going to assume that the chemical is at equilibrium, meaning that the con-
centration throughout the tank is allowed to vary as a function of x but is not allowed to vary with
time. Also, we are going to assume that the volume, V , of the tank stays constantbecause it
makes things easier.
Note that as a result of the equilibrium assumption, the amount of mass in any given volume V
is constant.
16
16
(because m
total
=
_
V
C(x)dxdydz, so if C(x) is not changing with time, m
total
is not changing with time either)
42
Also note that if I draw in two positions x
1
and x
2
, I get that the volume between them is
V = Adx, where A is the cross-sectional area in the width-depth plane of the tank and dx is the
difference between x
1
and x
2
.
If there are no reactions taking place and there is no accumulation of the chemicalfor in-
stance, the chemical is not precipitatingthen conservation of mass implies that the amount of
mass going into the volume V must be equal to the mass leaving V . We call the rate at which mass
enters the volume the ux F, which generally varies with x. We dene the ux to be positive at
a particular location x
1
if there is mass of the chemical diffusing from left to right at x
1
. Hence,
conservation of mass implies that the ux F(x
1
) of chemical into V at x
1
must be the same as the
ux F(x
2
) of chemical out of V at x
2
; that is, F(x
1
) = F(x
2
).
Now we ask the question: What drives the uxwhat makes it positive or negative? If
C(x) = constant, then the concentration is the same everywhere and we do not expect any ux
of chemical. To understand this, think about the milk that I poured into my coffee in lecture; if
the coffee is stirred and the milk is equally dispersed throughout the uid, it would be very strange
to have the milk start diffusing so that it was at a higher concentration in one place than another.
Therefore, we dont expect F(x) to depend on the absolute amount of chemical present. Said in
terms we have used before in mechanical systems, we dont expect a constitutive law of the form
F(x) = DC(x)where D is some constantbecause that would imply that positive concentra-
tion leads to positive ux of the chemical to the right in the diagram.
Instead, if there is more chemical to the right, we expect the chemical to diffuse to the left.
Alternatively, if there is more chemical to the left, we expect the chemical to diffuse to the right.
17
The next simplest choice we can make is to propose that at a given x (say, x
1
or x
2
in the gure),
the propensity of the chemical to ow in the positive x direction is a function of the derivative
dC(x)
dx
of C rather than C(x). And, thinking back to mechanical systems, the simplest choice we
could make is to make the constitutive law be linear with respect to the derivative of C. Lastly,
what should the sign of the constant be? Well, if the concentration being higher to the right implies
ux to the left, the constant must have a negative sign.
These observations put together are called Ficks law, which states that
F(x) = D
dC(x)
dx
A
, where D > 0 is the constant of proportionality and A is again the cross sectional area (since ux
is occuring everywhere in that cross sectional area). It is worth noting that just like in mechanical
systems, this linear relationship only occurs because we have a highly controlled environment
the uid is still, it is probably very uniform, and the chemical being introduced is also uniform.
If this were a natural system, with all the environmental factors that could be introduced, a linear
relationship between ux and the derivative of concentration with respect to position x probably
could not be expected.
What should you remember from today? The key thing is that diffusion is driven by ux, and
the simplest model of ux is called Ficks Law.
17
Keep in mind that despite the fact that there is ux, the concentration is assumed to be in equilibriumC(x) is
still constant with respect to time even though individual atoms of chemical are diffusing across the boundaries.
43
14 The Diffusion Equation with No Accumulation
Last time we discussed Ficks law and how ux is related to the derivative of concentration with
respect to the position x. We also discussed that this linear constitutive law holds because the uid
is very controlledthis is not a natural diffusion process that might have many nonlinearities and
higher-order effects involved. Instead, it is a model of a very controlled process, and we are going
to explore what that means today in the context of diffusion in equillibrium.
Lets look at our picture of Ficks law again.
We have a tank and two positions in that tank x
1
and x
2
that are very close to each other separated
by a distance dx. By the assumption that the concentration is in equillibriumthat C(x) is constant
with respect to timewe know that the mass of chemical in the small volume between x
1
and x
2
is constant. How can we use the fact that
F(x
1
) = F(x
2
)
and
F(x) = D
dC(x)
dx
A?
We just plug in to the equillibrium statement (keeping in mind that this implies mass is conserved
in any volume).
F(x
1
) = F(x
2
)
D
dC(x
1
)
dx
A = D
dC(x
2
)
dx
A
D[
dC(x
2
)
dx

dC(x
1
)
dx
]A = 0
Now, since D > 0 and A > 0, in this case we can divide them out of the equation. Moreover, we
can do something kind of trickywe can divide both sides by dx (which is also positive). Really,
this is a trick! There is no way you could guess to do this, but we will see later in Lecture 16 that
this step is actually pretty natural.
dC(x
2
)
dx

dC(x
1
)
dx
dx
= 0.
44
If we take the limit as dx 0, this becomes the second derivative of C(x) with respect to x.
Equilibrium Diffusion Equation with no accumulation
d
2
C(x)
dx
2
= 0
This equation is called the diffusion equation. It is also called the heat equation because heat
distributes through a body in the same way. Now remember, this version of the diffusion equation
does not include any reaction or accumulation and assumes equilibrium.
Notice that this equation does not depend on C(x), only on derivatives of C(x). Hence, solu-
tions are reasonably easy to guesswhat curve has zero as its second derivative? Straight lines!
Figure 20: If C(0) = 5 and C(1) = 1, then the diffusion equation with no accumulation in
equilibrium predicts that C(x) = 5 4x.
As an example, if you know that a tank has the concentration regulated to be C(x = 0) = 5
and C(x = 1) = 1, then the diffusion equation says that
d
2
C(x)
dx
2
= 0,
which implies that
C(x) = ax + b.
The concentration at x = 0 is 5, so b = 5 and the slope between x = 0 and x = 1 is 4, so
a = 4. Hence, the concentration, according to the diffusion equation, will be
C(x) = 5 4x
for every x. It is worth thinking for a moment about what this means physically. The derivative
of the concentration with respect to x is equal to 4 everywhere. Hence, there is ux into the
tank at x = 0 and there is ux out of the tank at x = 1. We dont know why or how that ux
is occurring, we simply know it is occurring. It is probably occurring because of some form of
engineered process control.
Now think about the small volume we started with. Even though there is ux into the tank and
ux out of the tank, the mass of chemical in the small volume really is constant, because the ux of
45
chemical into the small volume is the same as the ux of chemical out of the small volumethis
is because we took the limit as dx 0.
18
Lastly, what if there were no ux in and no ux out of the tank? Then that would mean
that D must be equal to zero because of Ficks law, so the the solution would be a at linethe
concentration would be the same everywhere. This is just what we saw in my coffee in lecture
that at equilibrium the concentration of milk in the coffee is the same everywhere.
What should you remember from today? The diffusion equation in equillibrium with no
accumulation is the second derivative of the concentration with respect to position x. When you
solve the diffusion equation, you get a prediction of the concentration everywhere in the tank by
only knowing what is happening at the edges of the tank. Next time we are going to talk about
what happens when there is accumulationwhere for some reason the chemical is accumulating
or being taken out of the uid everywhere.
18
This is true, but for the case where the concentration C(x) is linear taking the limit does not matter.
46
15 The Diffusion Equation with Accumulation
Last time we talked about the diffusion equation in equillibriumwhich means that the concen-
tration does not change with timeand without accumulation. Today we talk about the case
where there is accumulation. Accumulation can happen because the chemical precipitates out
of solutiona simple example is rain falling out of a cloud, which of course decreases the concen-
tration of water vapor because it has changed into water droplets. Another example is something
that many of us did as childrenmaking candy out of a sugar water solution, where as the sugar
crystalizes the concentration of sugar in the water must go down.
What changes if there is accumulation at rate a? That is, at every point in the uid the chemical
is either being generatedmeaning positive accumulationor destroyed/precipitatedmeaning
negative accumulationat some rate a. The main thing that changes is the conservation of mass
statement.
For the volume
V = Adx,
we have three terms affecting the total mass in the volume. First, the term
Accum = aAdx
is the accumulation term that is either adding or removing the chemical everywhere in that volume.
Second, there is the ux F(x
1
) and lastly there is the ux at F(x
2
). Now here is the unintuitive
partwe are assuming that the chemical process is in equilibrium, so the the total mass in V still
stays the same. Hence, we we get
Accum + F(x
1
) = F(x
2
).
Now, we proceed just like we did last time by replacing the ux terms with Ficks law
aAdx D
dC(x
1
)
dx
A = D
dC(x
2
)
dx
A
and then we divide by A and dx, just like we did in Lecture 14.
a D
dC(x
1
)
dx

dC(x
2
)
dx
dx
= 0.
Again, taking the limit as dx 0, we get
Equilibrium Diffusion Equation with accumulation
a + D
d
2
C(x)
dx
2
= 0
This is called the equilibrium diffusion equation with accumulation. Note that this implies a
new type of solution, generally not a line.
If a is constant everywhere in the uid, what curve C(x) has a second derivative that is con-
stant? A parabola! Think for a moment about what this means. The equation says that the parabola
47
will be concave down if a is positive, and concave up if a is negative. This makes sense because
the only way that total mass can stay constant when a is postive is if the chemical is being removed
at the boundaries of the tank. That should mean that in equilibrium the concentration is higher in
the middle than it is near the edges. Indeed, if we assume that C(x = 0) = 1, C(x = 1) = 1,
a = 1, and D = 1, we get a parabola for C(x).
Figure 21: If there is constant accumulation throughout the uid at a rate a, then the resulting C(x)
will be a parabola.
What happens when a is not constant as a function of x? This can happen for any number of
reasonsmaybe sunlight is heating part of the tank but not the rest of it, so there is a temperature
gradient in the uid causing more accumulation in hotter places. Then we have
a(x) + D
d
2
C(x)
dx
2
= 0.
If, for instance, a = kx, then the solution would be cubic in x. You will look at an example of this
in the homework.
Lastly, what happens if a is allowed to depend on C(x) rather than x? This might happen when
the ability to accumulate a chemical is dependent on how much is already there, which is what we
mean by a solution becoming saturated. Then we have a diffusion equation of the form:
a(C(x)) + D
d
2
C(x)
dx
2
= 0.
If, for instance, a is proportional to C(x) (i.e., a(C(x)) = kC(x)), then we have the equation
D
d
2
C(x)
dx
2
+ kC(x) = 0

C =
k
D
C.
If you rewrite this as D

C + kC = 0, you might more easily recognize this as a linear,
constant-coefcient second-order differential equation that is exactly the same as the spring-mass
system we have seen before, where the independent variable is now x instead of t. You know the
solution to this from mechanical systemsthe solution of this differential equation will involve
sin() and cos() terms (that depend on x, not t). You will do an example of this as well in the
homework.
What should you remember from today? Remember that introducing accumulationwhich
is often the goal of a chemical engineerwill generally lead to solutions that are not straight
lines, but often times you have all the tools you need to solve the differential equation. Next time
we are going to look at what happens when the system is not in equillibrium. Even though that
48
Figure 22: A spring mass system
makes things more complex mathematically, my suspicion is that you will nd the predictions
more intuitive!
Examples:
Look at the gures below.
Where is the ux positive? Where is the ux negative? And where is the accumulation positive?
Where is accumulation negative? Remember that both the equillibriumdiffusion equation and your
physical intuition should agree.
Something that is easy to forget is that ux does not imply motion of the uid. One can have
ux into the tank, like the gure on the left, without implying that uid is moving into the tank.
For all the examples that we consider, the amount of uid is constant, even if there is ux in and
out of the tank.
49
16 Time-Varying Diffusion
Last time we talked about diffusion processes with accumulation. But everything we have talked
about up until this point is dependent on the idea that the concentration is in equillibrium. However,
most of our experience with diffusion is not in equillibriumwhen I drop dye in water I see that
the concentration of the dye changes as a function of time! This is a great example of where
synthesis of your Physical Knowledge into Analytical Reasoning and Computational Skills plays
a really important role in your engineering judgment, because you simply have to be able to think
about what you expect prior to nding a solution.
Today we are going to develop a way of modeling time-varying diffusion. To make the devel-
opment as simple as possible, we are going to assume that there is no accumulation, but that the
concentration is allowed to change in time.
Lets look at our example of a tank with uid and some chemical in the tank. We still have the
same basic components as beforea very small volume V with ux in and out of the volume.
Now, however, we are going to allow the mass in that volume to change as a function of time. The
mass in a small volume is the concentration times the volume
C(x)V = C(x)Q
0
dx
and the only thing that could lead to the mass changing in that volume is if the ux in and the ux
out are not the same. Hence

t
(C(x)Q
0
dx
. .
mass
) = F(x
1
) F(x
2
)
= D
C(x
1
)
x
Q
0
(D
C(x
2
)
x
)Q
0
= D
_
C(x
2
)
x

C(x
1
)
x
_
Q
0
where I have used the partial derivative notation for the derivative of C with respect to t and the
derivative of C with respect to x.
This equation implies that we can divide by Q
0
and divide by dxrecall that we did this before
in Lecture 14, but without any real reason or explanation. Taking the limit as dx 0, we get that
the time derivative of C is equal to D times the second derivative of C with respect to x.
50
Time-Varying Diffusion Equation with no accumulation
C(x)
t
= D

2
C(x)
x
2
Note that there are derivatives both with respect to time and with respect to position. Because
of that, this equation is called a partial differential equation or PDE for shortthis is why I used
the partial derivative notation earlier. PDEs are often very challenging to solve, and in general we
cannot expect to have e
ht
, with sin() and cos() terms showing up as solutions. Also, the initial
condition for this problem is a curve rather than a number.
That is, at time t = 0, the concentration might look like
so that there is a lot of chemical in the left and less in the right part of the tank. If there is no
ux of chemical into or out of the tank, we might expect as time progresses this nonequillibrium
initial condition to approach a solution where C(x) is at and the chemical has diffused everywhere
equally.
However, if we make two assumptions, we can make a lot of progress. First, assume that
that the tank is innitely wide x [, ]this is reasonable even if the tank is simply very
largeand secondly assume that the chemical starts out all in one place, perfectly concentrated at
a particular position x. These assumptions model the situation where you drop a single drop of
chemical into a very large tank and we are now asking how that single drop will diffuse through
the tank as a function of time. If I drop just one small drop of milk into my coffee cup, it takes a
while for the walls of the coffee cup to matter in the diffusion of the milk.
It turns out that with these assumptions we again get an analytical solution that is of the form
of an exponential.
C(x, t) = Q
0
1

4Dt
e
x
2
4Dt
This equation solves the diffusion equation for any constant Q
0
, which will depend on how much
chemical there was in the drop.
Some things to note about this equation include that at t = 0 the coefcient of the exponential
term is innitethis is why we assume that the chemical is all in one place at time t = 0. After
time t = 0, the coefcient multiplying the number goes down and the curve C(x) becomes broader
as the chemical diffuses away from the point it started.
51
How would you verify that C(x, t) solves the differential equation? Plug into the time-varying
diffusion equation and nd out that the time derivative of this equation is equal to D times the sec-
ond derivative with respect to the position x. Verifying that this function is a solution is something
you will consider more in the Exercises following this lecture.
You might notice that this function is related to the Gaussian distribution
1

2
e

1
2
(x)
2

2
where is the mean and
2
is the variance. This will turn out to be useful in the Demonstration
that we are going to do for chemical diffusion.
Lastly, notice that the time-varying diffusion equation is in fact a linear differential equation.
That means that it satises the principle of superposition, which means you can take several of
these exponential curves and add them together in order to construct a more complex solution
involving chemical starting out in several positions x in the uid.
What should you remember from today? You should remember that when a diffusion process
is not in equilibrium and there is no accumulation, the time-varying diffusion equation provides
us with a way of approximating how the chemical will diffuse over time throughout the uid.
However, this model requires two relatively strong assumptionsnot all systems, even engineering
systems, will satisfy the assumptions we made!
52
17 The Convolution Equation
So far we have talked about mechanical systems and chemical systems, and we have learned that
linear, constant-coefcient differential equations describe these systems in many settings. In both
cases, and soon in electrical systems, external signals also can affect behavior. In mechanical
systems this was in the form of a force, while in chemical systems the external signal was in the
form of the accumulation.
For instance, the slinky I showed in lecture has a single mass in the middle that has a frequency
of oscillation based purely on the mass, spring constant, and damping constant. However, when
I started to force one end of the slinky, the mass started to move in a way that depended on how
I was forcing it. Today we are going to learn about the convolution equationthis provides us a
notion of superposition with respect to external signals, like the one I created with my hand for the
slinky example.
Lets assume that we have a single variable x and a linear, constant coefcient ordinary differ-
ential equation with A a number, B a number, and u a signal that is forcing the system.
x = Ax + Bu
The solution to this ODE is
x(t) = e
At
x
0
+
_
t
0
e
A(t)
Bu()d
this is called the convolution equation. Now, this is a pretty scary equation because it has an
integral in it, but lets spend a moment to look at each component. The left hand side of x(t) is
just the exponential times the initial conditionthis is the state evolution if there were no external
signal u(t) and is called the transient response. It should look familarit is just the exponential
solution for the ODE when there is no external signal. The right hand side involves an integral from
0 up until time t and does not include x
0
, but does include uit is called the steady state response.
How does one actually compute this solution? You dont typically take the integralinstead, you
use Euler integration or some other integration scheme for the ODE.
How should we conrm that the convolution equation is actually a solution to the ODE? We
plug it in and show that the time derivative is equal to Ax + Bu.
d
dt
(x(t)) = Ae
At
x
0
+ A
_
t
0
e
A(t)
Bu()d +
=1
..
e
A(tt)
Bu(t)
. .
from Leibniz rule
= Ax + Bu
Taking the time derivative of the left hand side just drops down an A, while taking the time deriva-
tive of the right hand side is a bit trickier. The key thing is that t shows up in two placesin the
boundaries of the integral and in the expression being integrated. This means there are two parts
of the derivativethe rst one comes from differentiating inside the integral and the second one
comes from Leibniz rule, which was one of the rules from calculus I told you that you would need.
Grouping the expressions allows us to conclude that x(t) indeed does solve the ODE. What
does this equation mean? First, it means that we can separate the effect of the initial condition
53
from the effect of the external signal. Secondly, it means that we have superposition for external
signalsif I give you two signals u
1
(t) and u
2
(t), you can nd the state trajectory for each one
and then add them to nd the state trajectory for u(t) = u
1
(t) + u
2
(t).
Figure 23: spring damper system with external force
To make this more clear, lets look at an example. Lets go back and look at the spring-damper
system from Lecture 3 with an external force and an initial condition of x
0
= 0. Lets assume that
F
ext
= sin(2t)a 1 Hz signal. This system has the ODE
x =
k
b
x +
sin(2t)
b
.
The convolution equation tells us that this ODE has the solution
x
1
(t) = e

k
b
t
x
0
..
=0
+
_
t
0
e

k
b
(t)
1
b
sin(2)d.
Moreover, if we instead say that F
ext
= cos(4t)a 2 Hz signalthen the convolution equations
says that the solution to the ODE is
x
2
(t) = e

k
b
t
x
0
..
=0
+
_
t
0
e

k
b
(t)
1
b
cos(4)d.
Hence, the convolution equation tells us how to solve for the state evolution for both external
signals. Now, what happens if F
ext
= sin(2t) + cos(4t)? Then we get
x(t) =
_
t
0
e

k
b
(t)
1
b
(sin(2) + cos(4)) d
=
_
t
0
e

k
b
(t)
1
b
sin(2)d +
_
t
0
e

k
b
(t)
1
b
cos(4)d
= x
1
(t) + x
2
(t)
That is, we get that x(t) can be obtained either by simulating the system again with an input
F
ext
= sin(2t)+cos(4t) or you can take your solutions for F
ext
= sin(2t) and F
ext
= cos(4t)
and simply add them together! The convolution equation is valid for vector-valued ODEs as well,
but then the e
A
term means something slightly different.
What should you remember from today? Remember that for a linear, constant coefcient, rst-
order ordinary differential equation with an external signal, the convolution equation gives us a
type of superposition principle that includes both initial conditions and external signals.
Example: Suppose x = x + sin(t). Write the solution for x(t) given x
0
= 1. (It may be helpful
to know that
_
t
0
e
(t)
sin()d =
1
2
(e
t
+ sin(t) cos(t)).) Using the convolution equation, we
nd that x(t) = e
t
+
1
2
(e
t
+ sin(t) cos(t)).
54
The Vector-Valued Convolution Equation
In the previous section, we assumed that x is a scalar-valued quantity, which naturally leads to the
question of how to obtain solutions for differential equations of the form x = Ax +Bu where x is
a vector. To think about this, look again at the convolution equation.
x(t) = e
At
x
0
+
_
t
0
e
A(t)
Bu()d
Nothing about this equation is particularly specic to a scalar-valued choice of x(t). If we let
u be 1 1 dimensional, B be n 1 dimensional, x
0
be n 1 dimensional, and e
At
be n n
dimensional, all of the multiplication is at least dimensionally possible. But what does it mean to
take the exponential of At when A is a square matrix?
Assume, for concreteness, that A =
_
a b
c d
_
. What do we want to mean by e
At
? To me, the
most natural operation is something like
e
At
=
_
e
at
e
bt
e
ct
e
dt
_
.
But this does not turn out to be the right idea, largely because then our proof of why the convolution
equation is a solution to the differential equation x = Ax+Bu no longer holds.
19
As an alternative,
let us try to use the Taylor series to extend the exponential function to a matrix. In the scalar case,
we know that for a scalar a we have
e
at
= 1 + at +
1
2!
a
2
t
2
+
1
3!
a
3
t
3
+
1
4!
a
4
t
4
+
1
5!
a
5
t
5
+
1
6!
a
6
t
6
+ .
If we replace the 1 with the identity matrix I
nn
and replace a with A, we get a well-formed
equation
e
At
= I
nn
+ At +
1
2!
A
2
t
2
+
1
3!
A
3
t
3
+
1
4!
A
4
t
4
+
1
5!
A
5
t
5
+
1
6!
A
6
t
6
+ .
That is, all the matrix multiplications are dimensionally consistent and the addition is always di-
mensionally consistent (e.g., A
3
and A
3
are both square matrices of dimension n n and can
therefore be added together).
At this point, we really have no reason to think that this Taylor series denition of e
At
is any
more useful than e
At
=
_
e
at
e
bt
e
ct
e
dt
_
, but we can nd out if it is useful by looking at its derivative.
Taking the derivative of this denition of e
At
with respect to t, we get:
d
dt
e
At
=
d
dt
I
nn
+
d
dt
At +
d
dt
1
2!
A
2
t
2
+
d
dt
1
3!
A
3
t
3
+
d
dt
1
4!
A
4
t
4
+
d
dt
1
5!
A
5
t
5
+
d
dt
1
6!
A
6
t
6
+
= A +
1
1!
A
2
t +
1
2!
A
3
t
2
+
1
3!
A
4
t
3
+
1
4!
A
5
t
4
+
1
5!
A
6
t
5
+ .
= A(I
nn
+ At +
1
2!
A
2
t
2
+
1
3!
A
3
t
3
+
1
4!
A
4
t
4
+
1
5!
A
5
t
5
+ )
= Ae
At
.
19
To see this, try and take the same step as we took in the line where A factors out of the integral. If the equation
above is the denition of the matrix exponential, factoring out A is impossible.
55
That means e
At
is a solution to x = Ax with x(0) = x
0
. Moreover, if one now looks back at the
proof that the convolution equation is a solution to the differential equation x = Ax + Bu, one
sees that if one uses the Taylor series denition of e
At
, the steps are exactly the same. Assuming
that x(t) = e
At
x
0
+
_
t
0
e
A(t)
Bu()d, we get that
d
dt
(x(t)) = Ae
At
x
0
+ A
_
t
0
e
A(t)
Bu()d +
=1
..
e
A(tt)
Bu(t)
. .
from Leibniz rule
= Ax + Bu
and nd that, with this denition, we obtain a solution to the differential equation x = Ax + Bu.
This means that the convolution equation can be used to obtain solutions to vector-valued linear
ordinary differential equations with external signals.
56
18 Modeling Electrical Components
Near the beginning of this course we talked about how we build models of mechanical systems
from models of mechanical components. The same thing is true of electrical systems.
Today we are going to investigate how we model components of an electrical system. You
should think of voltage V as being an effort variable just like force in mechanical systems. The
charge q is like the energy stored in a mechanical spring. Lastly, the current i is the ow of charge
from one part of the circuit to another part of the circuit, and is dened to be the time derivative of
charge.
i =
d
dt
q
Figure 24: A constitutive law for an engineered electrical component might look like this; just like
mechanical elements, we expect the relationship between voltage V and charge q or current i to be
linear.
Just like we did with mechanical systems, we use what are called constitutive laws to model
individual components. These constitutive laws relate variables of interest, like charge q and
current ithe derivative of charge with respect to timeto voltage V . For instance, a plot of
a constitutive law might look like this one where the voltage V is on the vertical axis and the
variable q or i is on the horizontal axis. Just like in the mechanical setting, this curve goes through
the origin, so if a capacitor has zero charge q in it, or if a resistor has zero current i running through
it, then we expect to measure a voltage between one side of the element and the other that is zero.
If, however, the capacitor does have charge, or the resistor does have current running through it,
then we expect the measured voltage to be nonzero. The key thing is that these are engineered
devices, so the relationship ends up being pretty close to a linear relationship.
(a) (b) (c) (d)
Figure 25: The four electrical elements: (a) a capacitor (b) a resistor (c) an inductor (d) a battery
57
Electrical diagrams play a critical role in how we set up models of electrical systems, and in this
class we are going to always assume that we have four types of components capacitors, resistors
(not to be confused with mechanical springs), inductors, and batteries.
20
Note that the notation
for batteries has some dashes that are larger than others. We will always use the four symbols in
Fig. 25 to represent the four types of idealized components.
Moreover, the relationship between voltage and charge of a capacitor is always a line repre-
sented by the constitutive law
V
C
=
1
C
q
(where the positive number C is called the capacitance). This means that the larger the capaci-
tance, the smaller the voltage V required to maintain the charge. (This is why C is in the denom-
inator.) The relationship between voltage and current running through a resistor is also always a
line represented by the constitutive law
V
R
= Ri
(where the positive number R is called the resistance).
As a convention, we always indicate the positive end of the battery using large dashes at that
end and small dashes at the negative end. We are free to assign current ow conventions any way
we like. For instance, lets think about a battery-resistor-capacitor circuit. We can say that the
Figure 26: A battery-resistor-capacitor circuit
current runs clockwise in this circuit. Our sign convention for the polarities of the elements that
are not batteries will be that the current always runs into the positive terminal of the element. In
the case of this capacitor, that means that the positive end is on the right.
Because of the constitutive law, the voltage across a capacitor being positive means that the
charge on the capacitor must be positive.
V
C
> 0 q
C
> 0
The voltage across a resistor being positive means that the current running through the resistor
must be positive.
V
R
> 0 i
R
> 0
Lastly, sometimes our expectations about electrical systems will not always be well aligned
with our understanding of the idealized elements. As an example, consider this very simple system
that consists of a spring, a battery, and a switch. When the switch is open, the circuit is not complete
20
These are all DC (direct current) components. In this class we will ignore AC (alternating current) components,
but there are versions of these for the AC case.
58
Figure 27: A battery-capacitor circuit with a switch
and there is no charge in the capacitor. However, the moment that the switch closes, this idealized
system predicts that the capacitor will be instantly charged because its voltage V
C
will be instantly
equal to the battery voltage V
B
.
That probably seems unintuitive, but thats because real capacitors have what are called para-
sitic effects that include the nonideal properties of resistors and inductors. Just like in mechanical
systems, keeping in mind the difference between these idealized elements and the real, physical
elements they represent is a key skill you are developing in this class.
What should you remember from today? Electrical systems also have linear constitutive laws
because we engineer them to behave in a linear manner. Remember that we get to choose the
current ow convention in the diagram, and that this determines the sign convention we use. Also
keep in mind thatjust like mechanical systemsidealized electrical elements can have unintu-
itive behavior.
59
19 Kirchhoffs Laws
Last time we introduced electrical systemsvoltage, charge, current, and the constitutive laws that
relate them. What principles do we use to generate mathematical models of electrical systems? In
the case of mechanical system, the principles we used came from Newtons laws. In the case of
electrical systems, the laws we use are Kirchhoff s laws.
Kirchhoffs laws come in the form of two statementsKirchhoffs Current Law (KCL) and
Kirchhoffs Voltage Law (KVL). The current law states that the current into a nodea place in the
circuit, typically where two wires
21
meetmust equal the current out of the node.
KCL:

i
in
=

i
out
KVL:

V
loop
= 0
Kirchhoffs voltage law states that the sum of the voltages around a loop must be equal to zero.
Figure 28: A battery-resistor-capacitor circuit
Lets focus on the voltage law rst and look at the example in Fig. 28. Lets say that we have
a capacitor and resistor and a battery in a single loop. We can choose to have the current running
counterclockwise in the loop and that determines the polarities of the elements. If we evaluate the
voltage law clockwisestarting at the batteryand assign negative signs any time we encounter
the negative side of an element, we get
V
B
V
C
V
R
= 0.
If we now substitute the constitutive laws for V
C
and V
R
V
C
=
1
C
q V
R
= Ri = R q
we nd that
V
B

1
C
q R q = 0 q =
1
RC
q +
V
B
R
.
This is the same differential equation as the spring-damper system with an external force (Fig. 29).
Figure 29: A spring-damper system with external force
It is a linear, constant coefcient, rst-order ODE, so we can use all the same tools we used for
mechanical systems, including Euler integration, analytical solutions, superposition, and convolu-
tion.
21
The node could be anywhere, but KCL doesnt really tell us anything at a node in the middle of a single wire
because it simply indicates that the current does not change going through a particular point.
60
Figure 30: A capacitor-resistor-battery circuit with two loops
Lets look at a slightly more complex example that focuses on Kirchhoffs current law(Fig. 30).
Here we have a resistor and a capacitor and a battery. In the way I have drawn the current ow
conventions, Kirchhoffs current laws tells us that i
in
= i
out
, so at Node 1 i
C
= i
R
+ i
B
and at
Node 2 i
R
+ i
B
= i
C
, so the two nodes give us the same information.
Figure 31: Three capacitors and two resistors in two loops
Lastly, lets look at an example that combines KCL and KVL (Fig. 31). This has three ca-
pacitors and two resistors. I can assign the current ow convention any way I want. If I evaluate
Kirchhoffs current law, I get
i
C
2
= i
C
3
+ i
C
4
q
C
2
= q
C
3
+ q
C
4
+
=0
..
cons
q
C
3
= q
C
2
q
C
4
.
The voltage law gives me
V
R
1
+ V
C
2
+ V
C
3
= 0 V
C
4
+ V
R
5
V
C
3
= 0.
From these, I can conclude that
R
1
i
R
1
..
= q
C
2
+
1
C
2
q
C
2
+
1
C
3
q
C
3
= 0
1
C
4
q
C
4
+ R
5
i
R
5
..
= q
C
4

1
C
3
q
C
3
= 0
If I substitute in for q
C
3
, and note that i
R
1
= q
C
2
and that i
R
5
= q
C
4
,
22
I get
q
C
2
=
1
R
1
C
2
q
C
2

1
R
1
C
3
(q
C
2
q
C
4
)
q
C
4
=
1
R
5
C
4
q
C
4
+
1
R
5
C
3
(q
C
2
q
C
4
).
This is a linear, constant coefcient, rst-order ODE. I could write this in vector and matrix nota-
tion by choosing the state to be w = [q
C
2
, q
C
4
].
22
Note that putting nodes at the corners of the circuits indicates that we can do this.
61
Figure 32: Three springs and two dampers that are equivalent to the circuit above
What is this system similar to in terms of a mechanical system? Capacitors are like springs
and resistors are like dampers, so we might expect three springs and two dampers. Indeed, this is a
system that gives us the same ODE with potentially different coefcients, depending on the spring
constants and damping constants.
What should you remember from today? Kirchhoffs laws provide the principles by which we
construct ordinary differential equations that predict the evolution of charge in a circuit. We also
learned that electrical systems often have mechanical analogs, as in the last example. But what
if that mechanical analog had masses in it? What electrical system would behave the same way?
Next time, we will talk about inductors and how they complete the analogy between electrical and
mechanical systems.
62
20 Kirchhoffs Laws with Inductors
Last time we discussed Kirchhoffs laws, but I didnt say anything about how inductors work.
Today we are going to talk about the role that inductors play in circuits and how inductors complete
the analogy between mechanical and electrical systems.
Inductors have a simple constitutive law that says that the voltage across the inductor is pro-
portional to the time derivative of the current through the inductor.
V
L
= Li

Here I am using the prime notation for the derivative so that the dot over the i is not confused with
the time derivative.
23
This time derivative of the current i, which is itself the time derivative of
charge q, should remind you of acceleration of mass.
Lets say we have a simple circuit with a battery, a capacitor, a resistor, and an inductor.
Kirchhoffs voltage law says that the sum of the voltages around the circuit must be equal to
Figure 33: All four electrical elements in a single loop
zero. Therefore, I get
V
C
+ V
R
+ V
L
= V
B
1
C
q + R q + L q = V
B
.
Since, with my current sign convention, the current ows into the negative terminal of the battery,
I get a negative sign on V
B
and can move it to the other side of the equation. If I replace voltages
with constitutive laws as well as i with q and i

with q, I get a second order differential equation. It


is hopefully clear that L is playing the role of mass in this differential equation.
I can rewrite this differential equation in rst-order form
q = i
i

=
1
LC
q
R
L
i +
V
B
L
,
and then rewrite that equation in matrix and vector notation using w = [q, i] as the state vector.
d
dt
_
q
i
_
=
_
0 1

1
LC

R
L
_ _
q
i
_
+
_
0
V
B
L
_
23
To make this clear, look at

i versus i

. In text this is bad enough, but in handwritten notes it would be terrible to


keep straight.
63
This means I can use Euler integration from Lecture 4 to compute a solution. For instance, if I
choose the initial condition to be
_
q
0
i
0
_
=
_
0.5
0
_
and choose the constants to be
L = R = C = 1 V
B
= 9
then I get
_
q(0.1)
i(0.1)
_

_
0.5
0
_
+ 0.1
__
0 1
1 1
_ _
0.5
0
_
+
_
0
9
__

_
0.5
0
_
+ 0.1
_
0
8.5
_

_
0.5
0.85
_
.
I can also solve for a solution analytically the way we did in Lecture 5. If I assume an expo-
nential solution for q(t)
q(t) = e
ht
w
I get that
h
2
+
R
L
h +
1
LC
= 0
just like we did with mechanical systems. If R = 0
h =
_
1
LC
j q(t) = Acos(
_
1
LC
t) + Bsin(
_
1
LC
t)
then I get h has imaginary values, which means I should expect sin and cos terms in the solution.
This means that this circuit will have the charge in the capacitor oscillating for all timethat is,
the charge stored by the capacitor will uctuate forever.
If I have R = 0, then I can use the quadratic formula, just like we did with mechanical systems,
to solve for h. Lets set L = 1 and C = 1. Then we get
h =
R

R
2
4
2
which means that if R > 2 I have an overdamped system that will have no oscillation and if
R < 2 I have an underdamped system that will experience oscillation with exponential decay.
I hope that this has convinced you that electrical and mechanical systems have very similar
behavior. This is because the equations governing their behavior are exactly the same in many
cases!
What should you remember from today? When I have a circuit that has electrical components
that include capacitors, resistors, inductors, and batteries, I should expect the same kind of behavior
that I might see in a mechanical system that has springs, dampers, masses, and external forces.
64
Figure 34: A circuit with capacitance values C, the resistance is R, and the inductance is L.
Also, all the mathematical tools that we developed for mechanical systems are also applicable for
electrical systems.
Exercise:
Consider the inductor-resistor-capacitor circuit with four elements 1 4 in Fig. 34. The ca-
pacitance values are C, the resistance is R, and the inductance is L.
1. Write out all three Kirchhoffs Voltage Laws without plugging in constitutive laws for this
system.
V
1
+ V
3
= 0, V
2
+ V
4
V
3
= 0, V
1
+ V
2
+ V
4
= 0
2. Write out the constitutive law for elements 2 and 4.
V
2
= Li

, V
4
=
1
C
q
4
3. Write out Kirchhoffs Current Laws in terms of i
1
, i
2
, and i
3
.
i
1
= i
2
+ i
3
4. What is the rst-order ordinary differential equation for this system in terms of the states i
2
,
q
3
, and q
4
?
i

2
=
1
LC
q
4
+
1
LC
q
3
q
3
= i
2

1
RC
q
3
q
4
= i
2
65
21 Vector and Matrix Representations in Kirchhoffs Laws
Last time we saw that electrical systems have the same basic characteristic behavior as mechanical
systemsthey have exponential solutions and, with an inductor, can experience oscillation. Today
I want to go through an example that will help you get more comfortable with analysis of circuits.
Lets say we have a circuit that has two inductors and three capacitors. I can assign the current
Figure 35: Three capacitors and two inductors. This diagram should be like the video lecture
where i
2
and i
3
are switched.
sign conventions any way I want, and then I mark in the positive sign for every element where the
current ows into the element.
Kirchhoffs current law states that
KCL: i
1
= i
2
+ i
3
KVL: V
L
1
+ V
C
2
+ V
C
3
= 0
V
C
4
+ V
L
5
V
C
3
= 0
Kirchhoffs voltage law tells us that the sum of the voltages is zero around both the left loop and
the right loop. I could choose to sum around the outer loop if I wanted, but that would give me
redundant information. Notice that in the second KVL equation the sign of V
C
3
is negativethis
is because the right hand loop, going clockwise, encounters the negative terminal of C
3
.
Also note that
i
1
= i
L
1
= q
C
2
i
2
= q
C
3
i
3
= i
L
5
= q
C
4
.
This means thatjust as in Lecture 19Kirchhoffs current law implies that
q
C
2
= q
C
3
+ q
C
4
q
C
2
= q
C
3
+ q
C
4
+
=0
..
cons
q
C
3
= q
C
2
q
C
4
.
If we integrate this expression with respect to time, we get that q
C
3
= q
C
2
+q
C
4
plus a constant that
we set equal to zero because the total charge across all the capacitors in a circuit without a battery
is typically zero.
66
The consequence is that we can use Kirchhoffs voltage law to nd an ODE that governs the
state evolution of the circuit. Keep in mind that the current through the left inductor is the same as
the current through the left capacitor and that the same thing holds for the right inductor and right
capacitor. We get
KVL: L
1
q
C
2
+
1
C
2
q
C
2
+
1
C
3
(q
C
2
q
C
4
) = 0
L
5
q
C
4
+
1
C
4
q
C
4

1
C
3
(q
C
2
q
C
4
) = 0.
If we convert this second-order differential equation to a rst-order differential equation and
choose the state vector to be
w =
_

_
q
C
2
q
C
2
q
C
4
q
C
4
_

_
,
then we can rewrite the differential equation in vector and matrix notation
w =
_

_
0 1 0 0

1
L
1
C
2

1
L
1
C
3
0
1
L
1
C
3
0
0 0 0 1
1
L
5
C
3
0
1
L
5
C
4

1
L
5
C
3
0
_

_
w.
This means we have an equation of the form
w = Aw.
So we can use Euler integration to approximate solutions or exponential solutions to obtain analytic
solutions.
Lastly, lets set all the constants to 1.
L
1
= L
5
= C
2
= C
3
= C
4
= 1
This gives us an A matrix of
_

_
0 1 0 0
2 0 1 0
0 0 0 1
1 0 2 0
_

_
.
What do you expect this system to do? How do you expect it to behave? I can take A and use
MATLAB or Python to compute the eigenvalues of A. We know that these eigenvaluesand the
eigenvectors that go with themare part of the exponential solution e
ht
w from Lecture 12. If I
compute these eigenvalues, I get the following four values.
h =

3j and j
This means that I should expect oscillation at two different frequenciessin() and cos() terms with
frequencies of 1 and

3. Since superposition appliesbecause this is a linear, constant-coefcient


67
differential equationwe know that I can also expect to sum these sin() and cos() terms at the two
frequencies. If there was a battery that was oscillating the voltage at some third frequency, then I
know by the convolution equation that I should expect those frequencies to show up as well!
What should you remember from today? We can use all the tools that we learned in mechan-
ical systemsincluding vector and matrix notation and eigenvalue computationto analyze and
compute solutions for differential equations for electrical systems. Next time we are going to talk
more about analogies between electrical and mechanical systems to strengthen our intuition about
the parallels between them.
Exercise:
Assume that w = Aw and that A =
_
1 0
0 1
_
and w =
_
w
1
w
2
_
.
1. What is the Euler approximation of w(0.1) if dt = 0.1 and w(0) =
_
1
1
_
w(0.1)
_
1
1
_
+ 0.1
_
1 0
0 1
_ _
1
1
_
=
_
1
1
_
+ 0.1
_
1
1
_
=
_
0.9
0.9
_
2. What type of circuit does this represent? Circle all that apply in Fig. 36:
Figure 36: Five possible circuits
To gure out which ones it could be, count the states and see how they are related to each
other.
Hint: The A matrix suggests that the two states are independent of each other, and the
relationship is rst order.
68
22 Mechanical/Electrical Analogies
Last time we talked about using vector and matrix notation to represent electrical circuits. But
what if we want to use one physical system to represent another physical system? How do we
know when a parallel between two systems exists? The reason we care about this question is that
we often use our physical knowledge about one system to reason about another. For instance, we
know that mechanical systems can oscillate if damping is low, and from that we might reason that
electrical systems can oscillate with low resistancebut only if there is an inductor to play the role
that mass would play in a mechanical setting. This skill of translating between mechanical and
electrical systems is a key part of how we double check that the solutions we obtain actually make
sense.
Remember that capacitors are like springs, resistors are like dampers, and inductors are like
masses. As an example, lets start with a capacitor-resistor simple circuit. You probably can guess
Figure 37: A capacitor-resistor circuit is an analogy of a spring-damper mechanical system.
that the spring-damper system is an analog of this circuit. But in what sense are they equivalent?
The answer is in the ODE that represents each one. In the case of the circuit, the ODE is
q =
1
RC
q
. .
electrical
x =
k
b
x
. .
mechanical
but this is the same as the ODE for the spring-damper system. We think of two physical systems
being equivalent when the ODE that describes them is the same.
24
Figure 38: A capacitor-resistor-battery circuit is an analogy of a spring-damper mechanical system
with a force.
If we add an external force to the spring-damper system, what would we have to add to the
circuit to make the two systems equivalent. Once we add a battery to the circuit, the two differential
equations are the same again.
24
This equivalence ignores coefcientsjust because the parameters in an ordinary differential equation are differ-
ent doesnt mean we think the systems are not equivalent, in much the same way that we think of two spring-mass
mechanical systems with different masses as still fundamentally being the same system.
69
Lets say that now we start with a capacitor-inductor circuitwhat is the mechanical analog of
this circuit? You probably guess a spring-mass systemthese two systems have the same ODE.
Figure 39: A capacitor-inductor circuit is an analogy of a spring-mass mechanical system.
q =
1
LC
q x =
k
m
x
They are also the same as the slinky I showed in class when I held it horizontally. If I add an
external force or add a battery, they are equivalent to the slinky I showed in lecture oscillating
in gravity. Another example is the capacitor-resistor-inductor circuit, which is equivalent to the
Figure 40: A capacitor-inductor-resistor circuit is an analogy of a spring-damper-mass mechanical
system.
spring-damper-mass mechanical system.
Figure 41: Two decoupled capacitor-inductor circuits are an analogy to two decoupled spring-mass
mechanical systems.
Now, lets say that I have a different capacitor-inductor circuit. What is the equivalent mechan-
ical system? The equivalent system is a mechanical system with two masses, but the dynamics of
the two masses are completely independent of each other! This is not easy to see in the electrical
diagramat least it is not so easy for mebut it is really easy to think about in the mechanical
diagram. With two batteries, this system would be equivalent to two one-mass slinkys.
Now what if we added a capacitor so that the circuit has three capacitors? What mechanical
system is equivalent to this circuit? The equivalent mechanical system has two masses and three
springsthe middle spring couples the dynamics of the mass on the left to the dynamics of the
mass on the right. Again, for me this is much easier to understand in the diagram on the right. Both
of these systems are equivalent to the slinky in lecture with two masses.
What should you remember from today? Analogs between electrical and mechanical systems
70
Figure 42: A coupled circuit is an analogy of a coupled mechanical system.
are a powerful way of gaining intuition and applying the physical knowledge you have about one
type of system to the other types of systems that are equivalent.
71
23 Interpretation of Mathematical Expressions as Physical Sys-
tems
Last time we talked about analogies between physical systems. Today we are going to talk about
using physical systems to understand and reason about mathematical expressions. If I give you a
matrix of the form
A =
_
0.001 0.989
3.2 0.01
_
what could you do with it? Could you tell me what it means? Looking directly at a matrix repre-
sentation of a dynamical system is a skill that is surprisingly useful, partially because often times
matrix representations come from data, and data is never as clean as the examples we cover in
class. In the case of this example, what if I write down a matrix that is nearly the same as the
example?
A =
_
0 1
3 0
_
This is the matrix that represents a spring-mass mechanical system or a capacitor-inductor electri-
cal system. If I choose the state vector to be
w =
_
x
v
_
,
then w = Aw implies that
x = v
v = 3x
which implies that x = 3x.
Looking at Fig 43 and these equations, I now know to expect that the matrix I started with should
Figure 43: Both spring mass mechanical systems and inductor-capacitor electrical circuits have the
same mathematical representation.
have eigenvalues that are nearly only made up of their imaginary parts (i.e., the part without the j is
very small). If I calculate the eigenvalues, I nd that h = 0.00451.7789j, so my suspicion was
correct. This pair of eigenvalues means that the damping is very low because the nonimaginary
part of h is very small and negative.
Lets look at some other examples. For instance, what does
A =
_
1 0
0 2
_
72
represent? Because the diagonal elements are nonzero and the off-diagonal elements are zero,
we know that these two states are independent of each other and are rst-order. Therefore, this
A matrix represents either a two-spring-two-damper mechanical system or a two-capacitor-two-
resistor circuit, like those seen in Fig. 44.
Figure 44: Decoupled systems are represented by diagonal matrices
Now lets think about this four by four matrix.
A =
_

_
0 1 0 0
1 0 0 0
0 0 0 1
0 0 1 0
_

_
This matrix has two states that depend on each other in the upper left and two states that
depend on each other in the bottom rightthis corresponds to two spring-mass systems that are
disconnected or a capacitor-inductor circuit.
Figure 45: Another set of decoupled systems
Lastly, lets consider one more A matrix.
A =
_

_
0 1 0 0
5 0 1 0
0 0 0 1
1 0 1 0
_

_
This system has the dynamics of the two masses like the previous example, but also has terms
in the upper right and lower left. This means that the masses in the mechanical system must be
coupled with each other, like a spring-mass system and a capacitor-inductor circuit.
Figure 46: Coupled second-order systems
73
The key thing is that being able to recognize mechanical and electrical analogs of mathematical
statements makes interpretation of dataand even this classmuch easier!
What should you remember from today? Remember that when you look at a matrix, it helps to
think about what that matrix might represent. The analogy often helps us reason about the system
the matrix represents, even if it is not a mechanical or electrical system.
74
24 Everything Is The SameAlmost
We are going to end with what I promised you at the beginning of the classthat everything is
the same. Well, at least with all the caveats that the system is engineered and that we can use
constitutive laws and all of the other restrictions I have made on the way. But today we are going
to see that electrical and chemical systems are sometimes the same, and because of the connection
between mechanical and electrical systems, all three types of systems are sometimes the same.
As an example, consider this RC circuit.j
This circuit has lots of repeating elements, each with a capacitor and resistor. All of the capac-
itors have capacitance C and all of the resistors have resistance R. The equation that we get for the
charge on each capacitor is
q
i
=
1
RC
(q
i+1
+ q
i1
2q
i
)
Look at the right hand side of this differential equation and now look at the diffusion equation prior
to taking the limit as dx 0.
d
dt
C(x
i
) = D
C(x
i+1
)C(x
i
)
dx

C(x
i
)C(x
i1
)
dx
dx
= D
(C(x
i+1
) + C(x
i1
) 2C(x
i
))
dx
2
This means that the dynamics of the electrical system are approximately equal to the dynamics of
the diffusion equation if dx = 1, therefore
D =
1
RC
.
Lets test this out and simulate the electrical system while plotting the solution to the diffusion
equation on top of it. We can choose a total of n = 100 capacitors and R = 0.1 and C = 2.
Moreover, we choose the initial charge on every capacitor to be zero except the one in the very
middle, which we choose to have a positive initial charge of 1 Coulomb. We plot the height of
each state and watch it change over time and we plot the solution to the diffusion equation on top
of it. Amazingly, these two solutions are right on top of each other! Prior to the near-universal use
of computers for simulations, people used this relationship between the circuit and the diffusion
equation to use a circuit as an analog simulation of how a chemical might diffuse in a uid.
What does this mean? It means that electrical systems can experience diffusion if there are
enough electrical elements involved. Since electrical and mechanical systems are equivalent, it
means that there is a mechanical system that is equivalent to the diffusion equation as well! In fact,
one mechanical analog is a series of spinning masses with torsional damping between them, where
75

20 40 60 80
0.1
0.2
0.3
0.4
0.5
Figure 47: The RC circuit follows the evolution of a time-varying diffusion equation. Hence, the
circuit can be used to simulate a diffusion process.
we focus on the state v and how an initial velocity in the middle diffuses to velocities through the
system. You might nd it interesting that heat also diffuses in a mechanical body. For instance,
if you touch a piece of metal with something hot, the metal will get hotand the way it gets hot
satsies the diffusion equation. This is why sometimes the diffusion equation is called the heat
equation. So even thermodynamic systems are sometimes the same as mechanical, electrical, and
chemical systems. I do not know how you feel about this, but to me this is a really beautiful and
profound idea.
But mechanical, electrical, and chemical systems are not always the same! We saw before that
mechanical and electrical systems are sometimes the same if the components match up well. We
see here that they are sometimes the same if there are lots of components and those components
are very uniformthe resistance and capacitance of the circuit has to be the same everywhere for
the circuit to be the same as the heat equation.
Lastly, the relationship between mechanical, electrical, and chemical systems means that we
can use these physical analogies to understand how charge will diffuse through a circuit or how
energy in a mechanical system will diffuse through its elements.
The main thing I hope that you get out of this class is the sense that very different physical
systems often behave very similarly. Of course, this doesnt mean that the title of the class is
literalnot everything is the same! But enough things are the same that understanding analogies
between systems provides us with a way of connecting analytical reasoning with computation,
and computation with our physical knowledge, and our physical knowledge back to the analytical
reasoning. This ability to connect these different ideas and intuitions is part of what makes an
engineer competent to make decisions, and I hope you nd this class helpful in your future as
engineers!
76
c Todd D. Murphey
77

You might also like