Least square method