Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Differential Equations
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Books

Lecture Comments (2)

1 answer

Last reply by: Dr. William Murray
Sat Jun 8, 2013 5:57 PM

Post by Ali Momeni on June 6, 2013

You are incredibly clear in your teaching style. One way this could be improved is by using different colors so I can understand the pattern even faster. But thank you this is great.

Euler's Method

Eulers Method (PDF)

Euler's Method

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Lesson Overview 0:32
    • Euler's Method is a Way to Find Numerical Approximations for Initial Value Problems That We Cannot Solve Analytically
    • Based on Drawing Lines Along Slopes in a Direction Field
  • Formulas for Euler's Method 1:57
  • Example 1 4:47
  • Example 2 14:45
  • Example 3 24:03
  • Example 4 33:01
  • Example 5 37:55

Transcription: Euler's Method

Hi and welcome back to, my name is Will Murray.0000

We are covering differential equations, today we are going to study numerical techniques and in particular were going to cover Euler method.0002

Now, we do have another lecture on Euler equations and that is a totally different topic.0010

So, if that is what you are looking for If you are looking from Euler equations then you do not want to be watching this lecture.0016

But you can go over and see another separate lecture on Euler equations so, this is Euler’s method and only go ahead and start explaining what that is all about.0022

So, Euler’s method is a way to find numerical suits approximations for initial value problems that we cannot solve analytically .0031

We have all these techniques to solve differential equations analytically variation parameters and undetermined coefficients of linear equations and separable equations penalties analytic techniques where we can solve sort of using algebraic techniques and find exact solutions.0042

When you use Euler’s method, is when you cannot use those analytic solutions and so, you have to use approximation techniques so, we are going to be doing a lot of computing here there is not a whole lot of theory involved in Euler’s method.0059

But there is a lot of just plain numbers into equations and calculate see how it goes.0072

It is based on drawing lines along slopes in a direction field so, the idea is that you will start at some initial point Let me start at some initial point here and then you will kind of follow the slope along for a while .0078

Then you recalibrate you recheck your slope and follow that slope along for a while and then you recalibrate and so, on and keep doing so, that is kind of the basic idea of Euler’s method is just under there is not not a lot of theory involved it is just a matter of walking along in the solution space and rechecking your slope at every step.0091

So, they show you how the details of that work out what you do is you start at with an initial value problem so, those who always be in the form Y′ = some function of T in Y.0115

See some example of this you will get the hang of it and then you always have an initial point Y t not = Y not .0128

So, what you do is you start at that initial point T not, Y not and then you are going to move over in steps and so, in order to do that you have to know, what your step sizes that is what this value Hs.0135

That is usually given in the context of the problems so, the problem will say solve this such and such a differential equation using Euler’s method with step size 0.1 or 0.05 or 0.5 or something like that.0159

So, the step sizes H that is usually given to you in the context of the problem and what you do is you try to go over from T not Y not and you try to find the next point T1Y1.0167

And from there you find the next point T2Y2and here the equations that she used to do it to get to TN + 1 you just take TN and you add on the step size H .0179

So, you just stepping over a value of H each time it is going over and regular steps in the T direction2get the new Y value you start with the old Y value Y at and you add on H x now, this F TN YN this F TN YN that comes from the differential equation .0195

So, you go back 2 the differential equation and you plug the current value of TN YN into the differential equation and you evaluate that and then multiply by H and that tells you how far your stepping vertically.0220

So, really what this is doing here is it sort of the rate x time kind of thing the H is the time the change in time and the F is the rate because that is the same as Y′ .0234

This sort of keeps track of horizontal steps this is a your taking a horizontal step over from TN to TN +1 and then here your taking a vertical step up from YN to YN +1 .0249

Now, usually in the context of the problem they will tell you a certain value of T where they want you to approximate Y of T and so, what you do is you keep making steps over until you get to the value of T that you looking for so, let us try that out and see how that works in practice.0267

So, your first example we use Euler’s method was step size 0.1 to estimate Y is 0.4 in the initial value problem Y′ = 1+ T - Y and Y0 = 1 .0286

