#include <stdlib.h>
#include <stdio.h>
#include "modules.h"

long double poly_newton(long double x, double* xh, double* yh, int n,double** sep_dif) {
	long double ans = 0;
    long double sub;

	
	for (int m = 0;m < n;m++) {
		long double koef = sep_dif[0][m];
		sub = 1;

		for (int k = 0;k < m;k++) {
			sub *= (long double)(x - xh[k]);
		}

		ans += (long double)sub * koef;

	}
	
	return ans;
}