Post Reply 
[VA] SRC #012c - Then and Now: Sum
11-27-2022, 10:20 PM
Post: #1
[VA] SRC #012c - Then and Now: Sum
  
Hi, all,

After the nice solutions posted for Problem 2 and the 2,500 views mark exceeded (plus no less than three other related threads created by Albert Chan, Thomas Klemm and J-F Garnier,) now's the time for the next part of my SRC #012 - Then and Now, where I'm showing that vintage HP calcs which were able problem-solvers back THEN in the 80's can NOW solve recent tricky problems intended to be tackled with fast modern computers, never mind slow ancient pocket calcs.

In the next weeks I'm proposing six increasingly harder such problems for you to try and solve using your vintage HP calcs while abiding by the mandatory rules summarized here:
    You must use VINTAGE HP CALCS (physical/virtual,) coding in either RPN (inc. mcode), RPL (variants existing at the time, inc. SysRPL) or HP-71B languages (inc. BASIC, FORTH, Assembler), so NO XCAS, MATHEMATICA, MAPLE, EXCEL, C/C++/C#, PYTHON, etc., NO LENGTHY MATH SESSIONS and NO CODE PANELS.

    On the plus side, you may use any official/popular modules, pacs or libraries available at the time, such as the Math Pac, HP-IL and JPC ROMs for the HP-71B, the Advantage Module, PPC ROM and Extended Memory for the HP-41, and assorted libraries for the RPL models, to name a few.

That said, I'm done with holding back so here you are, a new problem which deals with the sum of an infinite series, namely:
    As an aside, you may remember the RPN program featured in my HP Article VA001 - Long Live the HP-11C, which used an efficient algorithm to quickly and accurately compute the sum of alternating series (say 1 - 1/2 + 1/3 - 1/4 + ...), even oscillating (say 1 - 1 + 1 - 1 + ...) or divergent ones (say 1 - 2 + 3 - 4 + ....)
Problem 3:  Sum
    Write a sumptuous program to summarily sum this unassuming yet serious series:
        [Image: SRC-12-3-1c.jpg]
    where f(n) is defined thus:  if n < 3 then f(n) = n else  f(n) = n * f(d(n)), where d(n) = number of binary digits of n.


    An example will make it clear; to compute f(10) we proceed as follows:

      We need f(10), which is  10 * f(d(10)) = 10 * f(4)   {as 10 = 10102 which has 4 binary digits}
           and now we need f(4), which is   4 * f(d(4)) = 4 * f(3)   {as 4 = 1002 which has 3 binary digits)
                and now we need f(3), which is   3 * f(d(3)) = 3 * f(2)   {as 3 = 112 which has 2 binary digits)
                     and now we need f(2), which is 2 by definition

    and backtracking we have f(3) = 3*2 = 6 and then f(4) = 4*6 = 24 and finally f(10) = 10*24 = 240.
Your program should have no inputs and must output the sum and automatically end. You should strive for 10-12 correct digits and the faster the running time the better.

Some useful advice is to try and find the correct balance between the program doing all the work with no help from you (i.e. sheer brute force, which might take substantial running time,) or else using some insight to help speed up the process. Your choice.

If I see interest, in a week or so I'll post my own original solution for the HP-71B, which is a 6-line program that does the job. In the meantime, let's see your very own clever solutions AND remember the above rules, please.

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
Post Reply 


Messages In This Thread
[VA] SRC #012c - Then and Now: Sum - Valentin Albillo - 11-27-2022 10:20 PM



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