C Program for Newton Forward Interpolation


Interpolation is the process of finding the values of y corresponding to the any value of x between x0 and xn for the given values of y=f(x) for a set of values of x. Out of the many techniques of interpolation, Newton’s Forward and Backward Interpolation are two very widely used formulas. In this tutorial, we’re going to discuss a C program for Newton Forward Interpolation along with its sample output.

Both of Newton’s formulas are based on finite difference calculus. These formulas are very often used in engineering and related science fields. Before going through the source code for Newton Forward Interpolation, let’s go through the forward interpolation formula and the variables used in the C program.

Newton’s forward interpolation formula contains y0 and the forward differences of y0. This formula is used for interpolating the values of y near the beginning of a set of tabulated values and extrapolation the values of y a little backward (i.e. to the left) of y0. The formula is given below:

Newton's Forward Interpolation Formula

Compared to forward interpolation, the backward interpolation formula contains yn and the backward differences of yn. This formula is used for interpolating the values of y near the end of a set of tabulated values and also for extrapolating the values of y a little ahead (i.e. to the right) of yn.

Variables Used:

  • MAXN – the minimum value of N
  • ORDER – the maximum order in the difference table
  • ax – an array containing values of x
  • ay – an array containing values of y
  • diff – a 2D array containing the difference table
  • h – spacing between values of x
  • x – value of x at which the value of y is wanted
  • yp – calculated value of y
  • nr – numerator of the terms in expansion of y.p
  • dr – denominator of the terms in expansion of y.p

Newton Forward Interpolation in C:


Newton Forward Interpolation in C - Output

Also see,
Lagrange Interpolation in C
Newton Divided Difference in C
Numerical Methods Tutorial Compilation

You are requested to write a program of your own for backward interpolation based on the source code above. If you have any queries regarding Newton’s forward interpolation, or its C source code, bring them up to me from the comments section.

You can find more Numerical methods tutorial using C language here.


Please enter your comment!
Please enter your name here