5
$\begingroup$

After this question I'm intrigued about the different behaviors depending where and how the assumptions are given.

PiecewiseExpand[Mod[n, m]]    (* case #1 *)
(* Mod[n, m] *)

PiecewiseExpand[Mod[n, m], n == m, Integers]    (* case #2 *)
(* -m + n *)

Assuming[n == m,    (* case #3 *)
 FullSimplify@PiecewiseExpand[Mod[n, m]] 
 ]
(* 0 *)

Assuming[n == m,    (* case #4 *)
 Simplify@PiecewiseExpand[Mod[n, m]]
 ]
(* Mod[0, n] *)

Assuming[n == m,    (* case #6 *)
 FullSimplify@Mod[n, m]
 ]
(* 0 *)

Assuming[n == m,    (* case #7 *)
 Simplify@Mod[n, m]
 ]
(* Mod[0, n] *)

Case #5 removed as it was an unrelated bug discussed in this question

How is that explained?

$\endgroup$
  • 1
    $\begingroup$ Items 3 and 4 exhibit the same behavior without PiecewiseExpand[]; item 5 is manifestly a bug. $\endgroup$ – J. M. will be back soon Oct 9 '15 at 15:41
  • 1
    $\begingroup$ $Assumptions = m > 0 && Element[{n, m}, Integers]; PiecewiseExpand[Mod[n, m]] returns Mod[n, m] $\endgroup$ – Bob Hanlon Oct 9 '15 at 15:48
  • 1
    $\begingroup$ @rhermans I suggest copying case 5 to a new question and tagging it with bugs instead of tagging THIS question :). Although we aren't a bugs repository it's nice to have a highlights catalog. $\endgroup$ – Dr. belisarius Oct 9 '15 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.