Skip to content
MathWorks - Mobile View
  • Accedere al proprio MathWorks AccountAccedere al proprio MathWorks Account
  • Access your MathWorks Account
    • Il Mio Account
    • Il mio Profilo utente
    • Associa Licenza
    • Disconnettiti
  • Prodotti
  • Soluzioni
  • Università
  • Assistenza
  • Community
  • Eventi
  • Acquista MATLAB
MathWorks
  • Prodotti
  • Soluzioni
  • Università
  • Assistenza
  • Community
  • Eventi
  • Acquista MATLAB
  • Accedere al proprio MathWorks AccountAccedere al proprio MathWorks Account
  • Access your MathWorks Account
    • Il Mio Account
    • Il mio Profilo utente
    • Associa Licenza
    • Disconnettiti

Video e Webinar

  • MathWorks
  • Video
  • Home Video
  • Cerca
  • Home Video
  • Cerca
  • Contatta l’ufficio addetto alle vendite
  • Software di prova
5:25 Video length is 5:25.
  • Description
  • Full Transcript
  • Code and Resources

Solving ODEs in MATLAB, 4: Order, Naming Conventions

From the series: Solving ODEs in MATLAB

The digits in the name of a MATLAB ODE solver reflect its order and resulting accuracy. A method is said to have order p if cutting the step size in half reduces the error in one step by a factor of two to the power p+1.

Related MATLAB code files can be downloaded from MATLAB Central

 

A Very important property of a numerical method is its order. The accuracy of the method is proportional to a power of the step size. And that power is called the order.

If h is the step size and p is the order, then the error made in one step is proportional to h to the p plus 1. And the error made in traversing an entire interval is proportional to H to the p.

So this means, if you're using a method of order p, and cut the step size in half, you can expect the overall error to be reduced by a factor of 2 to the p. The order of a numerical method is determined by analysis involving Taylor series during the derivation of the method. But we can also do an experiment to determine the order.

That's what this program does. The input is the name of an ODE solver. And then it's going to do a numerical integration of an ordinary differential equation, just involving t. So the result is the value of an integral. The integral of 1 over 1 plus t squared, from 0 to 1.

We know the exact answer is 1/2. So we integrate that differential equation twice, once with a step size of 0.1, and then with a step size of one half that. We integrate the differential equation, take the final value of y for each of those two integrations, compare those values with the exact answer, take the ratio of those two values. That shows how much the error is decreased when we cut the step size in half.

The log base 2 of that ratio is the order. It should be an integer so we can round it to the nearest integer, and return that value as the value in this function. Let's run our experiment first on ODE1.

We step size of 0.1, this method gets the integral as 0.5389, not very accurate. Cut the step size in half, it gets 0.5191. The ratio of those is two. Logarithm base 2 is 1. So ODE1 has order 1.

Now ODE2-- step size 0.1. 0.499. cut it in half, 0.4998. The ratio of those is close to 4. And so ODE2, we find with this experiment, is getting order 2.

Now let's try classical Runge-Kutta. This is why it's so popular. It's very accurate. We step size of 0.1, we get close to 1/2. Cut the step size in half, we get even closer. The ratio of these two is close to 16. To the log base 2 is 4. So ODE4 has, experimentally, order 4.

So we found that, at least with this single experiment, the ODE solvers 1, 2, and 4, have orders 1, 2, and 4. So as you probably realized, this is why we named them ODE 1, 2, and 4.

This brings us to the naming conventions in the functions in the MATLAB ODE suite. All the functions have names that are variations on the theme ODEpq. That means that the method ODEpq uses methods of order p and q So we've been getting a glimpse of that with our names, ODE 1, 2, and 4.

Here's an exercise. Modify order x to do further experiments involving the order of our ODE solvers. Change it to do other integrals. And check out the order of ODE 1, 2, and 4.

Download Code and Files

Download the code in this video

Related Products

  • MATLAB

Learn More

Explore more resources from Cleve Moler

Bridging Wireless Communications Design and Testing with MATLAB

Read white paper
Related Information
Learn differential equations

Feedback

Featured Product

MATLAB

  • Request Trial
  • Get Pricing

Up Next:

ODE23 compares 2nd and 3rd order methods to automatically choose the step size and maintain accuracy. It is the simplest MATLAB solver that has automatic error estimate and continuous interpolant. ODE23 is suitable for coarse accuracy requirements.
10:36
5: Estimating Error, ODE23
View full series (12 Videos)

Related Videos:

5:34
Solving ODEs in MATLAB, 9: The MATLAB ODE Suite
14:16
Solving ODEs in MATLAB, 11: Predator-Prey Equations
14:16
Solving ODEs in MATLAB, 8: Systems of Equations
15:21
Solving ODEs in MATLAB, 1: Euler, ODE1
9:37
Solving ODEs in MATLAB, 3: Classical Runge-Kutta, ODE4

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (简体中文)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contatta l’ufficio addetto alle vendite
  • Software di prova

MathWorks

Accelerating the pace of engineering and science

MathWorks è leader nello sviluppo di software per il calcolo matematico per ingegneri e ricercatori

Scopri…

Scopri i nostri prodotti

  • MATLAB
  • Simulink
  • Software per studenti​
  • Supporto hardware
  • File Exchange

Prova o Acquista

  • Download
  • Software di prova
  • Contattaci
  • Prezzi e licenze
  • Come acquistare

Impara ad utilizzare i nostri prodotti

  • Documentazione
  • Tutorial
  • Esempi
  • Video e Webinar
  • Formazione

Ricevi supporto tecnico

  • Aiuto all'installazione
  • MATLAB Answers
  • Consulenza
  • License Center
  • Contatta l'assistenza

Informazioni su MathWorks

  • Lavora con noi
  • Sala stampa
  • Missione sociale​
  • Casi dei clienti
  • Informazioni su MathWorks
  • Select a Web Site United States
  • Centro di fiducia
  • Marchi
  • Informativa sulla privacy
  • Antipirateria
  • Stato dell'applicazione

© 1994-2022 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Unisciti alla discussione