Differential Equations: A Tourist's Guide | DE1
How the language of change describes everything: from a falling ball and a pendulum to love. A guide to differential equations without unnecessary complexity.
Introduction
Steven Strogatz wrote: "Since Newton's time, humanity has understood that the laws of physics are always expressed in the language of differential equations." This language is used far beyond physics as well. The ability to read and write in it changes one's view of the world.
The material is an overview of the topic. It provides a general picture of what differential equations are and, at the same time, examines individual examples. The reader is assumed to be familiar with the fundamentals of mathematical analysis, including derivatives and integrals. Some sections will require basic knowledge of linear algebra.
Why Differential Equations Are Needed
Differential equations arise where it is easier to describe change than the absolute values of quantities. For example, it is easier to explain why a population grows or declines than to explain why it has this particular value at a given moment in time. Similarly, it is easier to describe why feelings toward a person change than to explain why they are exactly what they are.
In classical mechanics, motion is described through force. Force determines acceleration, and acceleration is a quantity that characterizes the change in velocity.
Two Types of Equations
Differential equations are divided into two classes:
- Ordinary differential equations (ODEs) describe functions of a single input variable, which is usually treated as time.
- Partial differential equations (PDEs) describe functions of several input variables.
PDEs describe a continuous set of values that change over time. Examples include the temperature at every point of a solid body or the velocity of a fluid at every point in space. ODEs describe a finite set of quantities that change over time. The main focus from here on is on ODEs.
The independent variable does not necessarily have to be time. However, change over time is the most typical and common example.
Example One: A Body Thrown Upward
Consider the trajectory of a body thrown upward. Near the Earth's surface, gravity imparts an acceleration directed downward, equal to 9.8 m/s².
This means the following. If you observe an object on which no other forces act and record its velocity every second, the velocity vector will acquire an additional small component directed downward, by 9.8 m/s each second. This constant is called the acceleration due to gravity and is denoted by the letter g.
Let y(t) be the vertical coordinate of the body as a function of time. The first derivative gives the vertical component of velocity, and the second derivative gives the vertical component of acceleration. Denote the first derivative as ẏ and the second as ÿ. The equation takes the form:
ÿ = −g
This is the simplest differential equation. It is solved by integration, that is, by reconstructing a function from its rate of change.
- Velocity. We look for a function whose derivative equals −g. This is −gt. The general solution is −gt + v₀, where v₀ is the initial velocity. The constant of integration is determined by the initial condition.
- Coordinate. We look for a function whose derivative equals −gt + v₀. This is −½gt² + v₀t. An arbitrary constant, determined by the body's initial position, can be added to it.
Thus, we have solved the differential equation: we found a function from information about its rate of change.
Position-Dependent Forces
The problem becomes more complicated when the force depends on the position of the body. When studying the motion of planets, stars, and satellites, gravity cannot be considered constant.
For two bodies, the attractive force of one is directed toward the other and is inversely proportional to the square of the distance between them.
The rate of change of the coordinate is still equal to the velocity. But the acceleration is now a function of position. An interaction arises between two interrelated variables, similar to the motion of the two bodies that these variables describe.
In differential equations, one often seeks a function whose derivative (or derivatives of higher order) is expressed in terms of that same function.
In physics, one most often works with second-order differential equations, that is, equations in which the highest derivative is the second. Equations of higher order contain derivatives of the third, fourth, and higher orders.
Working with such equations resembles solving an infinite, continuous puzzle. One must find infinitely many numbers, one for each moment of time t. These values are linked by a strict rule: how the quantity relates to its rate of change and to the rate of change of that rate.
Example Two: The Pendulum
A pendulum seems like a simple object, yet its equation reveals important properties of differential equations.
The Classical Approximation
In secondary school physics courses, pendulum oscillations are described as harmonic. The angle θ changes according to a sine law. The period of oscillation equals 2π√(l/g), where l is the length of the pendulum and g is the acceleration due to gravity.
These formulas are an approximation that works only for small angles. When a real pendulum is measured, it turns out that at larger deflections the period is longer than what the school formulas predict. At very large deflections, the graph of θ(t) no longer resembles a sine wave.
Deriving the Equation
The position of the pendulum bob is measured by the distance x along the arc. If the angle θ is expressed in radians, then x = lθ, where l is the length of the pendulum.
Gravity acts downward with acceleration g. However, the motion of the bob is constrained by the string, so we need to consider the component of acceleration in the direction of motion. This component equals −g·sin θ. The minus sign indicates that the acceleration is directed opposite to the displacement. The angle θ is considered positive when the deflection is to the right and negative when the deflection is to the left.
Thus, the second derivative of x equals −g·sin θ. Since x = lθ, we obtain:
θ̈ = −(g/l)·sin θ
Checking the Equation
Let us check the equation for physical meaning.
- When θ = 0, we have sin 0 = 0. There is no acceleration in the direction of motion, which corresponds to the equilibrium position.
- When θ = 90°, we have sin θ = 1. The acceleration coincides with the acceleration due to gravity, which corresponds to the situation where the pendulum is deflected horizontally.
The equation is consistent with physics.
Accounting for Resistance
To make the model more realistic, we add a term describing air resistance. We assume that the resistance is proportional to the velocity. Then the term equals −μθ̇, where μ is a constant that combines air resistance, friction, and other factors that determine the rate at which the pendulum loses energy.
The complete equation:
θ̈ = −(g/l)·sin θ − μθ̇
This equation is difficult to solve, but it allows for meaningful analysis.
The Sine Paradox
At first glance, it may seem that the sine in the equation is connected with the sinusoidal character of the pendulum's oscillations. In fact, the opposite is true. It is precisely the presence of the sine in the equation that explains why a real pendulum does not oscillate according to a sinusoidal law.
In the equation, the sine takes θ as its argument. In the approximate solution from the physics course, by contrast, θ itself oscillates as the output of a sine function. This contradiction indicates that the approximate model does not reflect the real behavior of the pendulum at large angles.
Analytical Solutions and Their Limits
Differential equations, as a rule, are extremely difficult to solve. For a pendulum without a damping term, one can barely manage to write down an analytical solution. It is extremely complicated: it uses functions that usually do not appear in textbook courses, and it is expressed through integrals and inverse integral problems.
Usually a solution is needed to compute values and understand the dynamics of the system under study. In this case, these tasks are shifted to computing and understanding new functions.
When a damping term is added, an exact analytical solution, as a rule, is not known.
For any difficult problem, one can introduce a new function that will serve as the answer to that problem. However, such an approach is meaningless if it does not allow one to compute and understand the system.
Therefore, the theory of differential equations often takes a different path. The exact solution is not sought; instead, one moves directly to understanding and computing based on the equation itself.
Phase Space
Instead of a graph of θ(t), it is more convenient to consider all possible states of the system on a two-dimensional plane. The state of the pendulum is completely defined by two numbers: the angle θ and the angular velocity θ̇. The acceleration is a function of only these two quantities.
Each point on the plane completely describes the pendulum at a given moment. The points can be regarded as all possible initial conditions. If the initial angle and angular velocity are known, the evolution of the system over time can be predicted.
The diagram shows a spiral converging inward. This is a typical trajectory for a damped pendulum.
At the beginning of the motion, as θ decreases, the vertical coordinate θ̇ becomes more negative. This is consistent with physics: the pendulum moves faster as it approaches the lowest point.
It is important to remember that on the diagram, the pendulum's velocity is represented by the vertical component of the state space. The velocity vector on the diagram points to the left, but its magnitude is plotted vertically. Phase space is an abstract object and differs from the physical space in which the pendulum exists and moves.
Because part of the pendulum's energy is lost to air resistance, the trajectory curls inward. The maximum speed and maximum deflection decrease with each oscillation. In other words, the point is attracted to the origin, where θ = 0 and θ̇ = 0.
Vector Field
The phase space allows a differential equation to be represented as a vector field.
The state of the pendulum is given by the vector (θ, θ̇). It can be represented as an arrow emanating from the origin, or as a point. Importantly, the vector has two coordinates, each of which is a function of time.
The derivative of this vector gives the rate of change of the state, that is, the direction and speed with which the point tends to move on the diagram. The derivative is a new vector (θ̇, θ̈), which is attached to the corresponding point of the plane.
The first component of this velocity vector is θ̇. This is the coordinate of the point in state space. The higher the point on the diagram, the more strongly it tends to move to the right. The lower it is, the more strongly it tends to move to the left.
The second component is θ̈. The equation allows it to be expressed entirely in terms of θ and θ̇. Thus, the first derivative of the state vector is a function of this same vector. The main difficulty is concentrated in the second component.
If this construction is carried out at every point of the plane, it becomes clear how the state changes from any position.
The vectors on the diagram are artificially shortened so as not to clutter the figure. The magnitude of the vector is shown by color.
Converting a Second-Order System into a First-Order System
A second-order equation for one quantity is transformed into a system of two first-order equations. The second quantity θ̇ can be denoted by a separate symbol to emphasize that two independent values are being considered, which are linked by their mutual influence on each other's rates of change.
This is a common technique in the theory of differential equations. Instead of studying higher-order derivatives of one quantity, it is more convenient to consider first derivatives of a vector quantity.
In this form, the solution of the equation acquires a clear geometric interpretation. The system, starting to evolve from an initial state, moves along some trajectory in space. At each moment, the velocity of the point coincides with the field vector at that point.
This velocity does not coincide with the physical velocity of the pendulum. It is an abstract rate of change that encodes the rates of change of both θ and θ̇.
Examples of Trajectories
- In regions where θ̇ is large, the vectors direct the point far to the right before it moves into a spiraling curl. This corresponds to a pendulum with a sufficiently large initial velocity. It makes several complete revolutions around its axis, and then transitions to damped oscillations.
- As the damping coefficient μ increases, the trajectories spiral inward faster. This means that the pendulum slows down more quickly.
This dependence is easy to understand once one knows that μ describes air resistance. However, if one sees the equation without context, without knowing that it describes a pendulum, it is hard to tell from it that increasing μ brings the system to the attractor faster.
Constructing the vector field with software helps build intuition about the behavior of the system.
Multidimensional Systems
A vector field can be constructed for any system of ordinary differential equations. This makes the approach general. However, most often the dimension of the state space is significantly greater than two.
The Three-Body Problem
Consider the three-body problem. The task is to predict how three masses evolve in three-dimensional space if they interact with each other through gravity and their initial positions and velocities are known.
Each mass has three position coordinates and three momentum components. In total, the system has 18 degrees of freedom: 3 bodies × 6 quantities. Therefore, the space of possible states has dimension 18.
A single point moves through this 18-dimensional space. At each moment, it takes a step in time along the vector on which it is located. This point fully encodes the positions and momenta of the three masses in ordinary three-dimensional space. Visualizing an 18-dimensional space is impossible.
In practice, the number of dimensions can be reduced by using the symmetries of the system. However, the underlying regularity remains: the more degrees of freedom, the higher the dimension of the state space.
Phase Space in Physics and Mathematics
In mathematics, a space of this type is often called a phase space. In this course, the term is used broadly: for any spaces that encode the states of changing systems.
In physics, especially in Hamiltonian mechanics, the term is reserved for a narrower case: a space whose axes represent coordinates and momenta. From a physicist's point of view, the 18-dimensional configuration space of the three-body problem is a phase space. However, to strictly match the physical definition, several changes may be needed in the pendulum model.
The planes used in the analysis of the pendulum are also called phase spaces by mathematicians. Physicists may use different terminology for them. The specific meaning of the term depends on the context.
The idea seems simple, yet it took humanity a long time to learn to view dynamics spatially, especially when there is a large number of dimensions.
The writer James Gleick, in his book Chaos, called phase space "one of the most powerful inventions of modern science."
One advantage of phase space is that one can ask questions not only about a single initial condition, but also about a whole spectrum of initial states. The set of all possible trajectories resembles a flowing fluid. That is why it is called a phase flow.
Stability
Phase flow allows us to study stability. Consider the equilibrium points of the system.
- The origin corresponds to the stationary pendulum at the bottom point.
- The point corresponding to the perfectly balanced pendulum in the upright position is also an equilibrium point.
These points are called fixed points of the system. A natural question arises: are they stable? That is, if the system is slightly perturbed, will it return to the fixed point or move away from it?
For the pendulum, physical intuition lets us answer this question in an almost obvious way. However, how do we answer it if the equations arise in a completely different, less intuitive context?
The calculations for such questions will be considered in the following materials. Intuition relies on analyzing small regions of space around the fixed point. We need to determine whether the flow contracts or expands in that region.
Example Three: A Model of Relationships
Strogatz presented his quote in a New York Times column devoted to the mathematical modeling of feelings. This example shows that the subject is not only physics.
Imagine you are flirting with someone, but the reciprocity of their feelings seems inconsistent. You turn to physics to take your mind off it, and while thinking about the equations of a damped pendulum, you understand the dynamics of this relationship.
- Your feelings grow when your companion shows interest and diminish when they are cold. The rate at which your love changes is proportional to their feelings for you.
- Your partner's feelings work the other way around. They reach toward you when you seem indifferent, and lose interest when you show too much attention.
The phase portrait of these equations looks very much like the central part of the pendulum diagram. You will oscillate between affection and repulsion in an endless cycle.
The metaphor of a swinging pendulum in feelings turns out to be not only apt but also mathematically grounded.
If your partner's feelings were additionally slowed when they begin to love too intensely, for example out of fear of becoming vulnerable, the equation would contain a term analogous to friction in a pendulum. Then you both would move toward an inward-winding spiral, that is, toward mutual indifference.
Two dynamical laws that look different, one from physics with one variable and the other from chemistry with two variables, have a similar structure. This is easier to see in the phase portrait. The equations differ: for example, the equations of relationships contain no sine. However, the phase space reveals the common structure.
Methods that are used to study one system often carry over to other systems.
Numerical Solution
Phase diagrams help us understand the behavior of a system. But how do we compute the answer to the equation?
One approach is to simulate the evolution of the system using finite time steps instead of the infinitesimal quantities and limits that underlie analysis.
Procedure:
- Locate a point on the phase diagram.
- Take a step along the vector at that point over a small time interval Δt. The size of the step equals Δt multiplied by the vector.
- Repeat the steps. The endpoint gives an approximation to θ(t), where t is the sum of all the time steps.
The vectors on the diagram are artificially reduced in magnitude, so they must be used with the scale in mind.
If Δt = 0.5, the result will be roughly inaccurate. For example, it will lead to erroneous conclusions about the motion of the pendulum. The cause is the step being too large. If the step is reduced to 0.01, the approximation becomes significantly more accurate. Computing θ(10) requires 1000 steps of 0.01.
A computer performs such repetitions. Repeating a simple operation 1000 times is easy if it is written in a programming language.
Python Program
The program performs the following actions:
- Sets two variables, θ and θ̇, using the initial conditions. In the example, θ₀ = π/3 (60°) and θ̇₀ = 0.
- Organizes a loop that corresponds to a set of small time steps from 0 to the specified moment t. The size of each step is Δt = 0.01.
- At each step, increases θ by θ̇·Δt and increases θ̇ by θ̈·Δt. The value of θ̈ is computed from the differential equation.
- After all the steps, returns the value of θ.
This is called a numerical solution of the differential equation. More sophisticated numerical methods exist that better balance accuracy and efficiency. The loop shown here conveys the basic idea.
Exact solutions cannot always be found, but there are meaningful ways to study differential equations even in this case.
The following materials will cover methods for finding exact solutions when this is possible. Particular attention will be paid to how exact solutions help in studying more general cases that cannot be solved explicitly.
Chaos and the Limits of Predictability
The limitations of exact solutions do not exhaust the difficulties. Chaos theory, one of the major fields to emerge in the last century, has shown that there are additional limits to predictability. They operate regardless of whether a solution exists or not.
For some systems, small deviations in initial conditions, such as unavoidable measurement errors, lead to radically different trajectories. The causes of this phenomenon are already well studied.
The three-body problem, for example, contains the seeds of chaos.
Returning to Strogatz's quote, one might say that the universe has cruelly filled its language with puzzles. Some of them cannot be solved, and for others, any solution is useless for long-term prediction.
This is indeed cruel. Yet it is also encouraging. The complexity of the world around us can be studied with mathematics. It is not hidden in the gap between model and reality.
Introduction and the Language of Change
Differential equations describe change; the laws of physics are written in their language, and this language applies beyond physics as well.
- A quote from Steven Strogatz: since Newton's time, the laws of physics have been expressed in the language of differential equations
- Differential equations arise where it is simpler to describe change than absolute quantities
- Basic knowledge of mathematical analysis and some linear algebra is assumed
ODEs and PDEs
ODEs describe functions of a single input (often time), while PDEs describe functions of several variables, such as the temperature at each point of a body.
- ODEs (ordinary differential equations) are functions with one input, usually time
- PDEs (partial differential equations) are functions with several inputs
- PDEs describe a continuous set of values, while ODEs describe a finite set of values that change over time
Example: Throwing into the Air
The gravitational acceleration g = 9.8 m/s² allows solving a simple equation by integration with initial conditions.
- The second time derivative of y equals -g
- Velocity: -gt + v0; coordinate: -gt²/2 + v0·t + y0
- Initial conditions determine the arbitrary integration constants
Dependence of Force on Position
When a force depends on position, as in gravity between bodies, the equations become interconnected and more complex.
- The gravitational force is inversely proportional to the square of the distance between bodies
- Acceleration is a function of position
- Second-order equations are the most common in physics
Pendulum
The pendulum is described by the equation θ'' = -(g/L)·sin θ; the small-angle approximation with a sine wave turns out to be inaccurate.
- Period of small oscillations: 2π√(L/g)
- Arc coordinate x = Lθ, acceleration θ'' = -(g/L)sin θ
- Accounting for air resistance: term -μθ'
- Check: at θ=0 there is no acceleration, at θ=90° the acceleration is the same as in free fall
Difficulty of the Solution
An exact analytical solution for a pendulum with friction cannot be found, so the properties of the equation are studied without solving it.
- Without damping, the solution is written only through complex functions and integrals
- With damping, there is no known exact solution
- Instead of a solution, one studies computations and understanding of the dynamics
Phase Plane and Vector Fields
The state of a pendulum is defined by its angle and angular velocity; the phase plane and the vector field show all possible trajectories.
- The state is described by the pair (θ, θ')
- Phase-plane trajectories show a spiral toward the origin under friction
- A second-order equation reduces to a system of two first-order equations
- The larger μ is, the faster the spiral converges to the stable state
The Three-Body Problem and Phase Space
The three-body problem has 18 degrees of freedom and lives in an 18-dimensional phase space; in physics, phase space is usually constructed from coordinates and momenta.
- For each body there are 3 coordinates and 3 momentum components, giving 18 degrees of freedom in total
- In physics, phase space is the space of positions and momenta (Hamiltonian mechanics)
- The phase flow resembles the motion of a fluid
Fixed Points and Stability
Fixed points correspond to stationary states; stability is determined by whether the system returns to them after small perturbations.
- The origin corresponds to a pendulum at rest, the point at the top corresponds to the inverted equilibrium
- Stability is checked by the contraction or expansion of the flow near a fixed point
- Detailed calculations are postponed to the following videos
Digression: Love as a Dynamical System
Model of relationships: feelings are described by a system with oscillations resembling a pendulum, which shows the universality of the structure.
- The rate of change of feelings is proportional to the partner's feelings
- With friction in feelings, the system spirals toward mutual indifference
- The phase portraits of the romantic and pendulum systems are similar, although the equations differ
Numerical Solution in Python
Numerical solution of the pendulum equation: time steps with Δt = 0.01 and a simple loop in Python.
- Euler method: θ += θ'·Δt, θ' += θ''·Δt
- For t = 10, 1000 steps are required with Δt = 0.01
- Initial conditions: θ0 = π/3 (60°), θ'0 = 0
- A step of Δt = 0.5 gives a large error
Limits of Predictability and Chaos
Exact solutions are not always available; chaos limits predictability, since small errors in initial conditions produce different trajectories.
- Chaos: small variations in initial conditions lead to vastly different trajectories
- The three-body problem contains the seeds of chaos
- Models and reality may differ, but the complexity of the world is still amenable to study
