Edited
Alternative for prior version
Avoids converting the data format twice
Temporarily suppressed warning about badly conditioned polynomial