## Posts

Showing posts from December, 2018

### Alpha stack on the HP-41C and HP-42S

A while back, another member of the MoHPC forum mentioned a program he'd written for the HP-41C that allows the user to manage multiple alpha registers. I responded saying that I had written something similar many moons ago that behaved like a LIFO (last-in-first-out) stack rather than an indexed array of datasets and said that I'd look it up. I have no idea whatsoever what I did with my little utility so I decided to rewrite it, purely and simply. So here it is. NB: This program creates and manages a data file in Extended Memory called "ASTACK". If you already have a file of that name, it will be deleted! Note also that running these programs uses Flag 01 and trashes registers R07-R10. Finally, since this uses Extended Memory, you will need to run this on a 41CX or SwissMicros DM41, or on a 41C or 41CV with the "X-Function" module. The size of the data file created in Extended Memory depends on the depth of the alpha stack that you want to crea

### The "N Queens" problem

The "N Queens" problem is a puzzle where you take an NxN chequers or chess board (it's usually 8x8 but this works for the general case) on which you have to place N queens in such a way that none of them threaten or are threatened by any of the others. Reminder: in the game of chess, a queen can move as many squares as she likes horizontally, vertically or diagonally but cannot jump over any of the other pieces on the board like a knight. This means that any piece in her direct line of sight on the same line, in the same column or on a diagonal to her is fair game. With this in mind, it is clear that there is only one solution to the problem on a 1x1 board, i.e. a single square (you just plonk a queen on it and you're done), and that there is no way to organise two queens on a 2x2 board or three queens on a 3x3 board without them threatening each other. For a 4x4 or greater board, there is more than one solution. I thought I'd have a go at solving th

### Numerical solver - Newton-Raphson method

The program downloadable from this page is a numerical solver. It attempts to find the zeroes of a function $f(x)$, i.e. it attempts to find $x$ such that $f(x)=0$ There are several methods for this. One that requires little computing power is Newton's Method, or the Newton-Raphson method, a description of which can be found on Wikipedia . We have no way of knowing the exact value of $f'(x)$ on the HP-41CX used here because that machine has no symbolic math capabilities, so we calculate an approximation of $f'(x)$ by taking a small value $\epsilon$ and calculating: $f'(x) \approx \frac {f(x+\epsilon)-f(x)} \epsilon$ This then allows us to calculate the next value of $x$ to use and display so that we see the calculator homing in on the zero that we're looking for: $x_{n+1} = x_n - \frac {f(x_n)} {f'(x_n)}$ Once we find a value of $x$ such that $|f(x)| \lt \epsilon$, we stop and that value of $x$ is deemed to be a zero of $f(x)$. The s

### Numerical Integration - Simpson's Rule

Numerical integration is an operation that many older machines are not able to perform without add-on libraries (e.g. Math Pac for HP-41C) or without writing a program from scratch to do it. There are, of course, some exceptions to this; Hewlett Packard's HP-15C and HP-42S come straight to mind, as does the Casio fx-180P, for example, but these machines are actually the exception, not the rule. There are many methods used to calculate definite integrals, that is integrals between known boundaries yielding a numerical result. One method that is a good trade-off between precision and complexity of application is Simpson's Rule , which attempts to find a quadratic of the form $a\cdot x^2+b\cdot x+c$ that fits or is close to our function. Finding the integral of this polynomial is very easy: $\int_{x_1}^{x_2} \! (a\cdot x^2 + b\cdot x + c) \, \partial x = \frac a 3 (x_2^3-x_1^3) + \frac b 2 (x_2^2-x_1^2) + c\cdot (x_2 - x_1)$ Basically, Simpson's Rule states: \[

### Is it really a Hewlett Packard?

There are two scientific calculators recently produced that, I'm afraid, fall into the cheap, plasticky category. They are the HP300s+ and the HP10s+. The question is, are they really Hewlett Packard machines at all? They are not. They are in fact Casios that have been rebadged to look like HP machines. Want proof? Watch this video with the HP10s+ showing its real colours. If you press the MODE key four times you get to the menu where you can alter display settings. There is an undocumented function in this menu where, if you press '2', you get to the contrast setting. This is not mentioned in the manual and, indeed, it has no effect, but look at what you get on screen when you press '2'. One good thing about this little machine is that I didn't even have to put a battery in it. The solar panel above the screen provides enough power to run the calculator as long as there's enough light around.

### HP Prime benchmark

Err, right. The HP Prime is hardly a vintage calculator given that it was first released in 2015. Better still, HP released the so-called Prime "G2" in August 2018 with faster hardware, much more RAM to work with and double the storage space in flash memory. When that happened, there was no excuse, I had to get one. At the time of writing, the Prime G2 would appear to be available only in Europe. The Americas have been left by the wayside this time around. I bought mine from derekenwinkel.nl with whom I have no affiliation other than being a happy customer of theirs. As it became known that there was an updated version of the Prime, people in the Museum of HP Calculators Forum were interested in hard data showing the improvements in performance, so I went and wrote a benchmark. The benchmark in itself is probably of limited value in absolute terms but gives a good idea of the differences between different machines. A benchmark run can comprise up to th

### Egg timer in a 41CX

Now this is something unusual. Who would want to use a 30-year-old machine worth something as a mere egg timer, or use it at all in a kitchen, where it could easily get damaged? It just so happens that one of the machines in my collection is a SwissMicros DM41. It's built really solid and it's basically the same thing as a Hewlett Packard HP-41CX in a case the size of a credit card, so that means that it incorporates, among other things, a Time Module, which gives it a stopwatch, countdown timer and alarm capabilities. The DM41 is a great little piece of technology. However, the operative word here is "little". While its LCD is the same size as it's Voyager-sized big brother, the DM41L, its keys are just a bit too small for the device to be fully practical, but for some things its form factor makes it just right. Okay, it's more than an egg timer. This said, my DM41 gets used most of the time in the kitchen as a timer while I'm cooking. I keep i

### Times are a-changing

The first post on this blog goes back to September 2009 and we are now about to go into 2019. So many things have changed since then. The original idea behind this blog was to publish periodical tips and tricks mainly related to GNU/Linux and other POSIX operating systems on one hand, and Symbian mobile phones on the other. Guess what... I no longer use GNU/Linux as my main operating system because I'm no longer self-employed and the work that I now do means that using MS-Windows is my only real option. I still use Linux on a handful of Amazon Web Services EC2 machines and on virtual machines at home and at work, but my main workstations are Windows 10 machines. So, what about mobile phones and Symbian? We all know what happened to that. Nokia discontinued Symbian and switched to Microsoft's Windows Mobile platform, and sold the mobile division to Microsoft, who promptly killed it off. A Chinese manufacturer took out a license to build and sell mobile phones under the Nokia