How can the Improved Euler Method be used in programming assignments?

In summary: There is dependence on time in the coefficients of the differential equations, but that's usually taken as a given.
  • #1
Jamin2112
986
12
The "improved" Euler method

Homework Statement



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.

Homework Equations



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

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:
Physics news on Phys.org
  • #2


Right!

Actually, your notes are a bit misleading.
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


Jamin2112 said:
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?
Wrong.

There's a huge difference between numerical quadrature and and numerically solving an initial value. The former addresses solving [itex]\int_a^b f(x) dx[/itex]. The latter addresses solving [itex]dy/dx = f(x,y)[/itex], [itex]y(x_0) = y_0[/itex]. 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


D H said:
Wrong.

There's a huge difference between numerical quadrature and and numerically solving an initial value. The former addresses solving [itex]\int_a^b f(x) dx[/itex]. The latter addresses solving [itex]dy/dx = f(x,y)[/itex], [itex]y(x_0) = y_0[/itex]. 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.

Ok, I think I understand.
 
  • #5


D H said:
Wrong.

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


I like Serena said:
You do like to contradict me don't you?
No. :-p

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.
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.Back to your previous post,
I like Serena said:
Actually, your notes are a bit misleading.
Your notes refer to f(yn) while they should actually refer to f(t,yn).
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:
[tex]\frac{dy}{dt} = y′ = f(y)[/tex]
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


D H said:
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:
[tex]\frac{dy}{dt} = y′ = f(y)[/tex]
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).​

Ah well, I guess you are right about the context. :wink:
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.
It's a bad quote.
 

Related to How can the Improved Euler Method be used in programming assignments?

1. What is the improved Euler method?

The improved Euler method is a numerical method used to approximate the solutions of ordinary differential equations. It is an improvement of the standard Euler method, providing more accurate results.

2. How does the improved Euler method work?

The improved Euler method uses a two-step process to approximate the solution of a differential equation. First, it estimates the slope at the beginning of the interval using the standard Euler method. Then, it uses this slope to approximate the value of the solution at the midpoint of the interval. Finally, it uses this midpoint value to estimate the slope at the end of the interval and calculate the final approximation.

3. What are the advantages of using the improved Euler method?

The improved Euler method is more accurate than the standard Euler method, making it a better choice for solving differential equations. It is also relatively easy to implement and does not require complex calculations.

4. Are there any limitations to the improved Euler method?

Like any numerical method, the improved Euler method has its limitations. It is not suitable for all types of differential equations and may produce inaccurate results for certain equations or initial conditions. It also requires smaller step sizes to achieve higher levels of accuracy, which can be computationally expensive.

5. How does the improved Euler method compare to other numerical methods for solving differential equations?

The improved Euler method is a popular choice for solving differential equations because of its simplicity and improved accuracy compared to the standard Euler method. However, it may not be as accurate as other numerical methods such as the Runge-Kutta method, which uses more intermediate steps to approximate the solution. The choice of method ultimately depends on the specific problem and desired level of accuracy.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
3K
  • Calculus and Beyond Homework Help
Replies
4
Views
3K
  • Calculus and Beyond Homework Help
Replies
6
Views
3K
  • Calculus and Beyond Homework Help
Replies
10
Views
6K
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
4K
  • Calculus and Beyond Homework Help
Replies
1
Views
3K
  • Calculus and Beyond Homework Help
Replies
3
Views
2K
Back
Top