public static String differentiate(Parser.Expression exp, final String variable){
        return exp.accept(new Parser.Expression.Visitor<String>() {
            // This is the d(var)/dx case
            public String differentiate(Parser.Variable var){
                String expVar = var.toString();
                String output;
                if (expVar.equals(variable)){
                    output = "1";
                    return output;
                }
                else{
                    output = "0";
                    return output;
                }
            }
            // dc/dx case
            public String differentiate(Parser.Number num){
                String output = "0";
                return output;
            }
            // d(u+v)/dx case
            public String differentiate(Parser.Addition add){
                Expression leftExpr;
                Expression rightExpr;
                String outLeft;
                String outRight;
                leftExpr = add.left;
                rightExpr = add.right;
                outLeft = Differentiator.differentiate(leftExpr, variable);
                outRight = Differentiator.differentiate(rightExpr, variable);
                return "(" + outLeft + " " + "+" + " " + outRight+ ")";
            }
            // d(u*v)/dx case
            public String differentiate(Parser.Multiplication mul){
                Expression leftExpr;
                Expression rightExpr;
                String outLeft;
                String outRight;
                leftExpr = mul.left;
                rightExpr = mul.right;
                String rightDiff = Differentiator.differentiate(rightExpr, variable);
                String leftDiff = Differentiator.differentiate(leftExpr, variable);
                outLeft = "(" + leftExpr.toString() + " " + "*" + " " + rightDiff + ")";
                outRight = "(" + rightExpr.toString() + " " + "*" + " " + leftDiff + ")";
                return "(" + outLeft + " " + "+" + " " + outRight + ")";
            }
            
        });
    }