Test whether a given function is polynomial
You have a black box function to which you can give real number inputs and from which you can receive real number outputs. How would you test whether it is likely to be a polynomial?
One expensive idea is to use finite differences:
1. Choose a maximum degree n of the "polynomial" you are testing.
2. Choose a consecutive sequence with random step size, and evaluate the function there to get an output sequence. E.g.,
3. Using the output sequence as S[0], define S[n] so that its k-th entry
4. If the function is a polynomial (of degree at most n), then the sequence should be all zeros.
Some issues about programming this method:
Would be expensive for large n
If S[0] has large values, computer arithmetic will produce bad results for S[1] and beyond.