Program MMM
Program MMM
Newton’s backward interpolation formula is used when the given value lies near the end of the
data table.
🔹 Formula:
Where:
🔹 C Program:
#include <stdio.h>
int factorial(int n) {
int f = 1;
for (int i = 2; i <= n; i++)
f *= i;
return f;
}
int main() {
float x[10], y[10][10], xp, h, u, yp;
int n;
printf("Enter x values:\n");
for (int i = 0; i < n; i++)
scanf("%f", &x[i]);
printf("Enter y values:\n");
for (int i = 0; i < n; i++)
scanf("%f", &y[i][0]);
// Constructing backward difference table
for (int j = 1; j < n; j++)
for (int i = n - 1; i >= j; i--)
y[i][j] = y[i][j - 1] - y[i - 1][j - 1];
h = x[1] - x[0];
u = (xp - x[n - 1]) / h;
yp = y[n - 1][0];
float u_term = 1;
for (int i = 1; i < n; i++) {
u_term *= (u + i - 1);
yp += (u_term * y[n - 1][i]) / factorial(i);
}
Fit a line of the form y=a+bxy = a + bx through a set of points such that the sum of the squares of
the vertical deviations is minimized.
🔹 Formulas:
🔹 C Program:
#include <stdio.h>
int main() {
float x[10], y[10], sumX = 0, sumY = 0, sumXY = 0, sumX2 = 0;
float a, b;
int n;
Would you like the next 2 programs now (e.g., Trapezoidal Rule and Simpson’s Rule), or should
I generate a Word file with these?