Post Reply 
[VA] SRC#005- April, 1st Mean Minichallenge
04-01-2019, 08:09 PM
Post: #1
[VA] SRC#005- April, 1st Mean Minichallenge
 
Hi all, welcome to my meaningless but well-meaning  SRC#005 - April, 1st  Mean Minichallenge.
      
Given a set of data consisting of positive real numbers  x1, x2, ..., xn,  consider these four well-known means Mk for k = 1, 2, 3, 4:

      M1 = the Harmonic Mean = \(\frac{n}{\frac{1}{x_1} + \frac{1}{x_2} + ... + \frac{1}{x_n}} \)

      M2 = the Geometric Mean = \(\sqrt[n]{ x_1 x_2 ... x_n} \)

      M3 = the Arithmetic Mean = \(\frac{x_1 + x_2 + ... + x_n}{n} \)

      M4 = the Quadratic Mean = \(\sqrt{\frac{{x_1}^2 + {x_2}^2 + ... + {x_n}^2}{n}} \)

The Minichallenge:

Write code that accepts as input a dataset and the parameter k and returns the value of the corresponding mean Mk. For instance, for the sample dataset  4, 1, 20.19  your code should return:

      k = 1:   M1 = 2.3085
... (Harmonic mean)

      k = 2:   M2 = 4.3224
... (Geometric mean)

      k = 3:   M3 = 8.3966
... (Arithmetic mean)

      k = 4:   M4 = 11.8972
... (Quadratic mean)

Now, with the same sample dataset, use your code to return the values of the means  M5/2 , MPi , M-2.019  and  M0.61. Also, find the value of k which makes  Mk = Pi.

In a day or so I'll post my original solution which is a 3-line (138 bytes) subprogram for the HP-71B, but in the meantime see what you can do with any HP calc (not Excel, Python, etc.) of your choice and please post both code and results, not just math expressions or text explanations and such. Enjoy ! Smile

V.
 

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-01-2019, 10:30 PM
Post: #2
RE: [VA] SRC#005- April, 1st Mean Minichallenge
(04-01-2019 08:09 PM)Valentin Albillo Wrote:  sample dataset  4, 1, 20.19  your code should return:

      k = 1:   M1 = 2.3085
... (Harmonic mean)

      k = 2:   M2 = 4.3224
... (Geometric mean)
...

find the value of k which makes  Mk = Pi.

Let x=k-2, we have (4x + 1x + 20.19x) / 3 = Pix

Let f(x) = 4x + 1 + 20.19x - 3 Pix

⇒ f'(x) = 4x ln(4) + 20.19x ln(20.19) - 3 Pix ln(Pi)

Use Newton's method to solve for x, x = x - f(x) / f'(x)

guess(x) = guess(k) - 2 = 1.5 - 2 = -0.5
-0.4479070869
-0.4457521188
-0.4457475673

⇒ k = x + 2 = 1.5542524327
Find all posts by this user
Quote this message in a reply
04-02-2019, 02:18 PM
Post: #3
RE: [VA] SRC#005- April, 1st Mean Minichallenge
(04-01-2019 08:09 PM)Valentin Albillo Wrote:  sample dataset  4, 1, 20.19  ... return the values of the means  M5/2 , MPi , M-2.019  and  M0.61.

To simplify code, geometric mean is better off (and more accurate) use multiply, then take nth root.
Assuming all data positive, below HP-12C code use 0 as signal for getting mean.

01 X=0 ; signal for getting mean
02 GTO 07
03 RCL 0; power = k-2 ≠ 0
04 X^Y
05 Σ+
06 GTO 00
07 g 0 ; mean before inverse power
08 RCL 0
09 1/X
10 X^Y
11 GTO 00

Example, for quadratic mean, k=4

[Clear Register] 2 [STO 0]               ; stored power = k-2 = 2
4 [R/S] 1 [R/S] 20.19 [R/S] 0 [R/S] ; quadratic mean = 11.89728401

M-2.019 = 1.313123100
M0.61 = 1.979834390
M5/2 = 6.238885591
MPi = 8.981253690
Find all posts by this user
Quote this message in a reply
04-03-2019, 11:56 PM
Post: #4
RE: [VA] SRC#005- April, 1st Mean Minichallenge
 
Hi, all:
      
Well, I thought that this would make an interesting April, 1st entry but it seems I was pretty overoptimistic judging from Albert Chan being the only one who showed any interest by posting an amazingly concise solution for the HP-12C no less, complete with all correct solutions and equations to boot. Thanks a lot, Albert !

