Javatpoint Logo
Javatpoint Logo

Newton Forward Interpolation in C

Newton's Forward Interpolation is a numerical method used to approximate the values of a function at points that lie between given data points. This technique is particularly useful when the data points are equally spaced. It's a form of polynomial interpolation where a polynomial of a certain degree is constructed to pass through the given data points. After that, this polynomial is used to estimate the function values at intermediate points.

The interpolation method is named after Sir Isaac Newton, who significantly contributed to calculus and interpolation techniques.

Process of Newton's Forward Interpolation:

Given Data:

You start with data points (x_i, y_i), where x_i are median values and y_i are the corresponding function values. These data points are typically sorted in ascending order of x.

Divided Differences:

Divided differences form the basis of Newton's Forward Interpolation. They are calculated recursively based on the given data points. The divided differences are defined as follows:

For j = 0, f[i][0] = y_i (i.e., the original y values).

For j > 0, f[i][j] = (f[i+1][j-1] - f[i][j-1]) / (x_i+j - x_i).

Here, i represents the index of the data point, and j represents the order of the divided difference.

Interpolating Polynomial:

Using the calculated divided differences, you can construct an interpolating polynomial of the form:

P(x) = f[0][0] + (x - x_0)f[0][1] + (x - x_0)(x - x_1)f[0][2] + ...

After that, this polynomial is used to approximate the function values at points between the given data points.

Estimating Function Values:

Once you have the interpolating polynomial, you can substitute a desired x value into the polynomial to estimate the corresponding function value at that point.


There are several benefits of the Newton's Forward Interpolation. Some benefits of the Newton's Forward Interpolation are as follows:

Simplicity and Ease of Implementation:

Newton's Forward Interpolation is simple to understand and implement. The method involves a step-by-step process of calculating divided differences and constructing the interpolating polynomial. This simplicity makes it accessible to beginners in interpolation techniques and numerical analysis.

Flexibility in Degree:

It offers flexibility in choosing the degree of the interpolating polynomial. It means you can modify the degree to the complexity of the function being approximated and the desired level of accuracy. Higher-degree polynomials can capture more intricate behavior, while lower-degree polynomials yield simpler approximations.

Application to Smooth Curves:

Another advantage of Newton's Forward Interpolation is its suitability for functions with relatively smooth behavior between data points. When the underlying function exhibits gradual changes or smooth transitions, the method provides accurate approximations that closely follow the function's behavior. This characteristic is particularly advantageous when dealing with real-world data exhibiting gradual variations.


There are several limitations of the Newton's Forward Interpolation. Some limitations of the Newton's Forward Interpolation are as follows:

Sensitivity to Data Changes:

While the algorithm can handle changes to the dataset, it might exhibit sensitivity to drastic changes or outliers. Rapid fluctuations or irregular behavior in the data can lead to oscillations in the interpolated polynomial. These oscillations can result in inaccurate approximations and a loss of reliability.

Inaccurate Extrapolation:

Newton's Forward Interpolation must be better suited for extrapolation beyond the range of provided data points. Attempting to estimate values outside this range can yield reliable and accurate results. Extrapolation with interpolation methods can introduce significant errors and should be avoided.

Decreasing Accuracy with Distance:

As you move further from the midpoint between two data points, the accuracy of the interpolated values tends to decrease. This limitation is particularly pronounced for functions with quick changes, sharp discontinuities, or high-frequency oscillations. The method's precision diminishes as you move away from the center of the data interval.


Step-1: Read the number of data points, n. Read the n equidistant x values and corresponding y values into arrays x and y.

Step 2: Calculate the common difference, h, between consecutive x values: h = x[1] - x[0]. Initialize a 2D array f to store divided differences.


  • For each data point i from 0 to n - 1, set f[i][0] = y[i].
  • For each order of divided differences j from 1 to n - 1:
  • For each data point i from 0 to n - j - 1, calculate:
  • f[i][j] = (f[i+1][j-1] - f[i][j-1]) / (x[i+j] - x[i]).

Step-4: Read the value of x_interp, the point where interpolation is desired. Initialize the result to f[0][0] (the first divided difference). After that, initialize term to 1.0.

Step-5: For each data point i from 0 to n - 1. Multiply term by (x_interp - x[i]).

Update result by adding f[0][i+1] * term.

Step-6: Print the interpolated value of the function at x_interp, along with the provided x and y values.

Note: This algorithm assumes equidistant data points and is specific to Newton's Forward Interpolation method.


Let's take an example to understand the use of the Newton's Forward Interpolation method in C.


Enter the number of data points: 4
Enter the central x values:
1.0 2.0 3.0 4.0
Enter the corresponding y values:
2.0 4.0 8.0 16.0
Enter the value of x for interpolation: 2.5
Interpolated value at x = 2.50 is 7.875000


  • First, the program starts by including the necessary header file h, which provides functions for input and output. The main function is the entry point of the program.
  • The program asks the user to enter the number of data points (n). It determines the number of x and y values the user will provide.
  • Two arrays, x and y, are declared to store the central x values and their corresponding y values.
  • The program uses a loop to read the central x values from the user and store them in the x array.
  • After that, another loop is used to read the corresponding y values from the user and store them in the y array.
  • The common difference h between consecutive x values is calculated as h = x[1] - x[0]. This difference is used later in the divided difference calculations. A 2D array (f) is declared to store the divided differences.
  • The divided differences are initialized by copying the y values into the first column of the f array.
  • Two nested loops compute the divided differences for each order j. The formula used for calculation is (f[i+1][j-1] - f[i][j-1]) / (x[i+j] - x[i]).
  • The program prompts the user to input the value of x for which interpolation is desired.
  • A loop calculates the interpolated value using Newton's Forward Interpolation formula. The result is updated at each iteration of the loop.
  • After that, the interpolated value is printed using the printf function, displaying the provided x value and the interpolated result.
  • The program returns 0, indicating successful execution, and the main function
  • This code implements Newton's Forward Interpolation method to approximate a function's value at a given point using the provided central data points. The provided input values will influence the outcome, and the program will calculate and display the interpolated value based on the input data.

