Write a program to demonstrate Newton-Backward Interpolation formula in C language.

Tested on: Turbo C++ Version 4.0Time Complexity: O (n2)Space Complexity: O (n2)Open Source: MIT
1
2
3
        /* program to execute Newton Backward interpolation */
4
	#include <stdio.h>
5
	#include < conio.h>
6
	#define max 50
7
	void main()
8
	{
9
	    float arrx[max + 1], arry[max + 1], diff[max + 1][5], num = 1.0, den = 1.0;
10
	    float x, p, h, y;
11
	    int i, j, k, n;
12
	    printf("Enter the value of n: ");
13
	    scanf("%d", &n);
14
	    printf("Enter the value of x  and y: \n"); /* input data */
15
	    for (i = 0; i <= n; i++)
16
		scanf("%f %f", &arrx[i], &arry[i]);
17
	    printf("nEnter value of x for which value of y is needed: ");
18
	    scanf("%f", &x);
19
	    h = arrx[1] - arrx[0];
20
	    for (i = 0; i <= n - 1; i++) /* calculate first difference */
21
		diff[i][1] = arry[i + 1] - arry[i];
22
	    for (j = 2; j < 5; j++)
23
		for (i = 0; i <= n - j; i++) /*  calculate other  difference */
24
	            diff[i][j] = diff[i + 1][j - 1] - diff[i][j - 1];
25
	    i = n;
26
	    p = (x - arrx[i]) / h; /* search for x0 , y0*/
27
	    y = arry[i];
28
	    for (k = 1; k < 5; k++) /* Apply Interpolation formula */
29
	    {
30
	        num *= (p + k - 1);
31
	        den *= k;
32
	        y += (num / den) * diff[i - k][k];
33
	    }
34
	    printf("Value of y = %f, when x = %f ", y, x);
35
	    getch();
36
	}
37
       
38

Output

1
2
3
        Enter the value of n: 6
4
	Enter values of x and y:
5
	100 10.63
6
	150 13.03
7
	200 15.04
8
	250 16.81
9
	300 18.42
10
	350 19.90
11
	400 21.27
12
	
13
	Enter value of x for which value of y is needed: 410
14
	Value of y = 21.531857, when x = 410.000000
15
            
16
        

Rate the Code

Reviews are published after a quick safety check (usually within 24 hours).

Reviews are public. Developers can see basic device specifications to respond. Learn more

How to run Newton Backward Interpolation Method program in C-Language?

To run Newton Backward Interpolation Method program in C-Language, follow the below mentioned steps:

  1. Copy the Code: Press the copy button in the code block to copy the complete code.
  2. Open Turbo C++ Version 4: Open the Turbo C++ (Version 4) software on your system.
  3. Paste the code: Paste the copied code into Turbo C++’s editor.
  4. Compile the Code: Compile the program by pressing the Alt+F9 keys. This shows you the errors and warnings, if any.
  5. Run the code: Press the Ctrl+F9 keys to run the program if the program is successfully compiled.
  6. Enter the Input: Provide the required inputs or your desired inputs, if applicable.
  7. Receive the Result: Get the result of the program on the screen based on the provided inputs.

More about the Newton-Backward Interpolation Formula

Discovered by: Sir Isaac Newton

Discovered Year: 17th Century

To find past estimated data points from the serial table based on the ending part of the table, the interval gap in the table should be equal.

Difference between Newton-Backward and Newton-Forward Interpolation

  • The Newton-Forward Formula is used to find the estimated data at the beginning of the table data.
  • The Newton-Backward Formula is used to find the estimated data at the end of the table data.

How does Newton-Backward Interpolation work?

  1. At the basis of ending values the Backward difference table is created.
  2. Then the below-mentioned formula is applied

    Image
    Where
    Image
    and xn is the last point of the table.

Why is Newton-Backward Interpolation used?

When you have serial data and want to find the latest or last point near values, this formula is most accurate.

Real-Life Examples of Newton-Backward Interpolation

  1. Calculate the gap between records: To calculate the gap between the last records for sensor monitoring and engineering.
  2. Financial and Business Reporting: Used to find the last missing data, like any data or month data out of quarterly or yearly.

Limitations of Newton-Backward Interpolation

  1. Equal Interval Gap Condition: To use this method, all the internal gaps must be equal.
  2. Best for End Values only: This method can be used to find the solution for the end values of the table, but for the beginning values there are high chances of errors.
  3. Predict the record only: Due to interpolation, it is more suitable for past prediction data but not for future prediction, such as stock price or market prediction.

Alternative methods

  1. Newton-Forward Interpolation : To find out the solution for the beginning values of the table, Newton-Forward Interpolation is more suitable.
  2. Lagrange’s Interpolation Formula : If the gap between intervals is not equal, then Lagrange’s Interpolation Formula is more suitable.
License: This program's source code is open-sourced under the MIT License, while the rest of the program's text content and overall dhimanp platform and brand content remain proprietary under dhimanp.

Submit your modified code

Your submissions are published after a quick safety check (usually within 7 days).

Submissions are public. Developers can see basic device specifications to respond. Learn more

Disclaimer

The information that you shared with us will be publicly visible, and everyone can see your information. And we (dhimanp) are not responsible if anyone misuses this information. We can remove any submitted code at any time for better transparency.

Privacy Policy

If you share your data with us by submitting your code for credit, then we may show your full name, school or college name, and city name on our website.

We are not using this data to track you and are not selling this data to anyone.

If you want to remove your name from our website, you can contact us, and we will remove your name from our website. In the removal process, full credit, including your full name, school or college, city, and code, will be removed from our website.