Post Reply 
General challenge for site members
06-21-2024, 03:54 PM
Post: #1
General challenge for site members
Hi All,

We enjoy tinkering with various types of calculations such as pi (to many decimals), log(2), and other functions. But as I look to what is happening in the world of computer software, the focus seems on AI, machine learning, and deep learning! It seems out there no one really cares about rehashing known mathematical constants and functions like log, sin, and so on!!

My general challenge is to push machines like the HP-71B (with MATH ROM?), HP-42s (and variants), and the HP Prime to implements even low-end machine learning algorithms. Any chance that we can make these calculators rise to meet the AI challenge?

Namir
Find all posts by this user
Quote this message in a reply
06-21-2024, 07:13 PM
Post: #2
RE: General challenge for site members
Contemporary "AI" seems to be based on linear algebra. With enough memory, and a matrix multiplication routine, you could do something. Recognising the digits 0-9 in noisy images is a possible starting point, although even that might be too demanding.
Find all posts by this user
Quote this message in a reply
06-21-2024, 07:36 PM
Post: #3
RE: General challenge for site members
I faintly recall seeing a Hexapawn game (mini chess on a 3x3 board) for the HP 65 that learns the optimal moves to make as you play against it. I think it might have been in one of the earlier issues of PPC Journal.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-21-2024, 07:56 PM
Post: #4
RE: General challenge for site members
If a pile of matchboxes can learn how to play noughts and crosses, a calculator should be able as well:




For the training we might also consider the:
[Image: tic_tac_toe.png]
Find all posts by this user
Quote this message in a reply
06-21-2024, 09:08 PM
Post: #5
RE: General challenge for site members
Hello,

here is a simple version of ELIZA, the artificial psychiatraist, so to say the mother of all natural language communication software. Written for the HP-71B by ChatGPT:

Code:
10 ! Simple ELIZA program for HP-71B
20 DIM A$[100], B$[100]
30 DISP "HELLO. I AM ELIZA. HOW CAN I HELP YOU TODAY?"
40 INPUT A$
50 IF A$ = "" THEN GOTO 40
60 GOSUB 200
70 DISP B$
80 GOTO 40

200 ! Pattern matching subroutine
210 IF INSTR(A$, "HELLO") THEN B$ = "HELLO. HOW ARE YOU FEELING TODAY?": RETURN
220 IF INSTR(A$, "I FEEL") THEN B$ = "WHY DO YOU FEEL"+MID$(A$, INSTR(A$, "I FEEL") + 6): RETURN
230 IF INSTR(A$, "BECAUSE") THEN B$ = "IS THAT THE REAL REASON?": RETURN
240 IF INSTR(A$, "I AM") THEN B$ = "HOW LONG HAVE YOU BEEN"+MID$(A$, INSTR(A$, "I AM") + 4): RETURN
250 IF INSTR(A$, "I THINK") THEN B$ = "WHY DO YOU THINK"+MID$(A$, INSTR(A$, "I THINK") + 7): RETURN
260 IF INSTR(A$, "YES") THEN B$ = "YOU SEEM QUITE CERTAIN.": RETURN
270 IF INSTR(A$, "NO") THEN B$ = "WHY NOT?": RETURN
280 IF INSTR(A$, "YOU") THEN B$ = "WE SHOULD TALK ABOUT YOU, NOT ME.": RETURN
290 IF INSTR(A$, "ALWAYS") THEN B$ = "CAN YOU THINK OF A SPECIFIC EXAMPLE?": RETURN
300 IF INSTR(A$, "NEVER") THEN B$ = "WHY DO YOU THINK THAT IS?": RETURN
310 IF INSTR(A$, "EVERYONE") THEN B$ = "CAN YOU THINK OF ANYONE IN PARTICULAR?": RETURN
320 B$ = "TELL ME MORE ABOUT THAT.": RETURN

Good night
Max
Find all posts by this user
Quote this message in a reply
06-22-2024, 02:48 AM
Post: #6
RE: General challenge for site members
(06-21-2024 07:13 PM)EdS2 Wrote:  Contemporary "AI" seems to be based on linear algebra.