So, let us see how that plays out what this initial condition this Y0 = 1 that tells us that T0 = 0 because of the value of T there and Y0 = 1 that is the initial value of Y that we are given.0302

Were also, given this is F of T, Y that is always the function that Y′ = some function of T, Y and let us remember basic equations for Euler’s method all right them up here in the corner.0321

TN +1 is always equal to TN + H TN + H is the step size and YN + 1 is always equal to Y N+ the vertical step is H x F of TN YN.0337

So, let us start figuring those out the F here the F of T0Y0 F of T0Y0 is F of 01 and now, since F of T Y is 1+ T - Y that is 1 +0-1 which is 0 and so, are were to find out what T1 is T1 is just 0+ H is is T0 + H all right that is T0 + H which is T0 was 0 H is 0.1 .0357

Our Y1 following the formula there is Y N so, Y0 + H x now, F01 is just we are figured out is 0 so, that is just Y0 which we already said was 1.0408

So, we got our T1 right there 0.1 and our Y1 is 1 and now, let us just Keep repeating that procedure F of T1Y1 is F of 0.1, 1 which again F of T Y is 1+ T - Y so, it is 1+0.1-1 which is 0.1 .0424

And so, our T2 is T1 + H so, T1 was 0.1 Hs 0.132 is 0.2 and our Y2 is Y1 + H x 0.1 getting the 0.1 from this 0.1 here so, Y 1 is 1 + now, Hs 0.1 so, 0.15 0.1 is 0.01 which is 1.01.0452

So, that is our T2and there is our Y2 and order to keep going until we get to the T value that were asked for which is that 1 right there like you going to get2T equal 0.4 so, looks like we got2more steps here .0492

So, we go ahead and calculate F of T2Y2which is F of 0.2 and 1.01 which is 1+ T - Y so, 1+0.2-1.01 and that is = 1.2-1.01 is 0.19 and now, we can write down T3is T2 + H which is 0.3 and Y3 is Y2 + H x that value we just we just figured out the F value was 0.19 .0510

Now, the Y2 was 1.01+0.19 x H H is 0.1 so, that is the 0.019 and so, we had those together and we get 1.01 1.019 is 1.029 so, we found our T3 is 0.3 our Y3 is 1.029 3 quarters the way there.0571

Lets find our F of T3 Y3 is F of 0.3 and 1.029 which is again F is 1+ T - Y we get that from the differential equation 1+0.3-1.029 and if we simplify that down we get 1.3-1.029 that is 0.271 .3-.029 .0610

So, now, we can find our T 4 is T3 + H which is 0.4 and our Y 4 = Y3 + H x our F value from above which is .271 which is now, Y3 was 1.029+ now, H is 0.1 so, 0.1×.271 is .0271 and so, if we add up 1.029 and 1 point 0 .271 we get 1 .05610653

Let me summarize here our T 4 Y 4is 0.4 and 1.0561 and so, that value right there is our estimate of the Y value when T is .04 .0706

So, that is our estimate for Y 0.4according to Euler’s method so, they recap and show you what I did here a sort of the basic equations for Euler’s method the TN + 1 is always TN + H YN + 1 is YN + H x F of TN YN where we say F we using this function right here from the differential equation.0728

So, start out T0Y0 comes from the initial condition T00Y0 is 1 and then I plug those into F and it just gives me 0 on the first step I always find my T1 by adding on an 8 sided T1 0.1 Y 1 from that equation is Y0 + H.0753

Now, that is that 0 is going in there just turns out 2 be 1 again soon I got T1 and Y 1 of plug those back in F I got 1 + T - Y and that goes down the 0.1 so, T2 I always think does go through all the T 0.1 0.2 0.3 and 0.4 those are all the T the Y at each step I take the previous Y + H x the F values that .01 is going in there.0776

We found the F value at the next step we got .19 and so, we plug that in to find the next Y3 found the F value there to get .271 and so, that plug-in there to get Y4 that simplify down to 1.0561 and so, I stop there because I was asked to find Y of .0 0.4 so, I stop there because I have got to achieve value of 0.4 and I take my corresponding Y value as 1.0561 .0814

