Re: greatest of two numbers
- From: "Mark Nudelman" <markn@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 17 Jan 2008 10:48:51 -0600
William Elliot wrote:
On Wed, 16 Jan 2008 aarklon@xxxxxxxxx wrote:
Hi all,max{ a,b } = a, if b <= a
The following are the two methods which i have seen for finding
greatest of two numbers
if a and b are two natural numbers
1) greatest(a,b) = [ (a+b ) + abs(a - b) ] / 2
2) ( (a + b) + sqrt[(a - b) ^ 2] ) / 2
is there any better method/ methods than this .????
= b, if a <= b
Works not only for reals, rationals and integers,
but also all totally ordered sets. For example
R^2 with lexicographical order:
(a,b) <<= (x,y) when a < x or a = x, b <= y.
<<= is an order different that the greater than <, of reals.
Or if you want to avoid "if" cases in the definition, you can use
Knuth's generalization of the Kronecker delta function:
"[expr]" where expr is a boolean expression
is defined to be 1 if expr is true and 0 if expr is false.
Then max(a,b) = ([a>b] * a) + ([a<=b] * b)
Of course, this just pushes the "if" into the definition of the Knuth
brackets, but you may consider the brackets a "known" operator.
--Mark
.
- Follow-Ups:
- Re: greatest of two numbers
- From: Hero
- Re: greatest of two numbers
- References:
- greatest of two numbers
- From: aarklon
- Re: greatest of two numbers
- From: William Elliot
- greatest of two numbers
- Prev by Date: Re: A question in module theory!
- Next by Date: Scientific American - Mind Games
- Previous by thread: Re: greatest of two numbers
- Next by thread: Re: greatest of two numbers
- Index(es):