MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Simplifying integer expressions with Mod and BitAnd

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84870] Simplifying integer expressions with Mod and BitAnd
  • From: Eric <auto451230 at hushmail.com>
  • Date: Wed, 16 Jan 2008 23:12:27 -0500 (EST)

I've been playing with Mathematica's ability to simplify integer arithmetic expressions and came up with a few cases that it didn't simplify as fully as possible.  As an utter Mathematica neophyte, I don't know if these are due to limitations in Mathematica or in my understanding of it.  Can anyone offer advice?

#1: (a % b) == a for non-negative a < b

I tried Refine[Mod[a,b], a \el Integers && b \el Integers && 0 < a < b], but it wasn't able to recognize that Mod[a,b] would always be equal to a in such cases.  Should I rephrase the problem, or is this a refinement of which Mathematica isn't capable?

#2: (((a & 15) + b) & 7) == ((a + b) & 7)

Slightly similar to the previous example; Mathematica was unable to refine BitAnd[BitAnd[a, 15] + b, 7] any further.

#3: ((a * 16) & 15) == 0

I tried Refine[BitAnd[a * 16, 15], a \el Integers && a > 0], also without any further refinement.


Do you think it's possible to rephrase such expressions in a way that Mathematica would be able to simplify them?  The reason for the test is that I'd like to supply Mathematica with programmatically-generated integer arithmetic expressions, containing a variety of operators, and know that it is simplifying them as cleverly as possible.


  • Prev by Date: Re: Version 6 graphics can be painfully slow
  • Next by Date: Re: Don't understand behavior of ClearAttributes[Plus,Orderless]
  • Previous by thread: Bug: dummy variable appears in result
  • Next by thread: Re: Simplifying integer expressions with Mod and BitAnd