Skip to content

A numerical method library contains Least Square Polynomial Approximation, Gregory-Newton Interpolation, and Numerical Integration.

Notifications You must be signed in to change notification settings

kennyynlin/numlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

numlib

A C++ numerical method library contains Least Square Polynomial Approximation, Gregory-Newton Interpolation, and Numerical Integration.

Usage

#include "numlib.h"

Least Square Polynomial Approximation

std::vector<double> xdata{1, 2, 3, 4, 5};
std::vector<double> ydata{1, 8, 9, 64, 125};
dataset ds(xdata, ydata);

# returns polynomial coefficient
std::vector<double> coef;
coef = ds.leastSquareCoef();

coef should be {0, 0, 0, 1} which represents 0x^0+0x^1+0x^2+1x^3.

# returns y value
double yValue;
yValue = ds.leastSquareY(6);

yValue should be 6^3 = 216.

Gregory-Newton Interpolation

Please refer to the explanation of Gregory-Newton Forward Difference.

#returns interpolation value
yValue = ds.gregoryNewton(6);

yValue should also be 216.

Numerical Integration

pending...

Contributing

Pull requests are welcome! Feel free to contact me via email.

About

A numerical method library contains Least Square Polynomial Approximation, Gregory-Newton Interpolation, and Numerical Integration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published