I am also trying to generate number series. I was hoping professional tests didn't use anything more complicated than Lagrange polynomials, but apparently only some items can be explained this way.
I will try out your code, thanks.
EDIT: Turns out this method can solve only half of the number series from the professional test I used for this experiment.
Also turns out, this method you describe is called the "method of successive differences" and works for any polynomial, if this thread is to be believed:
Since 2018 I believe "prevalence" is preferred over frequency for determining vocabulary difficulty:
https://link.springer.com/article/10.3758/s13428-018-1077-9
I think I discovered this link from you though.
I am also trying to generate number series. I was hoping professional tests didn't use anything more complicated than Lagrange polynomials, but apparently only some items can be explained this way.
I will try out your code, thanks.
EDIT: Turns out this method can solve only half of the number series from the professional test I used for this experiment.
Also turns out, this method you describe is called the "method of successive differences" and works for any polynomial, if this thread is to be believed:
https://everything2.com/title/How+to+solve+any+number+sequence+puzzle