Important Questions -- Numerical Methods
Module 2 -- Interpolation
1. Newton's forward and backward interpolation
🔢 Sample Dataset (Equally Spaced x-values)
1 | 1 |
2 | 8 |
3 | 27 |
4 | 64 |
5 | 125 |
✅ This is based on
- Newton’s Forward Interpolation to estimate
- Newton’s Backward Interpolation to estimate
Step 1: Build the difference table
1 | 1 | ||||
7 | |||||
2 | 8 | 12 | |||
19 | 6 | ||||
3 | 27 | 18 | 0 | ||
37 | 6 | ||||
4 | 64 | 24 | |||
61 | |||||
5 | 125 |
and the step size
Step 2: Find
For forward interpolation, we choose :
So, for
For backward interpolation, we choose:
for
Step 3: Forward and Backward Interpolation
Forward Interpolation formula:
So,
Backward Interpolation formula
So,
If you apply both the values of
2. Lagrange Interpolation and Newton's Divided Difference Interpolation
The formula
Given a set of n+1 data points:
the Lagrange interpolation polynomial
where the Lagrange basis polynomial
Let's practice an example to clear this up.
📊 New Dataset (Unequally spaced x-values):
x | f(x) |
---|---|
1 | 2 |
3 | 10 |
4 | 22 |
7 | 70 |
Find
Or better yet we can write the dataset like this:
1 | 3 | 4 | 7 | |
---|---|---|---|---|
2 | 10 | 22 | 70 |
which can be considered pairs of the following format:
Step 1: Create the Lagrange Polynomials
- Hide
. Then the polynomial should be like this.
In the denominator write the same terms but replace
- Hide
- Hide
- Hide
For
We put
So,
Using Newton's Divided Difference Interpolation
So again we have the dataset.
1 | 3 | 4 | 7 | |
---|---|---|---|---|
2 | 10 | 22 | 70 |
Step 1: Build the difference table
1 | 2 | |||
3 | 10 | |||
4 | 22 | |||
7 | 70 |
Then use this formula:
So,
Module 3 -- Numerical Integration
1. Trapezoidal Rule
- Formula:
All terms except the first and last one are multiplied by 2.
Approximate the value of:
with 4 sub-intervals
Step 1: Find step size
Step 2: Calculate values
Step 3: Evaluate the values for
Step 4: Apply Trapezoidal rule.
2. Simpson's rule
- Formula:
All terms besides the first and last ones are multiplied by constants. Odd terms are multiplied by 4, even terms are multiplied by 2.
Approximate the value of:
till
Step 1: Find
Step 2: Calculate values
Step 3: Calculate values
Step 4: Apply formula
Module 5 -- Solutions to a non-linear algebraic equation
1. The Bisection Method
Algorithm
- Initial Bracket: Choose
and so that . - Midpoint: Compute the midpoint
. - Test Sign:
- If
(or is close enough to zero), then is the root. - If
, set ; otherwise, set .
- If
- Repeat: Continue the process until the interval
is sufficiently small or until the error is less than a predetermined tolerance (or till c stops changing).
- Given Equation:
Let's go with the classic combination of 1,-1
Their product is not less than zero, so we need another separate interval.
Let's try (1, 2)
And,
So, we have a valid interval as
So we find the midpoint
and
So far, we have had:
Iteration | midpoint ( |
|||
---|---|---|---|---|
1 | 1 | 2 | 1.5 | -0.125 |
Let's continue this till the value of
Iteration | midpoint ( |
|||||
---|---|---|---|---|---|---|
1 | 1 | 2 | 1.5 | -2 | -0.125 | Yes, set a = c |
2 | 1.5 | 2 | 1.75 | -0.125 | 1.609 | No, set b = c |
3 | 1.5 | 1.75 | 1.625 | -0.125 | 0.660 | No, set b = c |
4 | 1.5 | 1.625 | 1.5625 | -0.125 | 0.252 | No, set b = c |
5 | 1.5 | 1.5625 | 1.53125 | -0.125 | 0.005 | No, set b = c |
6 | 1.5 | 1.53125 | 1.515625 | -0.125 | -0.034 | Yes, set a = c |
7 | 1.515625 | 1.53125 | 1.5234375 | -0.034 | 0.012 | No, set b = c |
8 | 1.515625 | 1.5234375 | 1.51953125 | -0.034 | -0.010 | Yes, set a = c |
9 | 1.51953125 | 1.5234375 | 1.521484375 | -0.010 | 0.00062 | No, set b = c |
10 | 1.51953125 | 1.521484375 | 1.516007813 | -0.010 | -0.0317 | Yes, set a = c |
11 | 1.516007813 | 1.521484375 | 1.518746094 | -0.0317 | -0.0156 | Yes, set a = c |
12 | 1.518746094 | 1.521484375 | 1.520115235 | -0.0156 | -0.0075 | Yes, set a = c |
13 | 1.520115235 | 1.521484375 | 1.520799805 | -0.0075 | -0.0034 | Yes, set a = c |
14 | 1.520799805 | 1.521484375 | 1.52114209 | -0.0034 | -0.0014 | Yes, set a = c |
15 | 1.52114209 | 1.521484375 | 1.521313233 | -0.0014 | -0.00039 | Yes, set a = c |
16 | 1.521313233 | 1.521484375 | 1.521398804 | -0.00039 | 0.00011 | No, set b = c |
17 | 1.521313233 | 1.521398804 | 1.521355567 | -0.00039 | -0.000143 | Yes |
After 17 iterations, the midpoint
2. The Regula-Falsi Method
Algorithm
We start off similar to how we do in the Bisection Method
- Initial Bracket: As with bisection, choose
and so that , that is, and should have opposite signs. - Interpolation: Compute the new estimate using the formula:
- Test sign:
- If
(or is close enough to zero), then is the root. - Otherwise, if
, set , else set
- If
This method should get the root faster than the bisection method.
For the same equation:
We know already know the intervals, 1 and 2.
and
Compute
Iteration | midpoint ( |
||||||
---|---|---|---|---|---|---|---|
1 | 1 | 2 | 1.33 | -2 | 4 | 1.954 | Yes, set a = c |
2 | 1.33 | 2 | 0.690 | 1.954 | 4 | -2.36 | No, set b = c |
3 | 1.33 | 0.690 | 1.040 | 1.954 | -2.36 | -1.914 | No, set b = c |
4 | 1.33 | 1.040 | 1.183 | 1.954 | -1.914 | -1.525 | No, set b = c |
5 | 1.33 | 1.183 | 1.247 | 1.954 | -1.525 | -0.306 | No, set b = c |
6 | 1.33 | 1.247 | 1.258 | 1.954 | -0.306 | -1.266 | No, set b = c |
7 | 1.33 | 1.954 | 1.466 | 1.954 | -1.266 | -0.315 | No, set b = c |
8 | 1.33 | 1.466 | 1.530 | 1.954 | -0.315 | 0.056 | Yes, set a = c |
9 | 1.530 | 1.466 | 1.5210035 | 0.056 | -0.315 | -0.0022 | No, set b = c |
10 | 1.530 | 1.5210035 | 1.5213772 | 0.056 | -0.0022 | -0.0000147 | No, set b = c |
11 | 1.530 | 1.5213772 | 1.52137969 | 0.056 | -0.0000147 | -0.00000009816 | Yes. |
We see that
So the most precise real root is
3. Newton-Raphson Method
-
Initial Guess: Start with an initial guess
. -
Iteration: Compute the next approximation using:
Taking the same equation again,
And the derivative of this function is:
Let's keep the initial guesses:
Now we choose
A general rule of thumb is to take the midpoint between the two initial guesses if one of the guesses'
So,
So,
and
Let's continue this till
So,
For
For
For
For
Again we see that the value repeats till 5 decimal places, so we stop the process here.
The most precise real root is:
Module 6 -- Solutions to an ODE.
1. Euler's Method
Formula
If you know
Note that we only calculate the derivative of
And it requires very small step sizes.
Given ODE:
and
Given step size:
- Find
and
So, we make a table like this:
- At
n | ||
---|---|---|
0 | 0 | 1 |
n | ||
---|---|---|
0 | 0 | 1 |
1 | 0.1 | 1.1 |
where
So, we found
Let's continue till
So,
n | ||
---|---|---|
0 | 0 | 1 |
1 | 0.1 | 1.1 |
2 | 0.2 | 1.22 |
And
2. Runge-Kutta 2nd Order (RK2)
This method is used for 2nd order differential equations.
This is based upon Euler's method by modifying it.
(obtained by using Euler's method)
then, we use this to get :
For the same ODE:
with step size
So,
n | |||
---|---|---|---|
0 | 0 | 1 | 1 |
For
(from Euler's method).
Now:
n | |||
---|---|---|---|
0 | 0 | 1 | 1 |
1 | 0.1 | 1.11 | 1.21 |
So,
Now,
(from euler's method)
n | |||
---|---|---|---|
0 | 0 | 1 | 1 |
1 | 0.1 | 1.11 | 1.21 |
2 | 0.2 | 1.2415 | 1.4415 |
So,
Notice the precision difference?
It gets even more precise in RK4.
Runge-Kutta 4th Order (RK4)
Builds on RK2:
We calculate these 4 stuff first.
And finally :
To not overly confuse you, let's just stick to the previously used:
with step size
and
So,
So,:
Next,
Next,
Finally
which is now much more precise than RK2.
Now for
Next,
Next,
Finally,
which even more precise than RK2.
4. Predictor-Corrector's method
1. Heun's Method.
We’ll look at Heun’s method, a simpler Predictor-Corrector pair (especially good for exams):
It's a 2-step process and a bit similar to RK2.
Step 1: Predictor (Euler's estimate):
Step 2: Corrector (Average slope):
Yeah, it's exactly the same as RK2.
Finite Difference method.
FDM converts differential equations into algebraic equations by replacing derivatives with finite differences.
We commonly solve second-order ODEs like:
We do that using the following formula:
This gives us a system of linear equations which we can solve using methods like Gauss elimination or LU factorization.
The number of values we can find out depends on the internal points — the ones between the boundary conditions.
For example:
with step size [0, 1]
So, the number of points we can have:
Only 4 points.
And we have the boundary values known.
Unknown values:
and
So, for
and $$-h^2 \ \times \ x_i \ = \ -(0.00625 \ \times \ 0.25)$$
So we get an equation :
- For
- For
Now if we solve these three equations we can get all the intermediate values.
That can be done using any of the matrix equation solving methods.