My original solution is the following 3-line subprogram (to vary a little from main programs and user-defined functions) for the HP-71B, which also deals with the Geometric Mean as well (unlike Albert's HP-12C program which does not, as he states himself):

      60  SUB GMEAN(A(),L,M) @ N=UBND(A,1) @ K=L-2 @ IF K THEN
      70  S=0 @ FOR I=1 TO N @ S=S+A(I)^K @ NEXT I @ M=(S/N)^(1/K) @ ELSE
      80  S=1 @ FOR I=1 TO N @ S=S*A(I)   @ NEXT I @ M=S^(1/N) @ END IF


The subprogram GMEAN (Generalized Mean), which can be called from any program in the RAM filesystem, accepts as parameters the array containing the dataset, the value of k, and returns in the specified variable (passed by reference) the value of the mean Mk. To test it and return the results I asked for, simply use this caller main program:

      10   DESTROY ALL @ OPTION BASE 1 @ DIM A(3),M @ READ A
      20   DATA 4,1,20.19
      30   INPUT K @ CALL GMEAN(A,K,M) @ DISP K;M

      >RUN
            ? 1       ->   2.30852787042    Harmonic mean
            ? 2       ->   4.32247115132    Geometric mean
            ? 3       ->   8.39666666667    Arithmetic mean
            ? 4       ->   11.8972840038    Quadratic mean

            ? 5/2     ->   6.2388855918     "midway" (!) between the Arithmetic Mean and the Geometric Mean
            ? PI      ->   8.98125368883
            ? -2.019  ->   1.31312310009
            ? 0.61    ->   1.97983439045

Notice that the limit of Mk when k tends to -Infinity is the minimum of the values in the dataset (some mean !) while, conversely, the limit of Mk when k tends to +Infinity is the maximum of the values in the dataset (ditto). To approximately check this:

      >RUN
            ? -380       ->   1.00288008791    { M-Inf = Min( x1, x2, ..., xn ) = 1 }
            ?  380       ->   20.1314053436    { M+Inf = Max( x1, x2, ..., xn ) = 20.19 }


Finally, to find the value of  k  which makes  Mk = Pi  we use this wrapper code (which assumes you've run the main program at least once) :

      40   INPUT M @ K=FNROOT(1,5,FNM(FVAR,M)-M) @ DISP K;FNM(K,M)
      50   DEF FNM(K,M) @ CALL GMEAN(A,K,M) @ FNM=M @ END DEF

      >RUN 40
            ? PI
                  1.55425243272      3.14159265359 { = M1.55425243272 }



That's all for now. Thanks again to Albert Chan for his interest and his worthy contribution, much appreciated. Smile

V.
 

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-06-2019, 11:41 AM
Post: #5
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hello!

(04-03-2019 11:56 PM)Valentin Albillo Wrote:  Well, I thought that this would make an interesting April, 1st entry but it seems I was pretty overoptimistic ...

No no no! No lack of interest. At least not from my part. But firstly it was a very busy week and secondly after a quick read I was not really sure that I understood the problem but didn't want to give away my stupidity by asking silly questions ;-)

Will try it out for myself now on the HP-71B and maybe the HP-39GII that I got in the mail today. The latter one should be able to solve the Pi-problem graphically.

And by the way, wouldn't it be more elegant for finding the value for e.g. M 5/2, instead of taking the mean between the results M2 and M3, to fit a polynomial through all four results?

Regards
Max
Find all posts by this user
Quote this message in a reply
04-06-2019, 10:34 PM
Post: #6
RE: [VA] SRC#005- April, 1st Mean Minichallenge
.
Hi, Maximilian:

(04-06-2019 11:41 AM)Maximilian Hohmann Wrote:  No no no! No lack of interest. At least not from my part.

Why, thank you ! It's always reassuring to know for a fact that some people find my productions interesting.

Quote:after a quick read I was not really sure that I understood the problem but didn't want to give away my stupidity by asking silly questions ;-)

There are no such things as silly questions for math-related challenges but in any case, whenever you'd like to ask some question about some challenge of mine and you don't want people to deem your question 'silly', just sent me a PM and I'll promptly answer your question in perfect privacy.

Quote:Will try it out for myself now on the HP-71B and maybe the HP-39GII that I got in the mail today. The latter one should be able to solve the Pi-problem graphically.

Good. If you do, please post your code in this thread, I'd love to see it.

Quote:And by the way, wouldn't it be more elegant for finding the value for e.g. M 5/2, instead of taking the mean between the results M2 and M3, to fit a polynomial through all four results?

I don't understand. The key to this mini-challenge is that all four means mentioned (Harmonic, Geometric, Arithmetic, Quadratic) are but discrete cases of a continuous Generalized Mean which includes those four as particular cases. The Generalized Mean ( Mk for short) is defined as:

        Mk = \( \left( \frac{\sum_{i=1}^n a_i^k}{n} \right) ^ \frac{1}{k} \)

and for k = -1, 0, 1, 2 it gives the Harmonic, Geometric (in the limit), Arithmetic and Quadratic means, respectively (for purely cosmetic purposes I did shift k by 2 to make it 1, 2, 3 and 4 instead).

So you see, as k is a continuous parameter (so not necessarily an integer) from -Inf to +Inf, you can compute Mk directly by using the above formula, no need to "take the mean" of any two results or perform any "polynomial fit", which matter of fact wouldn't succeed as the dependence on k is in the exponents and thus no polynomial fit would ever do.

Thanks again for your interest, much appreciated, and have a nice weekend.

V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-07-2019, 12:01 AM (This post was last modified: 04-07-2019 12:09 AM by Albert Chan.)
Post: #7
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hi, Maximilian:

I too were afraid of posting a "stupid" solution (never heard of Generalized Mean)

Mk^k = (a1^k + ... + an^k) / n

The case for k=0 doesn't fit quite right, getting meaningless result, M0 = 1^∞
I had to convince myself this work for Geometric Mean.

For k=ε (small value, but not exactly 0):

LHS = Mε^ε = e^(ε ln(Mε)) ≈ 1 + ε ln(Mε)

RHS = (a1^ε + ... + an^ε) / n ≈ ((1 + ε ln(a1)) + ... + (1 + ε ln(an))) / n ≈ 1 + ε ln(a1 ... an) / n

⇒ Mεn√(a1 ... an)
⇒ M0 = n√(a1 ... an)
Find all posts by this user
Quote this message in a reply
04-07-2019, 12:45 PM (This post was last modified: 04-07-2019 12:49 PM by Maximilian Hohmann.)
Post: #8
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hello Valentin and Albert,

(04-06-2019 10:34 PM)Valentin Albillo Wrote:  Good. If you do, please post your code in this thread, I'd love to see it.

I will. First I have to read a little more of the HP39Gii manual... It has it's own programming langauge, a bit of a mix of everyting. Some BASIC, some keystroke programming and every line has to be terminated with a semicolon just like in C.

Quote:I don't understand. The key to this mini-challenge is that all four means mentioned ... are cases of a Generalized Mean ... is defined as:

So this is the core of the stupid question I was too afraid to ask ;-) Like Albert I had never heard of this before. Instead I falsely assumed that your April fool's challenge was based on arbitrarily assigning discrete indices to different ways of calculating means and then somehow interpolating between them.

I asked Wikipedia about it and found out that in Germany it is actually called the "Hölder-Mittel" (https://de.wikipedia.org/wiki/H%C3%B6lder-Mittel) of which I had never heard before either. A strange kind of April First sidenote is that it is also known as "Potenzmittel". Now this is a German word which also has a completely different meaning that one usually associates with male-specific medication, the most prominent brand name being "Viagra".

But I will go back to my 39Gii (*) and see if I can administer the "Potenzmittel" somehow into it's memory :-)

Regards
Max

(*) In case anyone wants one: There is a guy in the UK who currently sells off these calculators for 10 GPB a piece + shipping on eBay. This is where I got mine from. They come from a girs-only boarding school on the outskirts of London and don't seem to have seen much usage - if any at all. Decent value for money if one does not want or need RPN/RPL.
Find all posts by this user
Quote this message in a reply
04-07-2019, 01:21 PM
Post: #9
RE: [VA] SRC#005- April, 1st Mean Minichallenge
(04-07-2019 12:45 PM)Maximilian Hohmann Wrote:  ...First I have to read a little more of the HP39Gii manual... It has it's own programming langauge, a bit of a mix of everyting. Some BASIC, some keystroke programming and every line has to be terminated with a semicolon just like in C.

The 39gii is really a Prime- ; the immediate predecessor of the Prime, it's OS, language and many features are actually quite close to (the early) Prime. It's stark appearance and mono-LCD are deceiving and make it appear much different, however they are far closer than they appear.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
04-07-2019, 06:03 PM (This post was last modified: 04-11-2019 02:02 PM by Maximilian Hohmann.)
Post: #10
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hello!

(04-07-2019 01:21 PM)rprosperi Wrote:  The 39gii is really a Prime- ; ...

The "poor man's Prime" so to say :-) I played all afternoon with it and it really is an interesting machine. Especially for the price you can find it for. It only crashed once during several hours (needed to take the batteries out to get it going again) which is not bad for this type of device.

Unfortunately HP does not care the least about us Macintosh users (different to Ti whose "Ti Connect" software has always been running on Macs as well). Although I was able to install the connectivity kit inside a Virtual Box it does not "see" the connected calculator... So I have to post photograhs of my results instead.

This is my 39Gii version of Valentin's program above. My attempts to pass a list, matrix or vector to a program resulted in the above mentioned crash, therefore I decided to use the inelegant way of storing the dataset in the global "L1" variable for lists. Entering the example data is done by typing {1,4,20.19} Sto Alpha L 1 Enter. (Note: Don't search for "Sto" on the keyboard, it is a menu funtion. What were these guys drinking when they designed this interface ?) As a genearal note, lots and lots of alternating "Alpha" and "Shift" pressing is necessary to program this calculator. A major, major, super major nuisance!

