added root finding code and least squares fit code from in class