Working code for polynomial data fitting with any degree of basis functions