The "GMEAN" program itself - not optimised in any way - reads like this, maintaining Valentin's variable names:

EXPORT GMEAN(L)
BEGIN
LOCAL K,N,G,S,I;
L-2 -> K; (Note: the "->" is in reality a black arrow that can be entered by menu command "STO" only)
SIZE(L1) -> N; (Note: L1 is one of ten global variables for lists)
0->G;
IF K != 0 THEN (Note: Do not type "!=" here even if the manual says so. Use the crossed-out equal sign accessible only from some menu-submenu instead. This took me almost an hour to find out and fix...)
(extra Note: Back in the day when I paid for my mortgage by writing programs used to design large airliners I would not have checked against "0" here but against some very small number to make sure binary rounding stuff would not result in loss of human life. Now I couldn't care less.)
0->S;
FOR I FROM 1 TO N DO (Note: Do insert all blank spaces manually here, using Alpha and the "+" key. The smart menu that creates the control expressions unsfortunately does not instert blank spaces around them which even more unfortunately are required for the program to work. My Sinclair ZX81 from 1981 did a lot better in that respect.)
S+L1(I)^K -> S;
END;
(S/N)^(1/K) -> G; (Note: Some of the parentheses may actually not be necessary but I added them just in case. After some time I ran out of patiance for debugging and kept pressing the "(" and ")" instead - but the debugger itself is really not bad)
ELSE
1->S;
FOR I FROM 1 TO N DO
S*L1(i)->S; (Note: As in Valentin's program "S" is actually a product here, not a sum - this is for the special case of the geometric mean)
END;
S^(1/N)->G;
END;
RETURN G;
END;


This programme, by using the "EXPORT" before it's name, makes the function "GMEAN" globally available on the calculator. Just like "SIN" or "LN". To try it out one can either type it into the "Home" screen as a command, e.g. GMEAN(1) or use the interface of the "Prgm" function which will smartly prompt for all function values (in this case there is only one). I like that latter functionality, otherwise one would have to code it oneself. Valentin's examples could be easily verified that way.

To solve for the GMEAN = "Pi" challenge I used the graphing "App" of the calculator. It could of course have been done in many other ways as well. Also the necessary commands could have been added to the code, making it fully automatic.

However I stayed with the semi-automatic way of doing things (like operating one's autopilot in "HDG" and "ALT HOLD" mode instead of using "LNAV" and "VNAV") and in the "Symb" menu defined and checked (the latter bit is very important - forget the check marks which are only available through the menu! and nothing will happen) two functions (I have to insert a photo here because, as already written, my Macintosh and the Hp-39GII did not become intimate friends):

[Image: IMG_0129_640px.jpg]

Then I used the "Plot" key, manually set the boundaries for X from -1 to 5 and for Y from 1 to 20 and got the plot shown below. Within the Plot-screen simply use the "FCN->Intersect" menu and the value of K for which the generalized mean will be Pi is smartly shown at the bottom of the screen. Again, all this can somehow be programmed if one would want to present a fully autmatised version.

[Image: IMG_0128_640px.jpg]

Regards
Max

Note: Edited to reduce the picture size as requested
Find all posts by this user
Quote this message in a reply
04-10-2019, 12:10 AM
Post: #11
RE: [VA] SRC#005- April, 1st Mean Minichallenge
      
Hi, Albert Chan:

(04-07-2019 12:01 AM)Albert Chan Wrote:  The case for k=0 doesn't fit quite right, getting meaningless result, M0 = 1^∞
I had to convince myself this work for Geometric Mean.

Good explanation. Though the code has to include the Geometric Mean as an special case to avoid the 1^∞ you mention, the generalized formula does actually work for values of k approaching from both sides. For instance, using my original solution we get:

      >RUN
            ? 1.999999   ->   4.3224 57 34930    {  M1.999999 (general case)  }
            ? 2          ->   4.3224 71 15132    {  M2 (special case = Geometric Mean)  }
            ? 2.000001   ->   4.3224 78 34444    {  M2.000001 (general case)  }

V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-10-2019, 04:23 PM
Post: #12
RE: [VA] SRC#005- April, 1st Mean Minichallenge
This site has some practical information on calculating the geometric mean of data that includes zero values. Linked from the Wikipedia article on geometric mean.
Find all posts by this user
Quote this message in a reply
04-10-2019, 09:54 PM
Post: #13
RE: [VA] SRC#005- April, 1st Mean Minichallenge
.
Hi, Maximilian:

(04-07-2019 12:45 PM)Maximilian Hohmann Wrote:  Like Albert I had never heard of this before. Instead I falsely assumed that your April fool's challenge was based on arbitrarily assigning discrete indices to different ways of calculating means and then somehow interpolating between them.

Hehe, no, my "April Fool" minichallenges are intended to seem weird and/or impossible but they're never arbitrary or fake, they're solvable in a deterministic way with nothing arbitrary to them (see the archives for some others, like my "SSMC-20-April 1st 2008 Spring Special", for instance).

Quote:I asked Wikipedia about it and found out that in Germany it is actually called the "Hölder-Mittel" (https://de.wikipedia.org/wiki/H%C3%B6lder-Mittel) of which I had never heard before either. A strange kind of April First sidenote is that it is also known as "Potenzmittel". Now this is a German word which also has a completely different meaning that one usually associates with male-specific medication, the most prominent brand name being "Viagra".

How unexpected (and fun!) ! Seems that both of us learned new things ! What an unexpected connection ! ... (and in German no less) Smile

Quote:This is my 39Gii version of Valentin's program above. [...]. What were these guys drinking when they designed this interface ?) As a genearal note, lots and lots of alternating "Alpha" and "Shift" pressing is necessary to program this calculator. A major, major, super major nuisance!

Thanks a lot for your code, I find it perfectly understandable but unnecessarily complicated in the little details when compared to plain simple HP-71B BASIC.

I don't understand why HP kept and still keeps inventing new programming languages particularized for this or that new calc when they already had the very best, most powerful ones. In the case of (HP71B-like) BASIC, a few extensions here and there (i.e.: additional keywords and polls) would accommodate any new capabilities (such as graphics, lists, etc.), the same way HP did with the (71B) Math ROM, which added new data types (COMPLEX, COMPLEX SHORT) to the existing ones (INTEGER, SHORT, REAL) and extended/added the necessary capabilities to handle them.

As for your "What were these guys drinking [...] ?" I've found myself thinking the same about some of the stupid decisions they made for the HP-71B and its Math ROM, so nothing new there, it happens with many models.

Quote:The "GMEAN" program itself - not optimised in any way - reads like this,
[...]
L-2 -> K; (Note: the "->" is in reality a black arrow that can be entered by menu command "STO" only)
[...]
IF K != 0 THEN (Note: Do not type "!=" here even if the manual says so. Use the crossed-out equal sign accessible only from some menu-submenu instead. This took me almost an hour to find out and fix...)
[...]
FOR I FROM 1 TO N DO (Note: Do insert all blank spaces manually here, using Alpha and the "+" key. The smart menu that creates the control expressions unsfortunately does not instert blank spaces around them which even more unfortunately are required for the program to work. My Sinclair ZX81 from 1981 did a lot better in that respect.)

Your comments (highlighted in dark red above) are hilarious, if sad. I guess there was little regard for usability tests when they designed the interface, else they'd have notice the many inconveniences and plain annoyances. Perhaps too strict deadlines or too few people assigned to do the checking. Anyway, if buyers can be (and actually are) used as beta testers for functionality, they may be for usability as well,

Quote:I have to insert a photo here because, as already written, my Macintosh and the Hp-39GII did not become intimate friends):

Nice pics, thanks for including them but I'd like to ask you a favour: could you please edit your post to replace those large pictures with smaller versions ? The large size ruins the format of the PDF I intend to create with this thread, as I usually do. Thanks in advance ! ... Smile

Best regards.
V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-11-2019, 02:13 PM (This post was last modified: 04-11-2019 02:14 PM by Maximilian Hohmann.)
Post: #14
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hello Valentin,

(04-10-2019 09:54 PM)Valentin Albillo Wrote:  I don't understand why HP kept and still keeps inventing new programming languages particularized for this or that new calc when they already had the very best, most powerful ones. In the case of (HP71B-like) BASIC, a few extensions here and there ...

I don't understand that either. They had everything in that calculator already. And there is still a market for good quality BASIC programmable calculators as Ti shows us every day...
A reason why I like the Ti Voyage 200 so much is because for me it is kind of a 21st century successor of the HP-71B: With a dedicated typewriter keyboard, an excellent BASIC language and connectivity. Plus of course some modern goodies like a fast processor, plenty of memory, a graphic display and CAS.

(04-10-2019 09:54 PM)Valentin Albillo Wrote:  Nice pics, thanks for including them but I'd like to ask you a favour: could you please edit your post to replace those large pictures with smaller versions ? The large size ruins the format of the PDF I intend to create with this thread, as I usually do.

I just resized them to 640 pixels (for nostalgic reasons only because 640 x 480 pixels was at one time _the_ standard for video graphics displays...). If this is still too large I can reduce them further.

Regards
Max
Find all posts by this user
Quote this message in a reply
04-11-2019, 11:56 PM
Post: #15
RE: [VA] SRC#005- April, 1st Mean Minichallenge
.
Hi again, Maximilian:

(04-11-2019 02:13 PM)Maximilian Hohmann Wrote:  II don't understand that either. They had everything in that calculator already. And there is still a market for good quality BASIC programmable calculators as Ti shows us every day...
A reason why I like the Ti Voyage 200 so much is because for me it is kind of a 21st century successor of the HP-71B: With a dedicated typewriter keyboard, an excellent BASIC language and connectivity. Plus of course some modern goodies like a fast processor, plenty of memory, a graphic display and CAS.

Seems like a very interesting machine, all the more if you recommend it as I know for sure that you're also very fond of HP-71B BASIC, so I think I'll soon have a thorough look at it and if I like what I see it's perfectly possible that I'll get one for my ultra-portable, on-the-go calc needs (as my Samsung tablet is not that ultra-portable, go71b is nearly unusable on it, and also I do not like or trust the Prime). It would be my very first ever TI machine !

On a side note, I've never understood why HP calc fans are so uninterested (even dismissive) about the HP-71B and 71B BASIC. It could be due to its unavailability when it was released, as it was so expensive that most HP fans couldn't lay their hands on one, but now that you can get one for peanuts (even as a gift) or in emulated form for nothing (Emu71/DOS, Emu71/Windows), the main reason for not owning and using one has become utterly moot.

Matter of fact, it runs so many rings around anything RPN in all counts, and even exponentially more rings around RPL (all flavours) in terms of code readability and maintenance, that I find it very hard to understand why people would prefer to use those languages for anything other than simple throw-away programs or implementing "libraries" or doing stackrobatics and such.

I think that the moment they must develop a significantly complex (even real-life) application, while further being expected to understand and maintain it in the not-so-near future, they'll see what I mean. I still perfectly understand and am able to modify or extend very long, complex 71BASIC programs (say 100-200 multi-statement lines or more) just by looking at the listing and little else. Can that be done with an equally long and complex RPL program without extensive comments, stack mapping and lots of documentation ? I seriously doubt it.

Quote:I just resized them to 640 pixels (for nostalgic reasons only because 640 x 480 pixels was at one time _the_ standard for video graphics displays...). If this is still too large I can reduce them further.

That's perfect, no need for further size reduction. Thanks a lot for so promptly and efficiently honoring my request and for your entire post, much appreciated.

Best regards.
V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-12-2019, 12:27 PM (This post was last modified: 04-12-2019 12:33 PM by Maximilian Hohmann.)
Post: #16
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hello,

(04-11-2019 11:56 PM)Valentin Albillo Wrote:  [Ti Voyaga] so I think I'll soon have a thorough look at it and if I like what I see it's perfectly possible that I'll get one for my ultra-portable, on-the-go calc needs ...

Well, the term "ultra portable" is of course open to interpretation. I took a quick photo of some scientific calcuators I pulled out from the heaps around my desk (all of which of course are functional and able to solve the problem from this thread with the exception of the orinial HP-35). Interestingly their sizes do not differ as much as one would have thought. The notable exception is the cute "Woodstock" whose footprint is only 1/2 of most of the others. The biggest and heaviest one is actually the 2nd generation Ti Nspire. The Voyage has 14% more square centimeters than the HP-71B but does not need a protective case and therefore uses less space in the briefcase than the HP.

[Image: IMG_0131_640px.jpg]

(Just for those readers unfamiliar with non-HP calculators, the top row shows:
Ti Voyage 200, HP-71B with an extra memory module in place of the card reader, Ti nSpire (2nd generation), HP-39gii, Ti-83plus, HP-48G
the bottom row: HP-95LX, HP-29C, HP-35 version 3, HP-35s, Ti-59, HP-41CV)


(04-11-2019 11:56 PM)Valentin Albillo Wrote:  On a side note, I've never understood why HP calc fans are so uninterested (even dismissive) about the HP-71B and 71B BASIC. It could be due to its unavailability when it was released, as it was so expensive that most HP fans couldn't lay their hands on one, but now that you can get one for peanuts (even as a gift) or in emulated form for nothing (Emu71/DOS, Emu71/Windows), the main reason for not owning and using one has become utterly moot.

[unavailability] When it came out I was at univerisity and not even able to afford an HP-41. The 71B cost over twice as much and a couple of accessories could drive the price up to the level of a decent family car. My Ti-59 cost only half of the HP-41 for comparison. (The car I was driving at the time had cost me 300 DM, an HP-71B would have cost between 1500 and 2000 DM - just to show how out-of-the world the price tag was - about as much a Commodre PET, Apple II or other first-generation "home computer" which then were really the things we wanted to have).
I always wonder why so many of them are available on the collector market now, there must have been a lot of wealthy professionals back then who (or whose employer) could afford them. But that's good for us of course :-)

I wonder what would have happened if HP had brought out a direct successor in the early 1990ies, an HP-72B. Leave the then obsolete card reader away, instead install a 2-line display over the full width and solder some more memory onto the board. Maybe include the contents of some popular extension ROMs as standard. The competition (Sharp, Casio) did essentially that and were very successful with their Basic-programmables.

Regards
Max
Find all posts by this user
Quote this message in a reply
04-12-2019, 02:14 PM
Post: #17
RE: [VA] SRC#005- April, 1st Mean Minichallenge
(04-12-2019 12:27 PM)Maximilian Hohmann Wrote:  When it came out I was at univerisity and not even able to afford an HP-41. The 71B cost over twice as much and a couple of accessories could drive the price up to the level of a decent family car. My Ti-59 cost only half of the HP-41 for comparison. (The car I was driving at the time had cost me 300 DM, an HP-71B would have cost between 1500 and 2000 DM - just to show how out-of-the world the price tag was - about as much a Commodre PET, Apple II or other first-generation "home computer" which then were really the things we wanted to have).
I always wonder why so many of them are available on the collector market now, there must have been a lot of wealthy professionals back then who (or whose employer) could afford them. But that's good for us of course :-)

Oh, definitely professionals. Stuff that's astronomically expensive from a hobbyist's point of view can make perfect sense in a business context.

For example, one time when I had only been a professional programmer for a few years, I had to debug a memory leak. The application in question was large enough that simply staring at the code until I figured it out was not an option. I did a bit of research and found a tool that looked perfect for the job, but it was not something we already had. So, we would have to buy it, and the price was $1500 (U.S.).

With my hobbyist sensibilities, I thought $1500 was insane. But I really needed this thing, so I went to my boss, fully expecting to be turned down at such an extreme price tag. Instead, he didn't even blink. He just asked, "do you need this?" And I told him that I expected it to save me about two weeks of work on the current project. That was all he needed to hear, he signed the purchase order right away. And once I thought of what two weeks of my time actually cost the company, it was clear that this really was a no-brainer.

I'm sure that's how it goes with a lot of that seemingly-expensive HP equipment. It saves people work and that's how it pays for itself. And if it is just a bit more reliable or easy to use than cheaper equivalents, that extra money usually pays for itself, too.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-12-2019, 09:54 PM
Post: #18
RE: [VA] SRC#005- April, 1st Mean Minichallenge
Hello Valentin,
Sorry for being a bit late and thanks for the interesting challenge.
I learned a lot about "mean" calculations (and about HP 15c prgramming). I always wondered how the geometric mean is connected to the other means.

Here is my solution for the HP 15C:
Code:
001  LBL A        | 42,21,11  # Mean calculation subroutine, expects data in Matrix A and k in x
002  2            |        2
003  -            |       30 
004  STO 8        |    44  8  # STO  p = k - 2
005  MATRIX 1     | 42,16, 1  # Reset matrix indices
006  CLR_Sum      |   42  32
007  LBL .0       | 42,21,.0
008  RCL A        |   45  11  # Get matrix element
009  RCL 8        |    45  8
010  x=0          |   43  20
011  GTO .1       |    22 .1
012  y^x          |       14  # p is not 0
013  GTO .2       |    22 .2
014  LBL .1       | 42,21,.1  # p is 0 (=geometric mean)
015  R_down       |       33
016  x=0          |   43  20  # Check, whether xi is 0 
017  RTN          |   43  32  # If yes, finished
018  LN           |   43  12  
019  LBL .2       | 42,21,.2
020  SUM+         |       49
021u RCL A        |   45  11  # Next element (note the user mode u)
022  GTO .0       |    22 .0
023  E(X)         |    43  0  # Get the average
024  RCL 8        |    45  8
025  x=0          |   43  20  # Check, whether p is 0
026  GTO .1       |    22 .1
027  1/x          |       15  # p is not 0
028  y^x          |       14
029  RTN          |   43  32
030  LBL .1       | 42,21,.1  # p is 0 (=geometric mean)
031  R_down       |       33
032  e^x          |       12
033  RTN          |   43  32
034  LBL B        | 42,21,12  # Helper function for solving Mp(A) = pi
035  GSB A        |   32  11
036  PI           |   43  26
037  -            |       30
Here the geometric mean is also calculated with the intrinsic averaging functions of the calculator. In the case k=2 the ln(xi) are summed and afterwards e^x of the average is calculated. The relative error of the method compared to the standard calculation using the products is 4.6e-10 for the values you used.
The value for the geometric mean calculated by the logarithmic summation is:
M2=4.322471149

The value calculated by multiplication is
M2=4.322471151

Here are the values for the requested parameters:
M-2.019 = 1.313123100
M0.61 = 1.979834390
M5/2 = 6.238885591
MPi = 8.981253690

The solution of Mp=pi is calculated by the sequence
Code:
1
ENTER
2
SOLVE B
My solution for p is p=1.554252433 or k =3.554252433.

Best regards
Bernd
Find all posts by this user
Quote this message in a reply
04-13-2019, 12:08 AM
Post: #19
RE: [VA] SRC#005- April, 1st Mean Minichallenge
.
Hi, Maximilian and Bernd Grubert,

Just some quick comments on your respective posts:

Maximilian Hohmann Wrote:HP-71B with an extra memory module in place of the card reader

One of my physical HP-71B is very similarly fitted, with a 128 Kb RAM module (CMT) in the card reader slot, plus a Math ROM, HP-IL ROM, and 4 Kb RAM modules.

Maximilian Hohmann Wrote:I was at univerisity and not even able to afford an HP-41. The 71B cost over twice as much

How lucky ! It was over three times as much here in Spain, completely unaffordable to me. However, I managed to get one via my then employer, exactly as Thomas Okken did.

Maximilian Hohmann Wrote:I always wonder why so many of them are available on the collector market now, there must have been a lot of wealthy professionals back then who (or whose employer) could afford them.

Nothing of the sort. The UK Government's DHSS (Department of Health and Social Security) ordered thousands of HP-71Bs in the 80's, together with a specialized DHSS ROM, a wand, HP-IL ROM and additional software and hardware. The DHSS ROM turned each HP-71B into a terminal for a one-off file tracking database system, you can read full details here.

In the 90's they became obsolete and were all sold extremely cheaply so the second hand market for the HP-71B was flooded with machines in good working condition fitted with HP-IL ROM, at least one 4 Kb RAM module, and at times even the DHSS ROM itself and/or the wand, but no manuals or leather case or anything else. I bought several back then at US$ 25 each but afterwards I saw them being offered even cheaper and at one HP-fan meeting each attendant was given one for free, as a door prize so to say.

That's the real reason they're so cheap and so aplenty, no need to postulate 'wealthy professionals'. Smile

(PS: Also, I remember I bought four HP-71B via TAS, this time at US$ 50 each, but everyone of them came fitted with a Math ROM (!!), to my immense delight. I doubt they were DHSS machines so: where did they come from ? Another large order by some technical department or something ?)

Maximilian Hohmann Wrote:I wonder what would have happened if HP had brought out a direct successor in the early 1990ies, an HP-72B.

Perhaps HP intended to release a successor but then someone new was hired and made sure to push real hard stack-based models, putting an end to that possibility and so killing for sure any future HP BASIC pocket computers, thus leaving an enormously lucrative market to many very successful SHARP and CASIO models. HP's loss.

(04-12-2019 09:54 PM)Bernd Grubert Wrote:  Sorry for being a bit late and thanks for the interesting challenge. I learned a lot about "mean" calculations (and about HP 15c prgramming). [...] Here is my solution for the HP 15C:

You're welcome, and thanks to you for an excellent solution for the HP-15C, which is very short (just 37 steps) and delivers all correct results to the questions the challenge asked for, so congratulations are in order.

The trick of computing the Geometric Mean by adding logarithms and then a final exponential is perfectly Ok for strictly positive datasets, as in this case, and the precision lost amounts to but a few ulps in the worst case, so it's perfectly acceptable as well.

Thanks again for your interest and for posting such a fine solution. Hope to see you participating in my next challenge or, if you're up to it and would rather not wait, Tier 2 got no solutions at all in my recent S&SMC#24 (still visible in the main page) and it's perfectly within the capabilities of an HP-15C and a keen user like yourself.
Wanna give it a try ? Smile

Best regards to all.
V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-13-2019, 05:31 AM
Post: #20
RE: [VA] SRC#005- April, 1st Mean Minichallenge
(04-13-2019 12:08 AM)Valentin Albillo Wrote:  Nothing of the sort. The UK Government's DHSS (Department of Health and Social Security) ordered thousands of HP-71Bs in the 80's, together with a specialized DHSS ROM, a wand, HP-IL ROM and additional software and hardware. The DHSS ROM turned each HP-71B into a terminal for a one-off file tracking database system, you can read full details here.

I wasn't aware of this, a short but very enjoyable thread - thanks for the pointer.
ÁM
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)