I offer that as my estimate of Y of 0.4 remember Euler’s method is always an estimation game it never actually tells you an exact answer.0850

So, what were going to do in the next problem keep this problem in your hand and keep our answer in your head because what we are going to do in the next problem is we are going to solve this differential equation analytically and were going to find the true solution and compare it with a solution that we came up with here using Euler’s method 2 approximate.0862

So, an example 2 we will solve the initial value problem Y′ = 1+ T - Y and Y 0 equal 1 were to solid analytically.0882

And order to compute Y of 0.4 now, this is the same problem that we solve using Euler’s method in example 1.0895

So, we are going to compare our exact answer that were defined in this example to our approximate answer that we found for example 1 were to see how close they are0903

So, let us work this 1 out we got there we got Y′ = 1+ T - Y will bring the Y on the other side get Y′ + Y = 1+ T .0914

Now, this is a linear differential equation and back to the very beginning of the course and remember my techniques for solving linear differential equations so, if you do not remember how to solve linear differential equations is been quite a long time since we talked about that.0928

But you might want to go back and re-watch that lecture on linear differential equations because we get a whole lecture together a linear differential equations and so, that is most of the something fairly familiar to you by now, .0947

But it is a little rusty just go back and check out the lecture and you will see how to solve it just write down the name linear differential equations.0959

And so, the technique there is to use this thing called the integrating factor where you do I T = E to the integral of P T DT .0971

And the P is whatever the coefficient of the Y is so, this case is just E of the integral of 1 DT which is ET and so, what you do is you multiply both sides by that integrating factor.0988

So, multiply everything Y′ x E T + Y x E T is equal to 1 x E T + T x E T .1004

The point of doing that is that makes the left-hand side into the derivative of Y E T using the product roll again this is all coming straight out of the lecture on linear differential equations 1712 so, go back and check that out if your rusty on that E T + T x E T and so, we can integrate both sides and on the left will just get Y E T on the right will get E T1019

Now, the integral of T E T you really have to use parts and I may use a little shorthand technique for parts T x ET shorthand technique is right derivatives down the left-hand side and integrals down the right-hand side.1051

Then multiply down these diagonal lines with an old with alternating sins and so, I get + T E T - E T + C1070

That was really integration by parts and that was something that we covered here in the lectures on in the calculus to section so, you might want to check the lectures from calculus 2 on how to integrate by parts.1084

We have lecture there on integration by parts and if you do not remember how to do that just go back and watch those lectures and you will see you get a refresher course and integration by parts.1096

So, meantime we got Y ET = R T + T R T - R T + C cancel those as I get Y E T = T E T + C and now, I am going to divide both sides by E T so, get Y = just T by itself + now, if I divide by E T that is the same as multiplying by E -T have to keep track of the C at this point .1107

Now, 2 figure out what the C and when he is my initial condition Y 0 = 1 Y 0 is just equal to 0+ C E 0 which is C and that is both equal 1 so, my C = 1 and play that back into my equation.1142

Y = T + C is just 1 E - T .1163

So, that is my analytic solution to my differential equation and I want to plug-in 0.4 and see what happens there so, Y is 0.4 = 0.4+ E -0.4 .1169

That something that I want to figure out using my calculator so, I am going to go 0.4+ E -0.4 and it tells me it is approximately = 1.703.1188

So, that is what we get solving the equation analytically and let me just remind you what we got using Euler’s method, we use Euler’s method member that was an approximate solution without solving the equation analytically.1213

Euler’s method we did this in example 1 so, Just watch example 1 go back and check that out we found that Y is 0.4 was approximately equal to 1.05611228

That is what Euler’s method gave us so, he left out a 0 when I found my exact solution it was 1.0703 for my calculator told me and I just did not write down that last 0.1247

Here is the solution got by doing Euler’s method and that was example 1 if you have a just watch that.1269

That is where that answer came from and so, we can see how good our approximation was using Euler’s method it was out 1.05 instead of 1.07 which is pretty close it is not perfect but that is the whole price of using approximation techniques is you would not get an exact answer.1279

So, the exact answer would really be 1.0703 but in order to do that we had to solve the equation analytically.1297

