It turns out that this is due to an error in the Fraction context that doesn't properly insert parenthesis in some circumstances when the fraction is turned into a string. Since you use

$ans = Compute("$F+C");

The value of `$F`

is first turned into a string, inserted into the larger string, and then re-parsed to form the new MathObject. Because the parentheses are missing, it is equivalent to

$ans = Compute("(x^2/7)+C");

which is `((x^2)/7)+C`

, not `(x^(2/7))+C`

, leading to your issue.

One solution would be to use

$ans = $F + "C";

instead. Since `$F`

is already a Formula object, it will handle the `+`

by doing addition of Formulas, first converting the string `"C"`

into a Formula, and returning the new Formula that is their sum. This avoids the stringification and re-parsing that your original method uses (so is also more efficient).

See if that does the trick for you.

I've made a pull request to fix the problem. So a second solution would be to download the updated `contextFractions.pl`

file from that PR and save it to your course's `templates/macros`

directory (or to the main `pg/macros`

directory if you have access to that).