ODE / IV Problems CS3220 - Summer 2008 Jonathan Kaldor
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 d 2 x/dt 2 (the second derivative of x w.r.t t)
Applications • The second law of motion is then: F = m d 2 x / dt 2 • Oftentimes, the force on an object depends only on the current position, velocity, and time, giving us: F(x, dx/dt, t) = m d 2 x / dt 2 • 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) d 2 x /dt 2 = - x / ‖ x ‖ 3 • Examples of PDEs: du/dt = d 2 u/dx 2 (heat dissipation) d 2 u/dt 2 = d 2 u/dx 2 (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 as f x (x, y, dx/dt, dy/dt) = m d 2 x/dt 2 f y (x, y, dx/dt, dy/dt) = m d 2 y/dt 2
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 d 2 x / dt 2
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 d 2 x/dt 2 term). Create a new variable y, and add the new equation y = dx/dt It then follows that dy/dt = d 2 x/dt 2 , so we havent changed the problem at all. However, if we replace all occurrences of d 2 x/dt 2 with dy/dt, then we have reduced the order to 1
Converting to Order 1 • Example: F = ma
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) u 0 = [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 have x’ = f(x,t) x 0 = [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) = x 0
Integrating ODEs x f(x 0 , t 0 ) x 0 t
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) = x 0 , we’d like to find x 1 = 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(x 0 , t 0 )
Integrating ODEs x f(x 0 , t 0 ) x 0 x 1 h t
Integrating ODEs x f(x 0 , t 0 ) f(x 1 , t 1 ) x 0 x 1 x 2 h h t
Integrating ODEs • This is known as Forward Euler: for k = 1, 2, ... x k = x k-1 + h f(x k-1 , t k-1 ) t k = t k-1 + h end
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 x i and x i+1 , but we aren’t aware of it -- we only “see” the new force at x i+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 • (Example using Springies)
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 x i to x i+1 (local error), and how much error is introduced when going from x 0 to x n (global error) • Local error: assume that x i is exact (zero error), and see how much error is introduced when moving to x i+1
Accuracy • Global error: how much error is there comparing x n and x(t n ), where x(t) is the true solution started at the initial condition x 0 = x(0)
Recommend
More recommend