Posts: 114

Threads: 18

Joined: Jan 2011

HP-33s and HP-35s lack min and max functions. Yes, they could be easily programmed, but..

a) Label would be consumed on HP-33S (not a problem for HP-35S, thou)

b) You can't use conditionals in the Equation Writer

So, here is simple (but awkward) brute force implementation of MIN & MAX using Signum function, present on these calculators.

MIN(a,b)=((b-a)*SGN(a-b)+b+a)/2

MAX(a,b)=((a-b)*SGN(a-b)+b+a)/2

If used in program, they could be simplified by isolating (a-b).

Posts: 653

Threads: 26

Joined: Aug 2010

If I need a min() or max() function in a program I simply do it this way - without any labels and with minimal memory usage:

MIN-function: MAX-function:

X>Y? X<Y?

x<>y x<>y

Okay, this doesn't work for the solver. :-)

Looking at your equations for a while I found a somewhat simplified version. Since (a-b)*sign(a-b) is simply abs(a-b) the two equations may be written even shorter this way:

MIN(a,b) = (a+b-ABS(a-b))/2

MAX(a,b) = (a+b+ABS(a-b))/2

By the way thanks for your suggestion - it's always nice to re-think some basics and find solutions one would otherwise not have thought of. :-)

Dieter

*Edited: 30 Jan 2011, 12:47 p.m. *

Posts: 114

Threads: 18

Joined: Jan 2011

Dieter, thanks for your simplification! I was just solving another problem involving signum function, and suddenly realized that it could be used to emulate MAX/MIN in solver. I wrote the same ABS solution 15 minutes before reading your post :) Your solution is better!