# The improved Euler method

1. Jan 13, 2013

### Jamin2112

The "improved" Euler method

1. The problem statement, all variables and given/known data

Using it on a programming assignment. The description in our course notes is a little confusing, so I need to know whether I'm doing it correctly.

2. Relevant equations

Go to p. 22 of this, if you're so inclined: http://faculty.washington.edu/joelzy/402_notes_bernard.pdf [Broken]

3. The attempt at a solution

Basically, if I have the slopes y'(x0), y'(x1), ...., y'(xn), and of course an initial point y0, I'm getting the next point y(xk) by y(xk) = y(xk-1) + Δx (y'(xk-1)+y'(xk))/2. Right?????

Last edited by a moderator: May 6, 2017
2. Jan 14, 2013

### I like Serena

Re: The "improved" Euler method

Right!

See for instance http://en.wikipedia.org/wiki/Euler_method

Your notes refer to f(yn) while they should actually refer to f(t,yn).
Since you use x instead of t, and y' instead of f, this becomes y'(x,yn).
Or y'(xk,yk) as you have it.

3. Jan 14, 2013

### D H

Staff Emeritus
Re: The "improved" Euler method

Wrong.

There's a huge difference between numerical quadrature and and numerically solving an initial value. The former addresses solving $\int_a^b f(x) dx$. The latter addresses solving $dy/dx = f(x,y)$, $y(x_0) = y_0$. You can't say "y'(xn)" in an initial value problem because the derivative is a function of both x and y.

Note that numerical quadrature can be viewed as a special case of an initial value problem. However, that the derivative of y is a function of x only in numerical quadrature (rather than a function of x and y in an initial value problem) means that numerical quadrature is intrinsically much simpler than an initial value problem.

Euler's method is a simple approach to numerically solving an initial value problem. When the derivative is a function of x only, Euler's method is equivalent to the rectangle rule for numerical quadrature. Another name for your "improved Euler's method" is Heun's method. This simplifies to the trapezoid rule (which what you wrote) for numerical quadrature when the derivative is a function of x only.

Life would be easy if all initial value problems had the derivative as a function of the independent variable only. That simply isn't the case. Oftentimes it's the other way arouund, with the derivative being a function of the dependent variables only.

4. Jan 14, 2013

### Jamin2112

Re: The "improved" Euler method

Ok, I think I understand.

5. Jan 14, 2013

### I like Serena

Re: The "improved" Euler method

You do like to contradict me don't you?

Well, suppose we have the initial value problem:
y' = 2x
y0 = 1

It seems perfectly normal to me to apply Euler's method on it, or the improved Euler's method.

In particular y'(x) can also be written as a function of x and y, that is, as y'(x,y).
It's not wrong, it's just a special case.

6. Jan 14, 2013

### D H

Staff Emeritus
Re: The "improved" Euler method

No. :tongue2:

Yes, it's a special case, but look at what's happening. Suppose you want to integrate from x0 to x1 in N steps. With the trapezoidal rule, you need N+1 derivatives. Compare with Heun's method ("improved Euler"), where the derivative function is called two times every step. You are calling the derivative function N-1 times more often than you need to. There's no need to compute the derivative for both (x,y1) and (x,y2) if the derivative is a function of x only.

The start of chapter 3 (the topic at hand) made it pretty clear that the notes were specific to systems where the derivative function is independent of time:
In this chapter we study dynamical systems consisting of one differential equation with a continuous time variable that are autonomous:
$$\frac{dy}{dt} = y′ = f(y)$$
where y is a function of the independent variable t. The equation is called autonomous because the right-hand side does not depend on t explicitly: the only t dependence is through y = y(t).​
This happens in physical systems quite often. Just a couple of examples: an N-body gravitational system where the bodies are point masses, and a spring/mass/damper system. In the gravitational system, accelerations are functions of position only (or position and velocity if you want a general relativistic solution). In the spring mass damper system, acceleration is a function of position and velocity. There is no direct dependence on time in either problem.

7. Jan 14, 2013

### I like Serena

Re: The "improved" Euler method

Ah well, I guess you are right about the context.
I skipped over that.

For the record, I do object about the book quoting Euler's method, without actually giving Euler's method (or Heun's method or Runge-Kutta's method) or making note that they leave out the t-dependency.