Skip to content

jiggzson/SEQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SEQ

Convert number sequence to polynomial form using method of finite differences

Example: I use the function generate to create a a sequence

//this sequence was generated using x^3+7*x+7
var number_sequence = [ 7, 15, 29, 55, 99, 167, 265, 399, 575, 799, 1077 ];

We can then analyze it using SEQ

var seq = new SEQ(number_sequence).analyze();
console.log(seq.toPolynomialString())
//x^3+7*x+7

We can get the next number in the sequence

var next = seq.next();
console.log(next);
//1415

or get it in the form of a javascript function

f = seq.toFunction();
console.log(f(7));
//399

You can tweak the tolerance and maximum iterations and the variable used when returning the polynomial string using the 'setTolerance', 'setMaxIterations', and 'setVariable' methods. The default for 'setMaxIterations' is 1000 which roughly corresponds to highest degree polynomial expected.

It cannot calculate all sequences yet.

About

Convert number sequence to polynomial form

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published