0
$\begingroup$

Recently asked my students to put together something like this:

Reduce[x^2 ==b, b, Modulus -> 11]

For me, on 12.1, this gives:

{{b -> ConditionalExpression[0, x == 0]},
 {b -> ConditionalExpression[1, x == 1 || x == 10]},
 {b -> ConditionalExpression[3, x == 5 || x == 6]},
 {b -> ConditionalExpression[4, x == 2 || x == 9]},
 {b -> ConditionalExpression[5, x == 4 || x == 7]},
 {b -> ConditionalExpression[9, x == 3 || x == 8]}}

I liked that this helped us quickly count (and describe) squares mod $n$, and it was a nice place to brag on Mathematica for helping us solve $x^2\equiv b\pmod{n}$ for $b$ even though $b$ appears to already be "solved for."

But they are reporting, with 12.2, that they just get {{b->x^2}} as the output. The Wolfram Cloud does the same.

I understand, perhaps, that Reduce might be an alternative in some sense. Maybe it's the "right" way to solve the problem. But it doesn't have the same user-friendly sorting of solution sets by $b$ value. It also seems odd to break this functionality in an update, when Modulus is still supported by Solve as far as I can tell.

Does anyone know exactly what happened here? Or am I missing a good, easy, quick fix/work-around?

$\endgroup$
6
  • 2
    $\begingroup$ Solve[x^2 == b, b, Modulus -> 11, MaxExtraConditions -> All] (or Method->Reduce) $\endgroup$
    – ciao
    Apr 5, 2021 at 8:03
  • $\begingroup$ That's interesting. Did they change the value or behavior for default MaxExtraConditions? $\endgroup$ Apr 5, 2021 at 17:52
  • 1
    $\begingroup$ What does nerfed mean? Turned into a foam football? $\endgroup$
    – Michael E2
    Apr 5, 2021 at 20:58
  • $\begingroup$ @KellenMyers - I don't have insight into WR decisions, but likely: SW has been on a "cleaner output/simpler output" push for the last few versions. $\endgroup$
    – ciao
    Apr 5, 2021 at 21:47
  • $\begingroup$ @Michael E2 presumably from a real one, yes. $\endgroup$ Apr 6, 2021 at 0:05

1 Answer 1

1
$\begingroup$

Here is what I observe:

$Version
(*  "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)"  *)

Reduce[x^2 == b, b, Modulus -> 11]
(*
(x == 0 && b == 0) || (x == 1 && b == 1) || (x == 2 && b == 4) ||
 (x == 3 && b == 9) || (x == 4 && b == 5) || (x == 5 &&  b == 3) ||
 (x == 6 && b == 3) || (x == 7 && b == 5) || (x == 8 && b == 9) ||
 (x == 9 && b == 4) || (x == 10 && b == 1)
*)

BoxForm`UseTextFormattingQ = True;
Solve[x^2 == b, {b}, Modulus -> 11, Method -> Reduce]
(*
{{b -> ConditionalExpression[0, x == 0]},
 {b -> ConditionalExpression[1, x == 1 || x == 10]},
 {b -> ConditionalExpression[3, x == 5 || x == 6]},
 {b -> ConditionalExpression[4, x == 2 || x == 9]},
 {b -> ConditionalExpression[5, x == 4 || x == 7]},
 {b -> ConditionalExpression[9, x == 3 || x == 8]}}
*)

To get just the quadratic residues, eliminate x:

Solve[x^2 == b, {b}, {x}, Modulus -> 11]
(*  {{b -> 0}, {b -> 1}, {b -> 3}, {b -> 4}, {b -> 5}, {b -> 9}}  *)

To get the reported response, try the following, which is at least correct:

Solve[x^2 == b, {b}, Modulus -> 11]
(*  {{b -> x^2}}  *)

I don't know why the behavior changed. You could try reporting it to WRI. Perhaps it wasn't intended.

$\endgroup$
1
  • 1
    $\begingroup$ I believe it was changed to avoid the ConditionalExpression flavor as default. $\endgroup$ Apr 6, 2021 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.