min(a,b) and max(a,b) equation for HP-33S/HP-35S



#4

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).


#5

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.


#6

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!


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP35s Calculator Max Rope Tension Program Jean-Marc Biram (Australia) 10 2,201 12-12-2013, 12:03 AM
Last Post: Jean-Marc Biram (Australia)
  Equation Library/App for the Prime Harold A Climer 3 867 10-30-2013, 10:14 AM
Last Post: CompSystems
  Is the HP 33s the next hot HP collectible ? Michael de Estrada 12 1,772 10-29-2013, 10:23 AM
Last Post: Thomas Radtke
  Equation Library on the PRIME Harold A Climer 0 513 10-26-2013, 10:01 AM
Last Post: Harold A Climer
  HP 35S: Resistors in Series or Parallel (Portred from HP-33E) Eddie W. Shore 2 699 10-14-2013, 05:29 AM
Last Post: R. Pienne
  Interesting Base Conversions - Porting a 1975 HP 25 Program to the HP 35S Eddie W. Shore 1 668 10-13-2013, 07:49 PM
Last Post: BruceH
  Meltiple Equation Solver PRIME Vs. HP 50G Harold A Climer 5 999 10-07-2013, 05:11 PM
Last Post: CR Haeger
  HP 35s y^x vs. yrootx Richard Berler 8 1,203 09-28-2013, 12:32 PM
Last Post: Andrew Feist
  EOT--TI N-Spire Equation Limit Matt Agajanian 2 664 09-22-2013, 12:37 PM
Last Post: Matt Agajanian
  Does Prime Have a Multiple Equation Solver? Norman Dziedzic 2 637 09-20-2013, 09:43 AM
Last Post: Norman Dziedzic

Forum Jump: