Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2009-03-07 02:58:30

Onyx
Member
Registered: 2009-02-24
Posts: 48

min{a,b} and max{a,b}

Hi, I've came across these functions and they seam pretty self explanatory, so I feel a little stupid asking this question, but I want to make sure I understand them right.

Does:

and:

Is that all it is?

Offline

#2 2009-03-07 03:32:35

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: min{a,b} and max{a,b}

Yes, that’s correct.

You might find these formulas interesting (possibly even useful):

Offline

#3 2009-03-07 04:03:44

Onyx
Member
Registered: 2009-02-24
Posts: 48

Re: min{a,b} and max{a,b}

Thanks, those formulas are indeed useful, since it's cleared the ambiguity I had with min{} and max{} in the text I'm reading. Cheers

Offline

#4 2009-03-07 07:50:19

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: min{a,b} and max{a,b}

Onyx wrote:

Thanks, those formulas are indeed useful, since it's cleared the ambiguity I had with min{} and max{} in the text I'm reading. Cheers

That makes me worry a little because there shouldn't be any ambiguity, even if you don't see them defined by formulas.  It is just a function that chooses the largest or smallest out of the set (in this case, set of two) of numbers.  Where is the ambiguity?


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#5 2009-03-09 11:28:57

Onyx
Member
Registered: 2009-02-24
Posts: 48

Re: min{a,b} and max{a,b}

Ricky wrote:
Onyx wrote:

Thanks, those formulas are indeed useful, since it's cleared the ambiguity I had with min{} and max{} in the text I'm reading. Cheers

That makes me worry a little because there shouldn't be any ambiguity, even if you don't see them defined by formulas.  It is just a function that chooses the largest or smallest out of the set (in this case, set of two) of numbers.  Where is the ambiguity?

The ambiguity was in the fact that although max{} and min{} are self explanatory, the text I was reading kept referencing them to to the formulas Jane provided without explicity stating the equalities, and after finding nothing online I wanted to make sure I wasn't missing something important. You know what they say about asumption being the mother of all **** ups

Offline

#6 2009-03-09 12:06:11

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: min{a,b} and max{a,b}

You didn’t miss anything important. The formulas may not look intuitive, but they are equivalent to the intuitive definitions of max/min. They have their uses too. They would be useful in, for example, part of a computer program where you need to extract the max/min of two numbers. Instead of branching off into if-then-else subroutines, you can easily plug in those formulas directly into the equations you are using in your program.

Moreover, the formulas can be extended to more than two numbers.

which saves you even more trouble with if-then-else.

Offline

#7 2009-03-09 19:56:00

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: min{a,b} and max{a,b}

JaneFairfax wrote:

They would be useful in, for example, part of a computer program where you need to extract the max/min of two numbers. Instead of branching off into if-then-else subroutines, you can easily plug in those formulas directly into the equations you are using in your program.

which saves you even more trouble with if-then-else.

I would argue against that since in most languages you would be able to do something such as:

c = a<b ? a : b;
or
d = a<b&&a<c ? a : b<c ? b : c;

instead of if/else, if/elseif/else

of which both using the conditional operator, and normal branching will be alot faster in terms of execution than using the formula:

The only time that i can see these formula being of use in a programming application is in GPU programming on slightly older architectures where either branching is not supported, or branching is very slow and using the formula could execute faster.


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#8 2009-03-09 23:07:58

Onyx
Member
Registered: 2009-02-24
Posts: 48

Re: min{a,b} and max{a,b}

Thanks, at least I'm aware of them now for the future.

btw theres an easy algorithm for finding the maximum or minimum of a set of numbers (array) e.g. the minimum:

Declare variable.
initialize variable as first element of array.
Loop through array element by element {
  if (current array element is less than variable) {
    set variable equal to current element. 
  }
}
return variable

Offline

Board footer

Powered by FluxBB