public AlgoCompleteSquare(Construction cons, String label, GeoFunction f) {
    super(cons);
    this.f = f;
    a = new MyDouble(kernel);
    h = new MyDouble(kernel);
    k = new MyDouble(kernel);

    fv = new FunctionVariable(kernel);
    ExpressionNode squareE = new ExpressionNode(kernel, a);
    Function squareF = new Function(squareE, fv);
    squareF.initFunction();
    square = new GeoFunction(cons);
    setInputOutput();
    square.setFunction(squareF);
    compute();
    lastDeg = 0;
    square.setLabel(label);
  }
 @Override
 public void compute() {
   // cover undefined cases
   if (!degree.isDefined() || !min.isDefined() || !max.isDefined() || degree.getDouble() < 0) {
     polynomial.setUndefined();
     return;
   }
   int lower = (int) Math.ceil(min.getDouble());
   int upper = (int) Math.floor(max.getDouble());
   if (lower > upper || (lower == 0 && upper == 0)) {
     polynomial.setUndefined();
     return;
   }
   // input is sane, we can do the computation
   int deg = (int) Math.floor(degree.getDouble());
   ExpressionNode varExpr = new ExpressionNode(kernel, fv);
   ExpressionNode newExpr = randomCoef(deg != 0);
   for (int i = 1; i <= deg; i++) {
     newExpr = varExpr.power(new MyDouble(kernel, i)).multiply(randomCoef(i != deg)).plus(newExpr);
   }
   f.setExpression(newExpr, fv);
   polynomial.setFunction(f);
 }