https://github.com/yurlungur/lagrange-interpolation
Library for Lagrange Interpolation
https://github.com/yurlungur/lagrange-interpolation
interpolation learning-algorithms scientific-computing
Last synced: about 1 year ago
JSON representation
Library for Lagrange Interpolation
- Host: GitHub
- URL: https://github.com/yurlungur/lagrange-interpolation
- Owner: Yurlungur
- License: mit
- Created: 2017-03-27T17:42:59.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-15T19:03:22.000Z (about 9 years ago)
- Last Synced: 2025-02-04T10:56:28.358Z (about 1 year ago)
- Topics: interpolation, learning-algorithms, scientific-computing
- Language: C
- Size: 599 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lagrange-interpolation
Author: Jonah Miller (jonah.maxwell.miller@gmail.com)
Simple library for Lagrange Interpolation in 1D, 2D, and 3D on a
Cartesian product grid. Written in C for maximum compatibility. The
plot below shows the error for piecewise 2nd-order interpolation using this library:

The plot blow shows the error (rescaled by the grid spacing) for
piecewise fourth-order interpolation of the function sin(5x) on the
evenly-spaced interval [-pi,pi] using this library:

The plot below shows the norm of the error for the interpolation of
the function sin(5x)cos(3y) on the evenly spaced domain [-pi,pi]^2
using 2nd, 4th, and 6th order interpolation.

## Installation
This code is simple enough that you can just copy-paste `lagrange.c`
and `lagrange.h` into your project. At the moment, that's the only
installation method.
## Use
The header file should provide the interface for the functions you are
interested in. Most interesting, probably, are the
`lagrange_interp_NDfo` functions, where you specify an order of
interpolating polynomial in each dimension and the library evaluates a
piecewise interpolating polynomial of that order over the grid. The
`lagrange_interp_ND` series of functions are global interpolators and
should be used only if your grid points are stable for high-order
interpolation.
## Testing
You can test the code by cloning the directory, entering it, and
typing `make test`. You can also generate a nice plot with `make
plot`. The plotting functionality requires the scientific python
stack.
```bash
git cone git@github.com:Yurlungur/lagrange-interpolation.git
cd lagrange-interpolation
make test
```