MathGroup Archive 2003

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

Search the Archive

Problem using Quotient and Mod functions with rational parameters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41860] Problem using Quotient and Mod functions with rational parameters
  • From: eduault <eduault at yahoo.com>
  • Date: Sat, 7 Jun 2003 00:08:49 -0400 (EDT)
  • Organization: Guest of ProXad - France
  • Sender: owner-wri-mathgroup at wolfram.com

As a Mathematica user, I was recently surprised by the result returned by
the Quotient and Mod functions, called with some rational parameters.

I was expecting that Quotient[m*n, n], with m positive integer and a
positive would return m.
This is nearly almost the case, for example:

Quotient[0.12, 0.01] returns 12
Quotient[0.13, 0.01] returns 13
Quotient[0.14, 0.01] returns 14

However, for some parameters, this is not the case:

Quotient[0.29, 0.01] returns 28
Quotient[0.57, 0.01] returns 56
Quotient[0.58, 0.01] returns 57
Quotient[0.59, 0.01] returns 58

Does someone explain those results, which I observed using Mathematica
versions
4.0.1.0 and 4.0.2.0, and two different machines (PCs with Windows NT and
Windows 98) ??

---------------------------------------------------------------------
Note:

The same behavior occurs with the Mod function.
This relation between Quotient and Mod is normal, because of the relation
found in the documentation, saying that "Mod[m, n] is equivalent to m - n
Quotient[m, n]".
But this leads to some surprising results:

Mod[m*n, n] should return 0, as in most cases: (I agree with this result)

Mod[0.12, 0.01] returns 0
Mod[0.13, 0.01] returns 0
Mod[0.14, 0.01] returns 0

but we also have, for rare parameters:

Mod[0.29, 0.01] returns 0.01
Mod[0.57, 0.01] returns 0.01
Mod[0.58, 0.01] returns 0.01
Mod[0.59, 0.01] returns 0.01




  • Prev by Date: Re: Explain this (error in Plot[Evaluate[Range[3]],{x,0,1}])
  • Next by Date: Re: creating functions from the result of Solve[]
  • Previous by thread: Re: Learning to work with non-commutative oscillators
  • Next by thread: Re: Problem using Quotient and Mod functions with rational parameters