MathGroup Archive 2004

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

Search the Archive

Re: Min[], Max[]

In article <c8rutb$8nl$1 at>, Frank Brand
<fank.brand at> wrote:

> Dear newsgroup members,
> can anyone explain me what´s the sense in the definition of
> Min[{}]= Infinity and Max[{}]= -Infinity

I don't know for sure but I have a guess:

When I have a need to find the min (or max) of an array in C or
Fortran, I usually do it by looping through the array and comparing
each value to the previous min (or max) value.  Whenever I find a
number smaller (or larger) than the previous min (or max), I replace it
with the new one.  When the program is done looping through the array
the min (or max) is found.

It is a simple method, but it needs a starting value.  What value for
min (or max) do you use to initialize before you enter the loop?  It
needs to be larger (or smaller) than the min or (max), or you won't
find the min (or max) of the list.  How do you initialize with a value
larger (or smaller) than the min or (max) of the array if you don't
know the min (or max) yet?

One way is to use a value larger (or smaller) than *any* value in the
list (another way is to use any value from the list).  In C or Fortran
code an easy way to do that is to use the largest (or smallest) number
the machine can recognize for your particular variable type.  For the
Mathematica programmers, it makes sense that that would be Infinity (or
-Infinity).  If you ask this method to find the min (or max) of an
empty list it just returns the initial value.

Anyone have a better explanation?

Jim Jennings, Research Scientist, Bureau of Economic Geology          
John A. and Katherine G. Jackson School of Geosciences
The University of Texas at Austin

  • Prev by Date: RE: Min[], Max[]
  • Next by Date: Re: Uniform design
  • Previous by thread: RE: Min[], Max[]
  • Next by thread: Tensor SVD?