Let me show you the various steps involved here first I took the differential equation I move the Y over 2 the other side and then that is a linear differential equation.1307

So, using the techniques we learned in our early lecture on linear differential equations I found the integrating factor in the integral of PNT where PNT here is just 1 there so, we just get E T multiply that by both sides.1317

That turns a left-hand side into the derivative of a product using the product roll so, we integrate both sides we just get Y E T on the left on the right we had integrate by parts T E T ahead integrate by parts course the inability the T by itself is just E T .1332

So, when I integrated by parts again using what we learning calculus 2 we get T E T - E T 2 terms cancel we just get T E T + C .1351

You do have to include the constant when you do the integration is kind of a very T lesson of differential equations and so, will resolve for Y were multiplying both sides by E - T so, get T + C E - T .1364

Then we use the initial condition T is 0 on Y is 1 I played in T0 I set it equal to 1 and I get C = 1 pretty convenient plug that back in to the general solution here and that is how I get the specific solutions the initial value problem Y = T + E-T .1378

That is I compute Y = 0.4 so, plugged in T is equal 0.4 for T plug that in and this is a something I worked out my calculator 1.0703 and I compare that with what we found in example 1 for Euler’s method .1398

Using Euler’s method to look at the same differential equation Y and 0.4 back there we calculated 1.0561 so, we really got 1.05 instead of the true answer would be 1.07.1419

That shows you the Euler’s method is pretty close but it does not give you a perfect solution so, let us keep going here with example 3.1431

Right with example 3 we are going to use Euler’s method was step size H = .01 and will estimate Y .0 for the initial value problem Y′ = T ² + Y ² and Y 0s equal to 1.1442

So, let me set up our starting point here we got T0 = 0 and Y 0 =1 getting those from the initial condition and down than I just remind ourselves of the Euler’s method equations T N+ 1 is always TN + H and Y N+ 1 is always YN + H x F of TN Y N .1459

And that were talking about is this function right here T ² + Y ² so, that is what we are going to use to compute the T ² + Y ² so, my T1 is 0+ H which is 0.1 .1494

My Y 1 is Y0 + H x now, T ² + Y ² is 0 ² +1 ² so, Y0 was 1 and + H x while 0 ² +1 ² is just 1 so, H is 0.1 and got that from over here and so, that is 1.1 and I have a T-1 and I have a Y1 Let us go and find T2 .1513

0+ H is 0.2 my Y2 is Y 1 + H x the function of T-1 and Y 1 so, the function here is T ² + Y ² so, that isis 0.1 ² that is from the T-1 +1.1 ².1553

Now, my Y 1 was 1.1 my H is 0.1 and .1 ² is .01+1.1 ² is 1.21 and so, that gives me 1.1+0.1 x looks like 1.22 and so, that is 1.1+.122 .1579

If we add those together were going to get 1.222 so, now, I have a T2 and I have a Y2 .1615

Keep going to get 2 more steps because were shooting for Y have 0.4 so, T3 is C is a small mistake here when I said T been T-1 + H I do get the right answer was 0.1+0.1 this should be T2+ H which is 0.2+.1 so, .3 .1630

The time stamps are very easy to keep track over to stepping along by 0.1 each time the Y steps are harder Y3 = Y2+ H x F of T2 and Y2 so, that 0.2 was T2+1.222 ², Y2 was 1.222+0.1 and start using a calculator here.1656

0.2 ² is .04 but 1.222 ² so, 1.222 ² is 1.493 and about 1.222+0.1×.04+1.49 is 1.53 and 0.1×1.53 is .153 and so, if I add that to 1.222 I get 1.375 for my Y3.1692

So, T3 and I got Y3 just 1 more step to go T 4 is T3 + H is 0.4 my Y4 is Y3 + H x F of F of T3 and Y3is a T3 was 0.3 and our function value is T ² + Y ² so, 1.375 ² and let me keep going in the new column here.1740

My Y3 was 1.375 my H is 0.1 and 0.3 ² is .09 1.375 ² we get 1.89 and .906 go ahead and add .092that +.09 and then I multiplied by .11784

