ode / iv problems - cornell university
TRANSCRIPT
Differential Equations
• So far, we have looked at problems involving one or more variables, with either linear or nonlinear relationships between them
• A Differential Equation is simply an equation (or system of equations) that involves both variables and their derivatives
Differential Equations
• For instance, a differential equation might be:dx/dt = sin(t x)
• This says that the change of the variable x as the variable t changes is according to the equation sin(t x).
• In this case, we have two variables. We call t the independent variable (it is the variable we can change) and x the dependent variable
Differential Equations
• As you might imagine, including derivatives of variables as well as the variables themselves complicates things further
• The solution methods we’ve looked at so far are not applicable in this case
• Special case: when the derivative of x depends only on t (i.e. dx/dt = f(t)), in which case we can use quadrature)
Applications
• Differential Equations appear everywhere
• Wave propagation
• Heat dissipation
• Mechanics
Applications
• One of the most familiar rules of mechanics is in fact a differential equation: Newton’s Second Law of Motion:F = ma (Force = Mass x Acceleration)
• If the position of an object is denoted by x, then its velocity (the change in position over time) is dx/dt. The acceleration is then the change in velocity over time, or d2x/dt2 (the second derivative of x w.r.t t)
Applications
• The second law of motion is then:F = m d2x / dt2
• Oftentimes, the force on an object depends only on the current position, velocity, and time, giving us:F(x, dx/dt, t) = m d2x / dt2
• This is a differential equation relating the acceleration of an object to a function of its current position, velocity, and time
Applications
• Some examples of force functions:
• Planetary motion (force is due to gravity, which is dependent on positions alone)
• Springs (again, force is due only to position of object / compression of spring)
• Air resistance (complex function, but the faster something is moving the more resistance it experiences - dependent on velocity and position [higher up == less air])
Classifications of Differential Equations
• There are two main classifications of DE problems: Ordinary Differential Equations (ODEs) and Partial Differential Equations (PDEs)
• An ODE has only one independent variable, and has derivatives with respect to that independent variable
Classifications of Differential Equations
• So, the example we discussed is an ODE: there is a single independent variable (t) and one or more dependent variables (x) with derivatives taken with respect to the independent variable only
• A PDE consists of several independent variables, with derivatives taken with respect to each other (so you may have x, y, dx/dy, dy/dx, etc...)
Classification of Differential Equations
• Examples of ODEs:dx/dt = sin(t x)d2x/dt2 = - x / ‖x‖3
• Examples of PDEs:du/dt = d2u/dx2 (heat dissipation)d2u/dt2 = d2u/dx2 (wave propagation)
Classifications of Differential Equations
• We will focus solely on ODEs in this class
• I will use x’ or x to denote the derivative of a variable with respect to the independent variable (i.e. dx/dt)
Classifications of Differential Equations
• We can also talk about systems of differential equations, much like how we had systems of linear/nonlinear equations.
• So, for instance, our Newtonian Mechanics ODE can be expressed in the 2D plane asfx(x, y, dx/dt, dy/dt) = m d2x/dt2
fy(x, y, dx/dt, dy/dt) = m d2y/dt2
Classifications of Differential Equations
• As usual, it is much easier to represent this using vector notation. We can represent systems of ODEs as
f(x, x, ... , t) = 0
where x is now an n vector, and f represents a set of n equations. This is known as the implicit form of an ODE
Explicit Form
• We would also like to convert our problem into explicit form: on the right hand side is the highest derivative used, and the left hand side is a function of the variables and all lower derivatives
• In general, for an order-n ODE we then have f(x, x’, ... x(n-1),t) = x(n)
• For some ODEs, this is not possible (need root finding strategies instead)
Classifications of Differential Equations
• Given an ODE, the order of the problem is the highest derivative involved in the problem.
• For instance, Newton’s Second Law of Motion is an order-two ODE (because it involves the second derivative of position)F = m d2x / dt2
Converting to Order 1
• The methods we will look at assume that we have a first order ODE. This appears to be a rather limiting requirement
• Fortunately, any order-2 or higher method can be converted to an equivalent order-1 ODE
Converting to Order 1
• Suppose we have an order-2 ODE in one variable (so we have some d2x/dt2 term). Create a new variable y, and add the new equation y = dx/dtIt then follows that dy/dt = d2x/dt2, so we havent changed the problem at all. However, if we replace all occurrences of d2x/dt2 with dy/dt, then we have reduced the order to 1
Classifications of ODEs
• One final classification: in order to solve ODEs, we need to integrate (or approximate the integral).
• Much like indefinite integrals, we end up with a family of possible solutions - in order to end up with a single unique solution, we also need to specify additional constraints
Classifications of ODEs
• Two types of additional constraints are initial values and boundary values
• Initial values specify initial values for each of the dependent variables. Boundary values specify the behavior of the problem on the boundaries (more common in PDEs)
• We will use initial value conditions
Classifications of ODEs
• For instance, in our F=ma ODE, there are a family of possible solutions. In order to narrow it down to one, we need to specify an initial position and initial velocity
Initial Value Problem
• Given all of this, we can now express our ODE in standard form:u = f(u,t)u0 = [initial conditions]
• Note: this gives us a starting value, and a function that gives us the derivative of the function at u,t
Integrating ODEs
• For simplicity, lets assume our ODE is a single equation in one variable; i.e. we havex’ = f(x,t)x0 = [initial conditions]
• We would like to find the function x(t) that represents the value of x at each time t. Obviously, we have x(0) = x0
Integrating ODEs
• We have the function f(x, t) which tells us how x changes as t changes (the slope of x relative to t). Given x(0) = x0, we’d like to find x1 = x(h), where h > 0 is the timestep
• Easiest approach: use the derivative at x(0) and assume the function is linear. Thus, x(h) = x0 + hf(x0, t0)
Integrating ODEs
• This is known as Forward Euler:
for k = 1, 2, ... xk = xk-1 + h f(xk-1, tk-1) tk = tk-1 + hend
Stability and Accuracy
• This is obviously an approximation to the actual ODE, controlled by the choice of stepsize h
• Leads to two questions
• Stability of integration
• Accuracy of result
Stability
• We treat the derivative as effectively constant for the length of the stepsize
• What happens if the derivative changes dramatically over the length of the stepsize?
Stability
• An example: lets take the Newtonian Mechanics example and include a spring force
• For a single particle, a spring force looks like F = -(||x - c|| - rest) (x - c)/||x - c|| where x is the particle position, c is the center of the spring, and rest is the rest length
Stability
• If our stepsize is too large, the force can change dramatically between xi and xi+1, but we aren’t aware of it -- we only “see” the new force at xi+1
• If we step too far, we can end up with an even larger force pushing back towards the center, which if we step too far again...
Stability
• Formally, we say that there are restrictions on the choice of stepsize h in order to ensure stability of the integration
• Stability of a stepsize is problem dependent AND method-dependent (we will look at other methods later)
Stability
• We can sometimes find analytical bounds for the stepsize that ensure stability
• Analyze the integration method on a toy example
Accuracy
• Even when the integration is stable, there is some amount of error due to the stepsize h
• Ideally, we would like to have an error estimate to allow us to intelligently choose the stepsize
Accuracy
• There are two ways of looking at the accuracy: how much error is introduced when going from xi to xi+1 (local error), and how much error is introduced when going from x0 to xn (global error)
• Local error: assume that xi is exact (zero error), and see how much error is introduced when moving to xi+1