We can consider linear regression a very simple form of machine learning.
From this perspective the HP-42S has it already built in:
  • use the Σ+ key to train the model
  • use the FCSTY key to make a prediction
You can even use a pre-trained model and fine tune it.

Apparently some eccentric professors of numerical analysis used that when they woke up in the morning and felt feverish.
Find all posts by this user
Quote this message in a reply
06-22-2024, 11:01 AM (This post was last modified: 06-22-2024 11:01 AM by Namir.)
Post: #7
RE: General challenge for site members
How about classification algorithms like the k-nearest neighbors algorithm and the k-means clustering? I think the HP Prime can implement it.

Namir
Find all posts by this user
Quote this message in a reply
06-22-2024, 12:07 PM (This post was last modified: 06-22-2024 12:11 PM by Maximilian Hohmann.)
Post: #8
RE: General challenge for site members
Hello,

or a simple neural network?

Please write a program for the hp-71b based on a neural network to predict results in the British premier league from previous games

Answer: Creating a neural network on an HP-71B is quite challenging due to its limited computational resources and memory. The HP-71B is a vintage calculator/computer from the 1980s with a BASIC-like language, and it was not designed for complex tasks like neural networks. However, I'll provide a simplified version of a program that could predict outcomes based on some basic statistics, which might give you a rough idea.

... AI generated statistics based program omitted ...

Next question: „Thank you, assume that the hp-71b has 64kBytes of RAM extension, would a neural network solution be feasible

Answer: Even with 64KB of RAM, implementing a neural network on the HP-71B would be challenging due to its processing power and limitations in handling complex arithmetic operations efficiently. However, a very simple neural network might be feasible, especially if you restrict the network size and training data. Here is an attempt at a basic neural network implementation for predicting outcomes in the British Premier League.
...
Implementing even a simple neural network on the HP-71B is an educational exercise in understanding the limitations of vintage hardware and how computational constraints shape the design of algorithms. For practical purposes, more modern hardware and software environments are recommended for machine learning tasks.

... more detailed explanations omitted ...

So here it is, the neural network for predicting football results:
Code:
10 DIM W(2), X(2), Y(2)
20 INPUT "NUMBER OF TEAMS: "; N
30 DIM TEAMS$(N), GAMES(N,2)
40 FOR I = 1 TO N
50   INPUT "TEAM NAME: "; TEAMS$(I)
60   INPUT "GOALS SCORED: "; GAMES(I,1)
70   INPUT "GOALS CONCEDED: "; GAMES(I,2)
80 NEXT I
90 INPUT "HOME TEAM: "; HOME$
100 INPUT "AWAY TEAM: "; AWAY$
110 FOR I = 1 TO N
120   IF TEAMS$(I) = HOME$ THEN H = I
130   IF TEAMS$(I) = AWAY$ THEN A = I
140 NEXT I
150 REM Initialize weights
160 W(1) = 0.5
170 W(2) = 0.5
180 REM Set learning rate
190 L = 0.01
200 REM Training loop
210 FOR E = 1 TO 1000
220   FOR I = 1 TO N
230     X(1) = GAMES(I,1)
240     X(2) = GAMES(I,2)
250     TARGET = X(1) - X(2)
260     PRED = W(1) * X(1) + W(2) * X(2)
270     ERROR = TARGET - PRED
280     W(1) = W(1) + L * ERROR * X(1)
290     W(2) = W(2) + L * ERROR * X(2)
300   NEXT I
310 NEXT E
320 REM Prediction
330 X(1) = GAMES(H,1) + GAMES(A,1)
340 X(2) = GAMES(H,2) + GAMES(A,2)
350 PRED = W(1) * X(1) + W(2) * X(2)
360 PRINT "PREDICTED RESULT: "; PRED
370 END

Unfortunately I have no way of transfering this code from my Macintosh to the HP-71B other than typing it in (which is what I would have done 40 years ago but these days are over) to see how well it ppredicts.

Regards
Max

NB: Just out of curiosity, I asked one more question: „Could you squeeze in a second layer of the neural network if the RAM were exteded to 128kB?

