Written in Ubuntu 23.04 LTS. This progam was written for GNU/Linux systems.
Implements Langrange-Interpolation in the C programming language
. Creates complete polynomials from Node Value pairs in csv files, and creates 2 dimensional plots, using gnuplot
, which are saved as png files.
- gcc
- gnuplot
Lagrange interpolation is a mathematical method that finds new points
The Lagrange Polynomial is written in the following form:
Where
For
This example takes critical points from a sine wave. Using Lagrange Interpolation, an approximation of the complete wave can be constucted.
The data in data/sine.csv
is format as the following
Nodes | Values |
---|---|
0 | 0 |
1.5707 | 1 |
3.1416 | 0 |
4.7124 | -1 |
6.2832 | 0 |
The program can be executed by the following
./run.sh [csv_file]
For this example csv_file
would be sine.csv
. If the program ran successfully the following message would appear:
Data read successfully
Nodes: Values:
0.00 0.00
1.57 1.00
3.14 0.00
4.71 -1.00
6.28 0.00
Initializing Lagrange Interpolation
Creating plot
Plot saved as 'img/sine.png'
And the following image is saved to img
as a png
file type.
MIT License - see LICENSE for details.