Sitemap
Tech Blog

Changing the way organizations look at data

Euler’s Runge-Kutta — Numerical Differentiation

4 min readJan 14, 2023

--

Runge-Kutta is one of Euler’s tools found to use during research. Euler is famous for establishing all sorts of mathematical tools. Still, Runge-Kutta is somehow unique. It is a tool used for numerical data.
This article is the first of the “Euler’s Runge-Kutta” series that aims to explain the analytical origin of the Runge-Kutta and how to use it. This article briefly explains numerical data and how derivation could be applied.

numerical operations (Reference: medium.com)

Working with Numerical data

When everyone is introduced to functions, we are taught that they are what give case problems meaning. What attracts us to them is their simplicity to work with and how they can satisfy us with values and answers but is this the case in real life? What happens in real life is that when we obtain data about a particular problem, we are bound by the gaps between points. Thus we can not obtain a smooth continuous curve, for this is impossible. This will force us to manipulate data to try and work with it, and here lies the motive for Runge-Kutta.

Discrete Data

Points represent observations and data collected about a specific topic. Still, we’d need an infinite number of data to create continuous functions. Hence, what is obtained is called numerical data, which means discrete points. So, what is often seen are these types of plots:

Press enter or click to view image in full size
Discrete Points (Reference: expii.com)

Usually, in a case study, we try to estimate a function that best fits the data and use it as our source of information, but sometimes we need to be foggier for there are a lot of missing values. Runge-Kutta is designed to estimate these points, but before we go on with it, we need to clarify some basic concepts.

Numerical Differentiation

A normal derivative cannot be applied to numerical points. That’s why we use one of the following cases:

In a plot of discrete plots 2D: yi is the image of x at i and xi is the time at i

Backward vs. Centered vs. Forward difference

Assume lag h = xi+1 — xi where 0 < h < 1

The lag should be slight, so we don’t lose a lot of data and keep the margin of error as low as possible.

f’(x) ≈

Get Mhmd Jawad Ahmad’s stories in your inbox

Join Medium for free to get updates from this writer.

Forward differentiation is the difference between the current point at i and i+1:

Press enter or click to view image in full size

Backward differentiation is the difference between the current point i and i-1:

Press enter or click to view image in full size

Central differentiation is the difference between i+1 and i-1:

Press enter or click to view image in full size
Press enter or click to view image in full size
Backward vs. Centered vs. Forward difference (Reference: semanticscholar.org)

When we have a set of points, and we want to find f(n)(x) with one of the differentiation methods, we use a recursive difference to find it. We have the base element, which is:

The thing with this method is that it applies to all three differentiations, but what differs them is how we choose the points where the backward difference is also the forward difference of the previous point; we get:

For forward differentiation:

Press enter or click to view image in full size

For backward differentiation:

Press enter or click to view image in full size

For central differentiation:

· In case of an even number of points:

Press enter or click to view image in full size

· In case of an odd number of points:

Press enter or click to view image in full size

Example: get backward differentiation of f’’’(1) for h = 0.25

Press enter or click to view image in full size
Press enter or click to view image in full size

MATLAB code for this recursive function

Function d = diff(y,h)
n=length(y)
if(n==2)
d = (y(2) - y(1))/h;
else
d=(diff(y(2:n-1),h) - diff(y(1:n-1),h))/((n-1)*h);
end if
end

Summary

This article explained how derivation is applied to numerical data. The following article in this series will focus on Richardson Extrapolation.

--

--