@Override
    public Expr derive(char var) {
        switch (operand) {
            case '+': {
                return new BinOp('+', c1.derive(var), c2.derive(var));
            }
            case '-': {
                return new BinOp('-', c1.derive(var), c2.derive(var));
            }
            case '*': {
                return new BinOp('+', new BinOp('*', c1, c2.derive(var)), new BinOp('*', c2, c1.derive(var)));
            }
            case '/': {
                return new BinOp('/', new BinOp('-', new BinOp('*', c1.derive(var), c2), new BinOp('*', c1, c2.derive(var))), new BinOp('*', c2, c2));
            }
            case '^': {
                if (c1.derive(var).evaluate() == 1) {
                    return new BinOp('*', new BinOp('^', new BinOp('*', c2, c1), new Constant(c2.evaluate())), c1.derive(var));
                } else {
                    return c1.derive(var);
                }
            }
            default: {
                return new Constant(Double.NaN);
            }
        }

    }