MAT1193 – 10b Euler`s Method Not all differential equations have a

advertisement
MAT1193 – 10b Euler’s Method Not all differential equations have a solution. In fact most don’t. What does in mean not to have a solution? Well it means that there isn’t a function that we can write down that we can then take it’s derivative and plug it in to the differential equation to make it true. But even if the differential equation does not have a ‘closed form’ solution that we can write down, we can use numerical methods to come up with an approximate solution. These numerical methods usually take the form of an algorithm or computer program that must be run to find the approximate value of the solution function for any given value of the input variable. The most basic such method for approximating the solution to differential equations is Euler’s method named after the German mathematician Leonhard Euler (1707-­‐
1783; pronounced ‘Oiler’). The idea is very simple. If you know the current time and the state of the system, the differential equation allows you to figure out the rate of change of the output variable. (For pure time differential equations, you only need to know the time, for autonomous differential equations you only need to know the value of the output variable, and for mixed equations you need to know both.) To use the method you first decide on a small time step that we call Δt. This is a parameter for the method. The main assumption behind Euler’s method is that the rate of change changes more slowly than the small time step Δt, so that we can approximate the rate of change as constant for that short length of time. If that assumption is true, then the change in the output variable (call it f) during each time step can be approximated by Δf = (df/dt)*Δt. This is just a version of “rate times time = distance.” To find the value of the variable for some time t, you start with the initial value of the variable (given by the problem) and then just add the change in the variable for each time step. In this way, Euler’s method takes a differential equation that is continuous in time, and approximates it with a discrete time dynamical system. To approximate the solution at time t, you need to repeatedly update the state of the system until you reach t. dq 2
= t + 3 . dt
Suppose q is the mass of some quantity measure in grams and time is measured in seconds. So the rate of change dq/dt is measured in grams/sec (g/sec). Now suppose we want to approximate the value q(3) when we know the initial condition €
q(0)=5 g. Suppose we also take a time step Δt = 1 sec. From the problem we know that we are looking to approximate a function q(t) with an initial condition q at time t=0 (written q(0)) equal to 5. We want the value of q at time t=3. Since our time step is equal to 1, then we’ll need to apply Euler’s method for three time steps. Lets do an example. Suppose we are given the differential equation So we start at q=5. At time t=0, we can find that dq/dt = 0+3 = 3 g/sec. If that rate of change were constant over the first second (Δt = 1 sec) then in that first second the change in mass would be Δq = (dq/dt)*Δt = (3g/sec)*(1 sec) = 3 g. Since the mass increased by 3 grams, we now have an approximate value for the mass at time 1: q(1)≈ 5g+3g = 8g. Now we figure out the rate of change at time t=1 sec. Plugging in to our differential equation dq/dt = 1+3 = 4 g/sec. So the in the next second the change is mass will be Δq = (dq/dt)*Δt = (4g/sec)*(1 sec) = 4 g. Since we started the time step with q(1)≈ 8g, we’ll end with q(2) ≈8g+4g = 12 g. Now we do the third time step and find the rate of change at time t=2 sec: dq/dt = 22+3 = 7 g/sec. So the third second the change is mass will be Δq = (dq/dt)*Δt = (7g/sec)*(1 sec) = 7 g. Since we started the time step with q(1)≈ 12g, we’ll end with q(3) ≈12g+7g = 19 g. So using Euler’s method with Δt = 1 sec, we approximate the value q(3) ≈ 19 g. One way to keep track of all these computations is to make a table, and fill in one row per time step. Some students try to get away with just learning the procedures as a rote thing, but they often make mistakes about what values to use for the various computations. Once you get the idea behind Euler’s method it’s reasonably easy, and the values that you need make sense. A bit of time spent learning what is going on will really pay off. So let’s use the same differential equation as above but use a much more accurate approximation, taking a time step of Δt = .2 sec and approximating the value q(2). For the first time step, we start at t=0 and q=5. We find that rate of change of q = dq/dt = 3. If we assume that this is constant for our time step of Δt = .2 sec, the q will have changed by rate*time = dq/dt* Δt = 3*.2 = .6. If we add this to our initial state we find that q(.2)=q(0)+ Δq = 5+.6 = 5.6. Now we do the same process over and over and write it in a table: Change Time State Rate of Change t q dq/dt Δq=(dq/dt)*Δt 0 5 02+3=3 3*.2 = .6 .2 5.6 .22+3 = 3.04 3.04*.2 = .608 .4 6.208 .42+3 = 3.16 3.16*.2 = .632 .6 6.840 .62+3 = 3.36 3.36*.2 = .672 .8 7.512 .82+3 = 3.64 3.64*.2 = .728 1 8.240 12+3 = 4 4*.2 = .8 1.2 9.040 1.22+3 = 4.44 4.44*.2 = .888 1.4 9.928 1.42+3 = 4.96 4.96*.2 = .992 1.6 10.920 1.62+3 = 5.56 5.56*.2 = 1.112 1.8 12.032 1.82+3 = 6.24 6.24*.2 = 1.248 2.0 13.280 So Euler’s approximation for this differential equation with Δt = .2 sec yields q(2) ≈ 13.28 g. Euler’s method is very general and can be used to approximate the solution to autonomous or mixed differential equations. All that we need to apply are (i) a time step Δt, (ii) an initial condition, and (iii) a procedure for figuring out the rate of change given that we know the current state and/or the current time. The information in (iii) comes from the differential equation that we are trying to solve. Here’s another example: dW
W
=
dt 2t +1 . Use Euler’s method with Δt = .25 to approximate the value W(1.5) . Assume that W(0) = 3. We can write our table Suppose Time State Rate of Change Change
t W dW/dt = W(2*t+1) ΔW=(dW/dt)*Δt 0 4 4/(0+1) = 4 4*.25 = 1 .25 5 5/(2*.25+1)= 3.333 3.33*.25 = .833 .5 5.833 5.833/(2*.5+1)= 2.917 2.917*.25 = .729 .75 6.562 6.562/(2*.75+1)= 2.625 2.625*.25 = .656 1 7.218 7.218/(2*1+1)= 2.406 2.406*.25 = .602 1.25 7.82 7.82/(2*1.25+1)= 2.234 2.234*.25 = . 559 1.5 8.379 So W(1.5) ≈ 8.379. 
Download