edited error funtion to take variables that we want to optimize. Known points assumed to be global list
least square optimization written. need to test on raw data