The rest of this on my calculator and then add 1.375 to that and it looks like it also, provides down to 1.573 so, that was my Y4 remember.1819

And appointed that is the best my estimate for Y of .4 so, I got my T4 and my Y4 summarize that T4 Y 4 is 0.4 and 1.573 53 but 573 so, that right there is my estimate for Y of 0.4.1841

So, let us go back over that make sure that everybody understands all the steps.1872

We start out with G0 = 0Y0 = 1 that came straight from the initial condition and we started stepping through this procedure following the initial equations for Euler’s method.1881

TN + 1 is always TN + H so, my H here is .1 that is how I hate my steps go .1 .2 .3 and .4 that shows you how the T develop the wiser more collocated following this formula it is always YN + H x F of TN YN and this is the F right here.1894

T ² + Y ² so, that is why 2 find Y 1 I took Y0 + H x now, that is T0 NY 0 there that is T0 and Y0 and when I found Y2I did Y 1 + H x that is T-1 and that is Y 1 down here to find Y3 it is Y2+ H x T2 and Y2.1918

And finally to find Y 4 its Y3 + H of that is T3 and that is Y 3, crunch all these numbers we end up with Y4 = 1.573 and I know, that that is where I want to stop because I got into my T value of 0.4 which is what I was asked estimate in the initial example.1949

And so, my Y value 1.573 is my estimate there so, example 4 we use Euler’s method was step size H = .0 or 0.3 and were to estimate Y is 0.6 in the initial value problem Y′ = T - Y and Y0 = 1 suddenly remind you of the equations that we always use for Euler’s method .1972

TN + 1 = TN + H stepping along by values of H and YN +1 = YN + H x F of TN YN.2004

Now, that F is just whatever you get from the differential equation that is F of TY right there so, the way you start is with the initial condition that your givens and that is Y 0 = 1 so, my T0 = 0 and my Y0 = 1 .2020

And I will start stepping through the algorithm but my step sizes H so, T1 = T0 + H which is 0+.3 so, that 0.3 my Y1 = Y0 + H x F of TN YN so, that is T0 - Y0 .2039

I am getting that from here T - Y so, that= now, where to my Y0 there is its 1+0.3 now, T0 - Y0 is 0-1 so, this is 1 +.3 x -1 1-.3 is 0.7 .2065

So, now, I found T1 and 0.3 and Y 1 is 0.792 is T1 + H which is 0.3+0.3=0.6 and my Y2is Y 1 + H x F of T-1 Y1 so, T-1 - Y1 .2088

So, my Y 1 was 0.7+ where to my H go 0.3 now, T1 - Y1 got my T1 was 0.3 - Y 1 was 0.7 and so, this is -0.4 if you must buy that by .3 get -0.12 so, got 0.7-0.12 which is 0.58 .2119

And I'm going to stop there in the reasonable. There is because I was asked to find Y of a 0.6 and look here we got T2 is 0.6 so, I may use my Y2that value as my estimation.2154

So, to summarize there the T2 Y2is 0.6 and then my Y2 was 0.58 and so, I am in a hang on to that 0.58 and offer that as my approximation for Y of 0.6 .2177

So, let me show you the steps again there we sort out T0Y0 came from the initial condition there and we started running through this condition these these equations.2200

The TN +1 steps by point 3H time steps by H each time so, we go from 0 2 .3 2 .6 and then to find the YN +1 we do YN + H x F of TN YN, and our F of T Y is here 2 my T - Y .3710 Since Y CT 0 - Y0 here and T-1 - Y1 here so, we figured out Y 1 was 0.7 Y2 is 0.58 and I stop there because I got into my T value of 0.6 which was the desired 1 from the problem.2212

So, may offer that 0.58 my last Y value as my estimation for Y0 .6 remember this is just an estimate because we are solving this thing numerically weird solving it analytically.2248

What we are going to do in the next example is to solve the same initial value problem analytically will see how close our answer is to the answer we just figured out.2262

So, in example 5 here we will solve the initial value problem Y′ = T - Y and Y0 = 1 were solid analytically using what we learned much earlier in this lecture series.2279

Remember, calculate Y0 .6 and compare with the answer with the result given by Euler’s method we figured that out in example 4 so, let us go ahead and start solving this .2289

