back_to_list()
Library v1.1.1

Analytical Interpolation And Approximation .Net Library

Library that returns analytical formula of interpolated or approximated function.

Try Interpolation and Approximation Online

X: Y:



Result:

NuGet

Library can be also downloaded from nuget

Features And Algorithms

Interpolation uses my own algorithm for calculating Lagrange coefficients. Approximation uses standard formula for building simultaneous equations and solves them using Gaussian elimination.

Examples and usage

You can use this library to find function formula that goes through all given points. For example having {-2, 4}, {0, 0}, {1, 1} and {2, 4} we will receive f(x)=x^2 as result.

// VARIABLES
List<PointD> points = new List<PointD>();

points.Add(new PointD(-2, 4));
points.Add(new PointD(0, 0));
points.Add(new PointD(1, 1));
points.Add(new PointD(2, 4));

//Computing
Interpolation interpolation = new Interpolation(points);
string result = interpolation.Compute();

Approximation returns function formula that goes near given points and is a polynomial of requested degree. For example approximation of {-4, 5}, {-2, 3}, {0, 1}, {2, 3}, {5, 5} requesting third degree will give us function as below:

// VARIABLES
int level = 3;

List<PointD> points = new List<PointD>();

points.Add(new PointD(-4, 5));
points.Add(new PointD(-2, 3));
points.Add(new PointD(0, 1));
points.Add(new PointD(2, 3));
points.Add(new PointD(5, 5));

//Computing
Approximation approximation = new Approximation(points, level);
string result = approximation.Compute();


Alter

Example application

Alter

Download: here

License

MIT License

Source code

Can be found on GitHub

Changelog

v1.1.1

  • Fixed NullReferenceException in Approximation constructor

v1.1

  • Enhanced numerical libraries interfaces
  • Changed license to MIT
  • Sources are now available on GitHub

v1.0

Comments (2)

J

Jan Kierzkowski

In version 1.1, when I tried to calculate approximation (using example provided above) I get null reference exception. Please fix it.
R

Rychu

Hey Jan. Thanks for reporting this. Please try version 1.1.1.

Add comment