MathGroup Archive 2008

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

Search the Archive

Re: Simplifying integer expressions with Mod and BitAnd

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84897] Re: Simplifying integer expressions with Mod and BitAnd
  • From: Eric <auto451230 at hushmail.com>
  • Date: Fri, 18 Jan 2008 05:49:53 -0500 (EST)

> #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.

Okay, I was able to simplify this, using Simplify[Mod[a,b], 0<=a<b], which yielded the answer a.  Mathematica apparently knows some tricks for simplifying bitwise expressions, too, but was ineffective against the following:

Simplify[BitAnd[a*2, 1], a \el Integers && a >= 0]  (no improvement; should yield 0)

Simplify[BitAnd[BitShiftLeft[a, 1], 1]]  (alternative to the above; no improvement here either, although it should also have resulted in an answer of 0)

Simplify[c <= a, c == BitAnd[a,b] && a >= 0 && b >= 0]  (no improvement; should yield True, since ANDing a non-negative number cannot increase it)

Simplify[a >= b, a >= 0 && b >= 0 && a == BitOr[b, 1]]  (no improvement; should yield True, because ORing one non-negative number by another cannot lower it)

Does anyone see mistakes in the way I'm attempting this, or know an alternate means that would take such tricks into account when generically simplifying expressions?


  • Prev by Date: Re: printing stylesheets?
  • Next by Date: Re: Trying hard to find ' Findfit ' of Mathematics in C++
  • Previous by thread: Simplifying integer expressions with Mod and BitAnd
  • Next by thread: Mouse operation, slider, dynamics, plot combination