pow((xy[0]-points[i][0]), 2) + Math.pow((xy[1]-points[i][1]), 2);
		if(d < best_d) {
			best_d = d;
			best_i = i;
		}
	}
	return best_i;
}

// above
var app_degree = 2;
function change_app_degree() {
	app_degree = Number(document.getElementById("app_degree_input").value);
	if(isNaN(app_degree) || app_degree < 0) {
		app_degree = 0;
	}
	document.getElementById("app_degree_input").value = app_degree;
	draw_canvas("approximation_canvas");
}

var both_degree = 3;
function change_both_degree() {
	both_degree = 