Comparing Numerical Methods for ODEs: Euler, Heun, and Runge-Kutta

  • Context: Undergrad 
  • Thread starter Thread starter mamma_mia66
  • Start date Start date
  • Tags Tags
    Numerical Ode
Click For Summary

Discussion Overview

The discussion centers around comparing numerical methods for solving ordinary differential equations (ODEs), specifically Euler, Heun, and Runge-Kutta methods. Participants explore the advantages and disadvantages of each method, as well as considerations for programming languages suitable for implementing these methods in a mini project.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks information on the advantages and disadvantages of Euler, Heun, and Runge-Kutta methods, indicating a need for comparison before selecting a method for a project.
  • Another participant suggests that any reasonable book on Numerical Analysis will provide error analysis for these methods, noting that using more points generally reduces errors.
  • A participant highlights the distinction between explicit and implicit methods, mentioning that implicit methods may be more stable but require solving non-linear equations, which can be cumbersome.
  • Concerns are raised about the implications of step-size in numerical methods, with a caution against reducing step-size too much due to potential finite precision errors.
  • Discussion shifts to programming languages, with one participant advocating for MATLAB due to its ease of use for numerical computations, while others mention C++ as an alternative, questioning the advantages of each language.
  • Some participants express that MATLAB is optimized for matrix operations, making it easier to implement numerical methods compared to C++, which may require additional algorithms for similar tasks.
  • Another participant notes that while MATLAB is a scripting environment with advantages in debugging and execution, it has drawbacks in speed and low-level interfacing.
  • One participant shares a link to a discussion comparing MATLAB and C++, highlighting scenarios where C++ might be preferred, such as speed, transportability of code, and cost considerations.
  • Concerns are raised about the concept of DLL or COM objects, with a participant seeking clarification on these terms.

Areas of Agreement / Disagreement

Participants express a range of views regarding the advantages and disadvantages of different numerical methods and programming languages. There is no consensus on which method or language is superior, and multiple competing perspectives remain throughout the discussion.

Contextual Notes

Participants mention various factors affecting the choice of numerical methods and programming languages, including stability, error analysis, and implementation challenges. However, specific assumptions and definitions are not fully explored, leaving some points unresolved.

mamma_mia66
Messages
51
Reaction score
0
Please someone help me how to find information about the advantages and disadvantages of each method (Euler, Heun and Runge-Kutta). I surched in google and there is nothing useful posted there. We using Dennis Zill textbook for First course of DE. I need to kind of compare them before I use one of them for a mini project. This independent study online course.

Thank you in advance.
 
Last edited:
Physics news on Phys.org
Any reasonable book on Numerical Analysis will have an error analysis for each of the methods you list.

In general the more points you use to compute the next point the smaller your errors will be.
 
Consider whether the method is explicit or implicit (implicit methods require solving non-linear algebraic equations at each time-step which is gah :( , but on the other hand tend to be more stable as far as absolute stability is concerned which is a definite yay :D ) . . . think about the advantages or disadvantages of the method being single-step or multi-step, of methods that are linear versus non-linear methods . . . of methods which are specifically designed for solving "stiff" problems . . . there are advantages and disadvantages to all these aspects, depending too on the differential system you need to solve . . . reducing the step-size when a method is not performing well is not always the best solution because very small step-sizes can lead to problems related to finite precision errors . . . so it's good to look for alternate methods :)

A good book (at least I like:P) is: "Numerical Methods for Ordinary Differential Systems: The Initial Value Problem" by J. D. Lambert.
 
After learning the numerical methods, the next step is to write program for the algorithm. I don't expect we calculate manually. So what is the most appropriate language for doing numerical computation? I would say use Matlab ( sorry this is the only language I know! :approve:)

But I have seen people using C++ to do numerical computation. Is there any advantages of using C++ over MATLAB ? Beside it able to create exe file (stand alone program). Graphic is difficult to display in C++.
 
I'm like yoo matematikawan, I only know Matlab :P I don't think there'd be any advantages or disadvantages to programming the method in any other language (as far as the end results go, as long as you use the same precision to represent numbers), just it would be harder maybe, and take longer to execute, because Matlab is optimized to operate with matrices and for the programmer it's really so easily to operate with them . . so for example how would you do x=A\b in C+, would you have to implement another algorithm just for that? I really don't know . . . but if you do, then I'd stick to Matlab :)
 
Other languages are more flexible and powerful than Matlab. Of course, you don't really need flexibility or power for this project...
 
Other languages are more flexible and powerful than Matlab.

O: Can you tell me which ones, for instance, and in what way? I'd like to know so I can learn xD
 
Well, Matlab is really a scripting environment more than a programming language. It is interpreted, if my recollection is correct, which means that it's never actually compiled to machine code. This has advantages and drawbacks. Advantages include less restrictive syntax and easier debugging / execution. Drawbacks include slower speed and more complex semantics. Also, as a scripting language, interfacing with hardware and using low-level constructs is clunky and/or impossible.

A good discussion can be found at http://www.cpptalk.net/c-vs-matlab-vt47148.html .

Basically, I feel like Matlab is a numerical analysis tool, and that C++ is a general-purpose programming language.

Apparently, Matlab is Turing complete. Still, I wouldn't want to misuse it to write general-purpose programs.
 
Last edited by a moderator:
Thanks for the link the MATLAB vs C++ discussion. I copy here the reasoning by one responden Tuva

...With that said, there are cases whereby one still might consider C++ for a scientific function library. I can think of three:
A) Matlab code isn't fast enough,
B) Matlab code cannot be transported to a DLL or COM object (for example some of the neural net functions cannot be compiled), or
C) Matlab is too expensive.
But even in those cases I would think long and hard before going C++ entirely...


For the reason A, I don't worry much. I think Matlab is fast enough to do my job. For reason C, I also do not worry. Our department have MATLAB install in almost all PC in the lab. To work at home I can use MATLAB clone Octave.

But I don't understand reason B. What are these DLL or COM object? Never came across before.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 2 ·
Replies
2
Views
6K
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 31 ·
2
Replies
31
Views
8K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
Replies
7
Views
3K