Interpolation refers to the process of creating new data points specified in a given dataset. The code below calculates the required data point in a given range of discrete datasets using a formula given by Gauss, and this method is known as the Gaussian forward method.
Gaussian forward method:
Gaussian interpolation falls under the Central Difference Interpolation Formulas. Suppose we are given the following value y = f (x) for given values of x:
X: x0 x1 x2 ………. xn
Y: y0 y1 y2 ………… yn
Differences y1 — y0, y2 — y1, y3 — y2, ……, yn — yn - 1, denoted as Δy0, Δy1, Δy2, ……, Δyn - 1, respectively, are called the first forward differences. So the first forward differences are:
Δy 0 = y 1 — y 0
and in the same way we can calculate higher order differences.
And after creating the table, we calculate the value using the following formula:
Now let’s take example and solve it for better understanding.
Problem:
In the following table, find the value of e 1.17, using the Gauss Forward formula.
x | 1.00 | 1.05 | 1.10 | 1.15 | 1.20 | 1.25 | 1.30 |
ex | 2.7183 | 2.8577 | 3.0042 | 3.1582 | 3.3201 | 3.4903 | 3.6693 |
Solution:
We have
y p = y 0 + pΔy 0 + (p (p-1) / 2!). Δy 2 0 + ((p + 1) p (p-1) / 3!). Δy 3 0 + ...
where p = (x 1.17 — x 1,15 ) / h
and h = x 1 — x 0 = 0.05
so p = 0.04
Now we need to calculate Δy 0 , Δy 2 0 , Δy 3 0 ... etc.
Put the required values into the formula
y x = 1 , 17 = 3.158 + (2/5) (0.162) + (2/5) (2/5 — 1) / 2. (0.008) ...
y x = 1.17 = 3.2246
Code: Python code to implement Gauss Formula
|
Output:
1 2.7183 0.1394 0.0071 0.0004 0.0 0.0 0.0001 1.05 2.8577 0.1465 0.0075 0.0004 0.0 0.0001 1.1 3.0042 0.154 0.0079 0.0004 0.0001 1.15 3.1582 0.1619 0.0083 0.0005 1.2 3.3201 0.1702 0.0088 1.25 3.4903 0.179 1.3 3.6693 at 1.17 is 3.2246