diff --git a/README.md b/README.md index d78d042..a6f9b06 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,89 @@ # Polynomial Interpolation -ANSI C program which composes polynomial of n - 1 degree that passes through n dots. +ANSI C program which composes polynomial of n - 1 degree that passes through n dots. It presents it in Newton interpolation polynomial and monic form. + +## Interface + +Application accepts as standart input decimal below 2147483647 `n` as number of dots, followed by n dots in format: ` (space) ` on each line, where `x` is an abscisse and `y` is an ordinate of single dot. Dot coordinates must fit [2.22507e-308;1.79769e+308] range by modulo. + +Result will be printed to standart output in the following format: + +Newton polynomial form: + +f_0 - f_1*(x-x_0) + ... + f_n(x-x_0)*(x-x_1)*...*(x-x_{n-1}) + +Simplified coefficients array (starting from 0 upto n-1 power): + +a_0 a_1 ... a_{n-1} a_n + +Polynomial in monic form: + +a_0 - a_1*x + ... + a_{n-1}*x^(n-2) + a_n*x^(n-1) + +Where f_i is a divided difference of y_1,...,y_i, a_i are coefficients of resulting monic polynomial + +## Data structure + +- `n` is an `unsigned int` variable, that is used to input and store number of dots + +- `x` is a pointer to array of `n` `double`s, that is used to store abscisses of dots + +- `y` is a pointer to array of `n` `double`s, that is used to store ordinates of dots + +- `coefficients` is a pointer to array of `n` `double`s, that is used to store coefficients of monic interpolation polynomial + +- `i`, `j` are `int` variables, those are used in loops as iterators + +- `tmp_polynomial` is a pointer to array of `n` `double`s, that is used to store coefficients of polynomial, resulting during simplification of interpolation polynomial summands. + +## Example + +Build and run application: + +```bash +gcc main.c +./a.out +``` + +### Input/output + +For input n = 3 and the following dots + +```plain +1 5 +2 3 +4 8 +``` + +Output is + +```plain +Newton polynomial form: +5 - 2*(x-1) + 1.5*(x-1)*(x-2) +Simplified coefficients array (starting from 0 upto n-1 power): +10 -6.5 1.5 +Polynomial in standart form: +10 - 6.5*x + 1.5*x^2 +``` + +### Illustrations + +#### Example 1 + + + + + + + +#### Example 2 + + + +or + + + + + + \ No newline at end of file diff --git a/img/console.png b/img/console.png new file mode 100644 index 0000000..68e2fd7 Binary files /dev/null and b/img/console.png differ diff --git a/img/console2.png b/img/console2.png new file mode 100644 index 0000000..1df4188 Binary files /dev/null and b/img/console2.png differ diff --git a/img/console3.png b/img/console3.png new file mode 100644 index 0000000..d4f9314 Binary files /dev/null and b/img/console3.png differ diff --git a/img/plot.png b/img/plot.png new file mode 100644 index 0000000..d46ebfe Binary files /dev/null and b/img/plot.png differ diff --git a/img/plot2.png b/img/plot2.png new file mode 100644 index 0000000..77845f3 Binary files /dev/null and b/img/plot2.png differ diff --git a/img/wolfram.png b/img/wolfram.png new file mode 100644 index 0000000..a855860 Binary files /dev/null and b/img/wolfram.png differ diff --git a/img/wolfram2.png b/img/wolfram2.png new file mode 100644 index 0000000..238b196 Binary files /dev/null and b/img/wolfram2.png differ