Answer: With 128KB of RAM, it is more feasible to implement a small neural network with a second layer on the HP-71B. However, the HP-71B's processing power is still quite limited, so the network will have to remain very simple. We can add a hidden layer to the neural network with a few neurons.

The resulting program is quite long and would really be interesting to try out...
Find all posts by this user
Quote this message in a reply
06-22-2024, 06:47 PM
Post: #9
RE: General challenge for site members
There is an excellent (2 part) article on implementing neuronal networks on the HP48G(X) including program code by Peter Gatenby:

Neural Networks Part I: Feedforward Hardlimited Networks (V21N1P36)
Neural Networks Part II: Learning by Back-propagationm (V21N2P10)

The articles can be read here: https://www.hpcc.org/calculators/hp48.html

Good luck,
Juergen
Find all posts by this user
Quote this message in a reply
06-22-2024, 09:39 PM
Post: #10
RE: General challenge for site members
(06-22-2024 06:47 PM)JurgenRo Wrote:  There is an excellent (2 part) article on implementing neuronal networks on the HP48G(X) including program code by Peter Gatenby:

Neural Networks Part I: Feedforward Hardlimited Networks (V21N1P36)
Neural Networks Part II: Learning by Back-propagationm (V21N2P10)

The articles can be read here: https://www.hpcc.org/calculators/hp48.html

Good luck,
Juergen

Impressive use of the HP48GX. Nice article.

Namir
Find all posts by this user
Quote this message in a reply
06-23-2024, 06:02 PM
Post: #11
RE: General challenge for site members
I wrote a program for the HP50g (and an earlier but more limited) for the HP41c that would play rock-scissors-paper against a person. It would learn quickly and win around 70%+ after about a dozen games. I extended it to rock-scissors-paper-lizard-Spock but that performed the same.

I looked at the last choices the opponent made vs the history. For a 3-level history, this takes 27 memory slots. I had a system that rewarded the correct choice and penalized wrong choices. It was hard to beat. I did manage to score evenly against the program using a base 3 pseudo-random number generator with good statistics and a very long cycle (too long for my program to learn.) Running about 100 of my pseudo-random choices a second time would end up losing.
Find all posts by this user
Quote this message in a reply
06-23-2024, 10:47 PM
Post: #12
RE: General challenge for site members
I think the RPL calculators (with their support for lists) have a better chance to use more sophisticated data structures than can store data adequate for machine learning algorithms.

Namir
Find all posts by this user
Quote this message in a reply
06-24-2024, 06:58 AM (This post was last modified: 06-24-2024 07:02 AM by Mr_F.)
Post: #13
RE: General challenge for site members
There's a neural network program for the Prime, author Mark Power, at hpcalc.org
https://www.hpcalc.org/details/9101

Related link in this forum
https://www.hpmuseum.org/forum/thread-14227.html

- Geoff
Find all posts by this user
Quote this message in a reply
06-24-2024, 07:57 AM
Post: #14
RE: General challenge for site members
I wrote a tic-tac-toe program for a TI-58 in 1979. It'd beat you every time if it went first, unless you made the correct play to force a draw. And if you went first, it would always draw. But that's not even a micro-version of AI, it'was simply a programmed code to achieve a deterministic outcome.

A couple of years before, I had made a vehicle that would hunt around the floor looking for bright things. If it hit something, it would remember which side it hit, back up a little (unless it reversed into something else), and then steer around the object to carry on its journey, at which point it forgot what it had hit last time. So it had three memory neurons, to learn and remember if it had just hit something on the right, or on the left, or at the back. All discreet transistors, just because....

Back to calculators, and to qualify as a version of AI, we'd need to define what AI is? Is it a system that can learn through experience, and use that knoledge to produce steadily improved outcomes in some task, by whatever criteria is set for it? Statistical functions could be a basis for this, whereby a steadily accumulating set of data could lead to better and better predictions about future data. eg, a set of numbers between 2 and 12, which are actually generated by throwing two dice, but we dont know that. Experience of a string of such values will let it learn the likely probability of each outcome. And if betting with some odds were presented to it, it will learn when to play and when to hold.
Find all posts by this user
Quote this message in a reply
Post Reply 




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