Skip to content

lovasoa/lagrange-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lagrange-cpp

Lagrange interpolation polynomials in C++11

Usage

Let's create a polynomial function that passes through the points (0,0) (2,4) (10,100).

Compile the files

$ make

Create a file that contains the point coordinates

Une point per line. X and Y coordinates are separated by a space.

$ cat > points.txt
0 0 
2 4
10 100

Generate the polynomial coefficients

Let's write the coefficients to a file named polynom.txt.

$ ./coeffs < points.txt > polynomial.txt
$ cat polynomial.txt 
0
0
1

We can see that the generated polynomial function is f : x -> 0 + 0*x + 1*x^2. This is the square function, as expected.

Evaluate the resulting function

Let's evaluate the function between 0 and 10.

$ seq 0 10 | ./poly_exec polynomial.txt 
0
1
4
9
16
25
36
49
64
81
100

About

Lagrange interpolation polynomials in C++11

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published