Complexity Analysis:

Time Complexity:

  • The code reads the number of data points, equidistant x values, and corresponding y values. It involves reading n data points with an O(n) linear time complexity.
  • The code initializes the divided differences array, which requires iterating through all n data points and filling in the initial column of the f array. It is performed in O(n) time complexity.
  • The nested loops compute the divided differences for each order j.
  • The outer loop runs for n - 1 iterations, and the inner loop iterates up to n - j times, resulting in a time complexity of O(n^2).
  • The loop used for evaluating the interpolating polynomial iterates n times. It is O(n). The printing of the interpolated value takes constant time complexity, O(1).
  • Overall, the dominant time complexity comes from the computation of divided differences: O (n^2). Thus, the total time complexity of the code is O(n^2).

Space Complexity:

  • The arrays x and y each store n data points, contributing to a space complexity of O(n).
  • The 2D array f storing divided differences has dimensions n x n, resulting in a space complexity of O(n^2).
  • The other variables used in the code (like h, x_interp, result, term, loop counters, etc.) occupy constant space.
  • The most significant contribution to the space complexity comes from the divided differences array, O(n^2). Thus, the total space complexity of the code is O(n^2).


Newton's Forward Interpolation finds application in various fields where there is a need to estimate function values between known data points. Newton's Forward Interpolation plays a vital role in filling gaps between data points and producing a more comprehensive understanding of the underlying phenomena in each of these applications. The choice of interpolation method depends on the specific characteristics of the data, the accuracy required, and the specific goals of the analysis. Some common applications include:

Engineering and Physics:

In engineering and physics experiments, measuring data at every point is often impractical due to time, cost, or physical limitations. For example, data might be collected at specific intervals when conducting stress-strain tests on materials. Newton's Forward Interpolation helps estimate stress or strain values between those data points, providing a more complete view of the material's behavior.

Computer Graphics:

In computer graphics, curves and shapes are often defined by control points. Newton's Forward Interpolation can generate smooth curves between these control points, creating visually pleasing and realistic graphics. Bezier curves and B-spline curves are popular examples that use interpolation to create curves used in graphics design and animations.

Geographic Information Systems (GIS):

GIS applications involve working with spatial data to create maps and analyze geographical phenomena. In GIS, data is often collected at specific locations, resulting in discrete data points. Interpolation techniques, including Newton's Forward Interpolation, help estimate values at non-sampled locations, producing continuous spatial surfaces for attributes like elevation, temperature, and population density.

Finance and Economics:

In finance, financial instruments like bonds and options have continuously changing values. However, market data is often available at discrete intervals. Newton's Forward Interpolation assists in estimating the values of these financial instruments at any given time, allowing investors and analysts to make informed decisions.

Scientific Data Analysis:

In scientific research, data collection can be influenced by factors such as time constraints or limitations of measurement devices. Newton's Forward Interpolation helps fill in the gaps in data, enabling researchers to analyze trends and patterns more accurately. For example, in climate science, it's used to estimate historical temperature values between irregularly collected weather data.


There are several characteristics of the Newton's Forward Interpolation. Some characteristics of the Newton's Forward Interpolation are as follows:

Equally Spaced Data Points:

Newton's Forward Interpolation is most effective when the provided data points are equally spaced along the x-axis. Equidistant data points simplify the calculation of divided differences, which are essential for constructing the interpolating polynomial. When data points are equidistant, the calculations follow a consistent pattern, leading to more efficient computation.

Polynomial Interpolation:

This method involves creating a polynomial equation that passes through the provided data points. The polynomial is a surrogate for the underlying function, allowing you to estimate function values between the given data points. By interpolating with a polynomial, you gain a continuous representation of the function that aids analysis and visualization.

Divided Differences:

Divided differences are the cornerstone of Newton's Forward Interpolation. They quantify the incremental change in function values over intervals between data points. By systematically calculating these differences, the algorithm derives the coefficients for the interpolating polynomial. These coefficients are crucial for approximating function values between data points.

Efficient for Equidistant Points:

The efficiency of Newton's Forward Interpolation is particularly pronounced when dealing with central data points. Equidistant spacing simplifies the divided differences calculations, making them follow a predictable structure. Consequently, the consistent calculation pattern makes the overall algorithm more efficient.

Incremental Construction:

One of the defining characteristics of this method is its incremental nature. The algorithm constructs divided differences and the interpolating polynomial step by step. It begins by calculating the lower-order divided differences and progressively constructs the higher-order ones. This incremental approach helps in managing the complexity of the calculations.

Progressive Accuracy:

The accuracy of the interpolated values improves as you move closer to the midpoint between two data points. The polynomial approximation becomes more accurate within this range due to the nature of polynomial curves. However, accuracy decreases as you move farther from this midpoint, potentially resulting in larger errors.

Next TopicTower of Hanoi

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA