function polynomial_in_x(A, x, n){
    var y = 0.0;
    for(var i = 0; i < n; ++i){
        y += A[i] * Math.pow(x, i);
    }
    return y;
}

function draw_grid_on(context){
    // grid
    context.beginPath();
    for(var i = x_min + 1; i <= x_max - 1; i++){
        if(i != 0) {
            context.moveTo(client_x_center + i*client_x_step + 0.5, 0);
            context.lineTo(client_x_center + i*client_x_step + 0.5, h+1);
        }
    }
    for(var i = y_min + 1; i <= y_max - 1; i++){
        if(i != 0) 