I am not right Y′ + Y = T and now, this is a linear differential equation and we learned how to solve linear differential equations in 1 of the very early lectures here in the differential equation series on .2301

What you do is you find the integrating factor = E to the integral of P of T DT where your P is whatever the coefficient of Y is right there in this case that is just 1 so, in the integral of 1 DT is just E T .2322

And so, you multiply both sides by that integrating factor so, we get Y′ ET + Y ET =2E T .2341

And then the point of that is what we learned in electron linear differential equations is that the left-hand side is the derivative of Y E T using the product role right-hand side of T E T so, we can integrate both sides.2354

Left will just get Y ET because were integrating a derivative and on the right now, many use parts any as integration by parts which is something we learned about in the calculus2lectures here on is 1 of the early results there.2373

So, in the integrate T E T using integration by parts is using tabular integration it is kind of a shorthand to solve certain integration by parts problems so, writing derivatives on the left integrals on the right and then I am going to put my alternating sins + and - sin it T E T - in the T .2390

And I will is have to attach a constant at the moment when I do the integration and so, I am going to solve for Y there divide sides by E T so, get Y = T-1+ C by E T that is the same as CE -T .2416

And that is my general solution now, I am going to use the initial condition Y0 = 1 so, 0 = 0-1+ C 0 and that is supposed 2 be equal 1 .2435

And so, what I see quickly here is that C must be 2 because E 0 is 1 and all play that back in my general solution Y is equal 2 T -1+2 in the negative T.2451

And so, that is my solution to the initial value problem Y = T -1+2 in the negative T and I wanted to compute Y of 0.6 so, the plug-in 0.6 for T 0.6 is 0.6-1+2 E -0.6 which it looks like that would be -0.4+2E of the -0.6 .2467

Indefinitely is my calculate for that so, -.4+ 2E to the -.6 and that gives me well approximately if I just take the first 2 decimal places 0.6976 as an answer.2504

And that is really an exact well that is very close to being an exact answer let me remind you what we got using Euler’s method so, we can see how accurate are Euler’s method answer was.2529

In Euler’s by using Euler’s method we did this in example 4 so, you can go back and check out example 4 if you are not sure where this is coming from we got Y of 0.6 .2545

Our estimation from there was 0.58 so, that is the estimation that Euler’s method gave us Y 0.6 0.58 the true solution according for analytic techniques is 0.6976 .2558

So, we got something fairly close but obviously not completely accurate so, Let me remind you what we did with this we saw a linear differential equations were many use my solution techniques for linear differential equations and that is to use the integrating factor.2579

This is coming from the lecture very early on in this series a linear differential equations into E integral of P of T were PT is the coefficient of Y so, here is just E integral of 1 so, that is E T .2596

Multiply that by both sides that turns the left-hand side into the derivative of our products are really kind of explaining the product role there so, if we integrated we just get that original product back Y E T .2609

On the right-hand side we had to use integration by parts to get E T - E T + C and so, solving for Y that means multiplying both sides by E -T .2622

This is what we get for general solution that we as the initial condition Y0 = 1, plug that back in and we get C = 2 so, I plugged that back into the general solution and that is how I got my specific solution here T -1+2 E-T and out to estimate Y is 0.6 .2635

Plug that in for T and I get something that I certainly would not want to do by hand but on a calculator.2658

That tells me it is 0.6976, and want to compare that with my answer from Euler’s method we worked out the answer from Euler’s method in example 4 set for this number 0.5 A comes from.2667

Worked on that just above an example 4 so, that is the Euler’s method answer the true answer is 0.6976 and so, you can see that 0.58 versus 0.69 we were fairly close with Euler’s method we were not completely accurate.2680

In the next lecture here on not the differential equations lecture series, we will talk about the Dakota method and will solve the same problem receive to get something much more accurate and so, will compare that answer whether Euler’s method answer will see that for the price of doing a little more computation, we can get a much more accurate solution.2695

So, that is the end of our lecture here on Euler’s method as part of the differential equations lecture series on My name is Will Murray, thanks for watching, bye bye.2718