Here you'll find all 32 PDF articles I wrote in the past about HP calculators and mathematical algorithms of all kinds implemented as full programs and routines for them. These articles were first published in paper form more than 11 years ago and some of them were later published by me in my long defunct HP Web page. At long last, the full 32-strong collection is now made available for the first time in its entirety as PDF files.
As of today, my articles feature such RPN calculators as all the Voyager Series models, HP-25, HP-34C, HP-35, HP35S, HP-41C, HP-42S as well as non-RPN ones such as the BASIC-programmable HP-71B, plus assorted modules such as the HP41C Advantage ROM and the HP-71B Math ROM, and purely math-based ones (though they'll still include relevant code for one or more models).
This Category will also feature all still unpublished articles I've written in the last 11 years, which will be released here for the very first time (they won't be submitted to any magazine for publication), plus all new articles I may write now and in the near future. Stay tuned !
5-page article celebrating the modest but capable HP-11C, includes an 84-step program which will very quickly and accurately find the limit sum of any user-defined infinite alternating series (say S = 1/0.23-1/0.24+1/0.25-1/0.26+... = 2.221127525), no matter how slowly it does converge (if at all !). If the series does not actually converge (say S = 1-2+3-4+5-6+...) then the program computes its so-called Eulerian Sum (0.25 in this particular case).
Full documentation and three comprehensive, commented examples.
6-page article celebrating the best-selling HP-12C, includes a 72-step program which will allow your HP-12C to play a challenging game of "Bridge-It!" against a human opponent in boards of any size up to 99x99. Try it on your unsuspecting financially-minded friends and see how they fare against the HP-12C !
Full instructions and detailed sample game, with figures.
11-page article, featuring an original HP-related short Sci-Fi story, specifically written by me as part of Sir Isaac Newton’s Anniversary of Birth’s commemorations. It gathered a lot of interest among HP fans at the time of its release and quite a number of comments and even some pretty interesting questions, see "Article VA032 - Time Voyager Revisited.pdf" below.
10-page article, includes a crafty 99-step program for the original HP-12 financial calculator which evaluates all six standard trigonometric functions (Sin, Cos, Tan and their respective inverses) very quickly and with full accuracy over an extended range of arguments.
The design goals were the following: (1) All six trigonometric functions in a single program, (2) Full accuracy for all functions, (3) Maximum speed and fast computation times for all functions and all inputs, (4) Convenience and ease of use, and (5) Compatibility with other RPN models. All of them were successfully met despite the many shortcomings the HP-12C has for general programming, which are detailed in the article.
Fully documented, including extensive implementation details, timings and accuracy, as well as two worked examples including using the implemented trigonometric functions to find all 5 real roots of a particular 5th-degree equation, and checking a trigonometric identity.
8-page article for the HP-12C financial calculator, includes a 37-step program which makes use of the built-in microcode IRR solver and a number of assorted financial functions to find one or more real roots of polynomials up to the 14th-degree (and up to 1480th-degree or more if there are groups of repeated coefficients). The program allows for quickly entering groups of repeated coefficients and correcting wrong inputs on the fly, and can also evaluate the polynomial for any given arguments.
Both root finding and polynomial evaluation are implemented using built-in financial functions without user-code loops or branching, so it's the fastest and more convenient polynomial root solver for the whole Voyager Series calculators, surpassing even the HP-15C's SOLVE function in this regard. Frankly, one of my very best programs for any calculator and among the ones I'm proud of the most.
The program is fully commented on a step-by-step basis and 5 sample worked cases are included, among them finding real roots of polynomial equations of degrees 3, 7 and 137, and all 5 real roots of a 5th-degree equation.
6-page article celebrating the peerless HP-15C, which apart from discussing in detail its many outstanding features such as the keyboard layout, the superb numerical algorithms, the astonishingly comprehensive instruction set and the advanced programming features and large RAM for its time, also features a sample 64-step program which will compute and store up to 208 decimal digits of Euler's constant e (=2.71828+), using mainly the built-in matrix operations.
The program is extensively documented and full results and timings are included as well.
7-page article, includes a 42-step program for the HP-15C which will compute explicitly the coefficients of the polynomial of degree N (2<=N<=6) which exactly fits (passes through) a given set of data points (x,y). The program prompts for the data points, then computes and outputs the coefficients of the polynomial fit, using the HP-15C's powerful built-in matrix operations for maximum speed and accuracy.
The program and algorithm are fully documented, with detailed usage instructions, plus there are three fully worked examples including data fitting and predictions, constructing a polynomial knowing its roots and performing inverse interpolation.
9-page article celebrating the awesome Advantage ROM for the HP41C series, which includes a 62-step, user-friendly, fully-prompting, fully-commented (step-by-step) implementation for the HP-41C/Advantage ROM of the HP-15C program featured in the article "HP-15C Nth-degree Polynomial Fitting" but extended to handle degrees much higher than 6, in fact limited only by available RAM. Also, if you have Extended Memory installed the program will take advantage (pun intended !) of it and use no main registers at all so it will run even at SIZE 000 regardless of the polynomial's degree.
The article also includes a thorough discussion of the differences between both approaches and no less than than four fully-developed application examples, including fitting, interpolation, inverse interpolation, finding a polynomial given its roots, and exposing polynomials disguised as trigonometrics :-)
12-page article for the HP-71B featuring a 160+ line program that recursively solves arbitrary "Mate-in-N" chess problems like the ones you typically find in magazines. The program can search for a mate in a specific number of moves or in any number of moves up to a given maximum, can search all legal moves or only moves by the mating side which check the opponent's king, will consider pawn promotions and underpromotions, understands stalemates, and can store the given position in a file and read the file afterwards for further use.
Fully commented on a section-by-section basis with many algorithmic details explained, plus two complete, amazing sample chess positions solved by the program: a middle-game typical Mate-in-2 problem and a famous Mate-in-3 endgame problem whose unique solution is an amazing pawn underpromotion to a Knight no less !
14-page article celebrating the HP42S, includes a comprehensive 423-line professional-looking program to solve the classic "8 Queens Puzzle", written specifically for the occasion in order to demonstrate many interesting 42S programming techniques and methodology, from user menus and matrices to error handling and fast graphics, ergonomy, how to use complex numbers for efficient multi-indexing, growing and shrinking matrices, indexing two matrices at a time, and many other advanced techniques, all considered from a didactic viewpoint.
Full explanation of the programming details and techniques, including the algorithm to detect and optionally filter out derived solutions (symmetries, rotations), is provided, as well as a complete run including all 92 solutions found and the filtered subset of just the 12 primary ones. As a bonus, the original barebones 9-line BASIC program for the SHARP PC-1211 which was used as the basis for this one is included as well.
10-page article, first part of a two-part article featuring in all 13 assorted mini-topics discussing novel, unusual, or otherwise interesting and little-known aspects of using the extremely powerful and versatile Math plug-in ROM for the HP-71B.
The 7 mini-topics discussed in this first Part deal with choice Math ROM capabilities, such as implementing missing matrix operations efficiently using norms and other simple techniques, implementing the missing complex-case for some standard math functions, implementing special transcendental functions such as Mittag-Leffler and Lambert W, quirks of the built-in solver, tips & tricks using complex operations to optimize real results, techniques to generalize subprograms to also seamlessly accept and work with complex data, etc.
Full documentation is provided, including plenty of code snippets, short programs and sample results to demonstrate the points discussed in detail.
8-page article, second part of the Baker's Dozen compendium of assorted mini-topics discussing interesting uses of the HP-71B's powerful Math ROM. The 6 remaining mini-topics discussed in this second Part deal with advanced applications such as polynomial data fitting for real or complex datasets, multidimensional integration, solving systems of non-linear equations, finding all eigenvalues of arbitrary matrices, and matrix operation benchmarks. The purpose is to show just how easily these usually complicated tasks can be dealt with thanks to the incredibily powerful Math ROM features.
Fully documented and, like the first Part, it includes many code snippets, short programs discussing the points presented and even templates for you to use when doing your own multidimensional integration or solving non-linear systems.
10-page article which includes a Sudoku-solver short program (just 35 lines) which can automatically solve any solvable Sudoku puzzle without requiring human intervention, using recursion to any depth if needed, and optionally printing status information as the search progresses as well as the solution once found. It will also recognize when a puzzle has been incorrectly entered and/or there is no solution.
Both the outer Shell (12 lines) and the inner Search subprogram (22 lines), which employs advanced techniques such as the use of bitboards, boolean operations and recursivity, are extensively discussed and commented section by section, including 5 selected Sudoku puzzles ranging from 30 occupied cells to as low as just 19, which are fully soved and commented as well.
8-page article, which discusses an amazing and, to most people, unexpected application of the rarely used Math ROM's FOUR keyword, namely how you can use Fast Fourier Transforms (FFT), and then an inverse transform (which are what FOUR does) to multiply two very high-precision numbers faster than with most any other algorithms currently known.
Includes a very short subprogram (10-line, can be formatted to just 8 lines) which will accept two multiprecision numbers up to 1024 digits long and will ouput their product (up to 2048 digits long), implementing the desired functionality by using FOUR at THREE different places no less! :-). Running time is nearly linear in the size of the inputs compared to quadratic times for the usual "school" algorithm. For instance, multiplying two 512-digit numbers using FFT is already 4 times faster on the HP-71B than doing it with the usual method. Full documentation and examples included.
9 pages, a sequel to my original 35-line "HP-71B Short & Sweet Sudoku Solver", which includes additional techniques to detect even more forced digits earlier and so avoid the need for recursion altogether or else having it deal with fewer empty cells, thus speeding the solving process enormously (up to 100 times faster in the most difficult puzzles) at the expense of just 10 additional lines of code.
Together both articles form a combined 19-page article which discusses important techniques for this kind of solvers (e.g., bitboards and boolean operations, updating the bitboards more efficiently, using the Conjugate Criterium to fill-in additional forced digits, etc.), plus it includes an additional very carefully crafted, comprehensive 15-puzzle Test Suite, fully commented, with solutions and timings, which, besides showing this solver's performance in action, can also be useful to you in order to test other solvers or even you own Sudoku abilities
11-page article, which introduces some new specially designed small matrices I created myself ("Albillo Matrices", AM for short :-) ), which are extremely troublesome to handle for the purposes of system solving, matrix inversion or determinant computation. Unlike the well-known symmetrical Hilbert matrices, whose elements can't be represented exactly in finite floating-point calculators, my matrices include only small, exactly representable 2-digit positive integer values, are balanced (all elements are about the same order of magnitude) and non-symmetrical, yet even for small dimensions (7x7, say) they're nearly intractable by anything short of exact, arbitrary-precision arithmetic.
Four such 7x7 AM matrices are presented (#1, #2, #3 and #7) and full results are given using AM #1 as a test case with useful extensive comments (sections "What can be done ?", "Can it get any worse ?", "Righting the wrongs" and "Conclusions and recommendations") and exact Mathematica-produced results are also included for comparison purposes.
Note: These AM matrices proved to be very popular with knowledgeable people posting at the "Museum of HP calculators" forum and many threads were created (some very long) with tons of additional results for most advanced HP calculators having built-in matrix capabilities or even for program suites implementing matrix operations. Ultimately this resulted in a great number of very thorough, comprehensive comments and lots of worthwhile and enlightening discussions. Also, I introduced several additional AM matrices and variants thereof, to test even further the achievable accuracy.
12-page article including two programs. For starters I give a 3-liner to compute the Least-Squares Nth-degree Polynomial which best fits a given set of (x,y) datapoints in the least-square sense, while for the main course there's a 50-line fully-commented program to compute the Minimax Nth-degree polynomial fit to a given set of datapoints (x,y), where the data can be entered either from the keyboard, automatically generated by evaluating a user-provided function, or read/stored from/to a data file. Additionally, five amazing, comprehensive worked examples are thoroughly discussed.
By definition, the Minimax polynomial is the approximating polynomial which has the smallest maximum deviation from the true function in absolute value. Thus, we’re minimizing ABS(P(x)-f(x)) instead of (P(x)-f(x))^2 as Least-Squares does. The user can specify the degree of the polynomial or else specify instead a maximum absolute error and let the program automatically select the lowest degree which will achieve it. Once the coefficients have been computed the user can evaluate the resulting polynomial at any given arguments right from the keyboard (even as part of more complicated expressions), and can also check the quality of the fit by automatically scanning any given interval for maximum errors in it, at whatever step size desired.
Minimax polynomial fitting is an incredibly powerful technique to add to one’s own data-fitting arsenal. Though the internal details are complex enough and it does require a lot of computing muscle when compared to other well-known strategies such as Least Squares, the final reward is the improved accuracy it provides for any given degree or, conversely, the lowest possible degree for any given accuracy. It may take longer to compute, but typically you do that just once, then evaluate the resulting polynomial many times, which, being of lower degree than the ones obtained by any other methods, will then evaluate faster, thus saving time in the long run.
5-page article, which commemorates that wonderful "Programmer's model", the unique Voyager-series HP-16C. It includes an interesting 91-step program that highlights some exclusive functionalities of this model (such as variable word size) applied to solve the "Towers of Hanoi" puzzle for N discs (the original puzzle has N=64) by mimicking recursion to very deep levels. Matter of fact, using a word size of 8 bits allocates as much as 111 registers available for the emulated recursion stack.
Additionally and by way of comparison and to further explain the algorithm used, HP-71B recursive (2-line) and non-recursive (6-line) versions are provided as well.
8-page article to commemorate the 25th Anniversary of my HP-41C "Othello"-playing program. For those of you who feel nostalgic about the golden past of classic HP calculators, this article reminisces on those wonderful times back when the HP-41C was brand-new and everything seemed possible and everyone was in awe at it.
The article tells the whole story about how my HP-41C "Othello" program came to be, with its downs and its ups (like being featured at the time in an issue of the "Wall Street Journal" magazine), and including previously unpublished letters sent from HP Corvallis to me ("The program has generated a lot of interest in our division"), asking me to submit it to the HP-41C User's Library and awarding me a special "Certificate for Outstanding Contributions" in return.
Also included is a recreation of the original HP-41C "Othello" for the HP-71B, which is a 43-line program with full instructions and sample run so that you can test your wits playing this challenging 8x8 board game against it, to try and feel what HP-41C users felt at the time when seeing it for the first time 25 years ago.
7-page article to commemorate the jaw-dropping original HP-25, my very first HP calculator ever and one of the most memorable classics ever made. The article includes some fond personal remembrances of those golden times, as well as a thorough explanation of why the HP-25 made such an impact back then, all of it conveniently laced with two truly awesome programs written in the 70's by two hyper-enthusiastic youngsters (one of my friends and myself) to numerically solve user-defined 1st-order differential equations using 3rd-order (36 steps, 3 function calls per step) and 4th-order (39 steps, 4 function calls per step) Runge-Kutta methods ... on a 49-step tiny RPN calculator with NO subroutine capability and no flags !!.
Single-stepping through the programs is a revealing experience, allowing you to fully appreciate what can be done in less than 40 steps and how everything fits together and works as if by magic, a real epiphany of sorts. Additionally, two very interesting non-trivial sample runs are included, with full step-by-step explanations and results.
14-page article which completes my Sudoku Trilogy, featuring a "Sudoku Generator & Coach" program which can generate an essentially infinite number of puzzles per the user's specifications, including number of empty cells, symmetries and optionally guaranteed uniqueness and solvability of the generated Sudoku puzzle without guessing ever being necessary. The resulting Sudoku puzzle is then output in a fully ergonomic, printable format so that you can generate a number of unique, solvable Sudoku puzzles and print them to later solve on the go.
The Coach part can give appropriate hints of various types, one at a time, guaranteed to be logically deductible by the user in the given order, either fully completing the puzzle or stopping midway, and can do that for both the self-generated puzzles and for arbitrary externally provided ones (say, taken from some magazine), which you can input for coaching.
12-page article which describes and compares the two greatest contemporary, ground-breaking machines of the early 80's: the RPN flagship HP-41C versus the very first pocket computer, the BASIC-programmable SHARP PC-1211.
The article includes six excellent side-to-side pictures comparing specific key design features of both models, as well as a thorough technical description of their differences (display, keyboard, usability in manual calculations, programming, mass storage, documentation) and two test-case programs, each of them written for both models to better see them in action while dealing with the very same programming task but each using their unique programming paradigms ("Hand to hand: a casual duel").
Finally, four additional short sample programs for the SHARP PC-1211 are included (all of them less than 9 lines long) yet successfully dealing with fairly non-trivial tasks with utmost ease.
9-page article dedicated to the groundbreaking HP-34C, a true landmark of vintage HP calculator design in many aspects, which introduced for the first time a number of state-of-the-art computing capabilities such as built-in solve and integrate functionalities, linear regression, gamma function, automatic memory allocation, etc., many of them never seen before in any HP handheld device, let alone at such a relatively cheap price and with full advanced programmability to boot.
The article includes fond personal remembrances related to this model, as well as a 66-step application program taking full advantage of some of its most advanced built-in capabilities to perform numerical two-dimensional integration of a user-defined f(x,y) between given limits. Four excellent, fully documented examples are included and last but not least, by changing just the one "DSE" instruction to "DSE I" this program will also run *as is* in the HP-15C !
12-page article celebrating the astounding HP-71B, which discusses its ultra-advanced capabilities in detail and further includes two wonderful pics as well as a brand-new program I've written specifically for the occasion, which in just 6 lines of code (!!) manages to generate and output user-defined ASCII-based stereograms, viewable from the printed page or monitor output (an Emu71-emulated HP-IL monitor, for instance) in full, glorious 3-D !
The underlying theory is explained in detail and the program is very extensively commented section by section (about 70 lines of explanation for the 6 lines of code !), as are the 3 awesome examples which generate just as many fully 3-D viewable ASCII stereograms, one of them being a 3-D HP logo :-). Finally, a section on "Seeing Stereograms" is included for the benefit of people not used to them.
5-page article, belonging to my "Long Live" series, which is intended as a commemorative article for the HP-35's 35th anniversary, and I think you'll agree it's quite an original approach to it.
It highlights all the groundbreaking capabilities of the HP-35 and their importance from a historical point of view, an further it includes three examples featuring four small "programs" (for a non-programmable calculator no less !), addressing such topics as root finding and numerical integration among others, as well as providing the appropriate historical context and a few personal anecdotes to spice it all. As you'll see, it's certainly a one-of-a-kind article.
6-page article, the first of my "Boldly Going" series which, as its name implies, is intended to effectively go "where no HP calc has gone before", dealing with unusually difficult programming tasks in a straightforward manner, thus expanding the limits of what you can do with your HP calc and how simply can you do it. For instance, can you use your HP calculator to find the matrix square root of these two neat little matrices
| 56 97 17 89 | | 4 + i 7 + i 3 - i 4 + 2i | A = | 33 -68 -42 5 |, A = | 6 - i 9 + 4i 8 – 3i 3 – 2i | | -206 -48 -34 -104 | | 1 + 3i 1 – 2i 4 + 2i 3 + i | | -39 92 27 30 | | 2 - i 1 + 4i -3 + 4i 1 + i |
that is, to find a real/complex matrix R so that R*R = A, in each case ?
This article discusses in detail just that, finding the matrix square root of square matrices. Two full programs are featured: a 7-line subprogram for the HP-71B which can deal with real- or complex-valued NxN matrices, and a 45-step program for the HP-15C which will find the square root of real-valued matrices up to 4x4. Four examples are provided, with full comments and notes, as well as the underlying algorithm.
1-page article belonging to my "Small Fry" series, which is intended to feature very small articles (maximum 1 page or two) while still keeping all the flavour and bite of the usual longer ones.
This article deals with the topic of prime counting, i.e., finding out how many prime numbers there are up to a given limit N. For large N, generating all primes up to N and returning the count is prohibitively expensive in terms of running time and/or memory usage, so: What can we do about it when N goes sky-high (say 10^10, 10^15, or more) ? The article features an 8-line user-defined function for the HP-71B to accomplish the feat very quickly with relative error as low as 0.000000004% for N as high as 40,000,000,000,000,000, as well as several comparative examples against other well-known prime counting procedures.
2-page article which includes a 4-line subprogram to very quickly convert a user-given real value to the simplest equivalent rational fraction within a user-specified maximum relative error. Fully documented, including a simple modification which allows you to see the underlying continued fraction representation of a given real value, and yet another equally simple modification which will output the successive ever-more-accurate fractions (convergents) as they’re being computed.
Additionally, examples are given to approximate Pi by a fraction, perform exact rational arithmetic and reduce fractions to lowest terms.
14-page article which includes the original version (v1.0) of my truly awesome (if simple) program which allows "ye goode olde" HP-71B to perform some rather impressive "symbolic" feats. The program does not require any additional ROMs or files, just a bare bones HP-71B, and can be converted to any other suitably fast HP model or emulator with minimum effort.
The program provides basic functionality for an advanced, very useful and most impressive feature which is nevertheless absent in all HP calculators' instruction sets, namely identifying numeric constants, i.e., the capability of, given some real numeric value, to try and identify its exact symbolic form if possible, and that failing, to provide an approximate symbolic expression of user-specified relative accuracy.
This allows us to perform some pretty nifty feats, such as attempting to give exact, symbolic results for definite integrals (even if they can’t be expressed in terms of elementary functions), finite or infinite summations, limits, specific values of transcendental functions and exact arithmetic with fractions, among other imaginative uses.
The full 14-page article includes more than 40 fully worked examples as well as three detailed extensions, the last being an "exercise' for the reader", solution included of course ! :-)
4-page article which discusses my brand-new 16-line (185-byte) implementation to pack three full-precision real numbers into a single variable, thus making it possible to store and recall in excess of 2300 floating-point values in HP35s’ indirect variables. It consists of three main, externally callable routines which implement the essential Initialization, Store, and Recall functionalities, all of them within the address space of a single label.
The implementation is such that you can convert any program using standard variables to use virtual variables instead by just calling the Initialization routine once, then changing each STO(I) and RCL(I) to the appropriate calls, which work exactly like the originals as far as stack behavior is concerned, LASTX included. Full examples given, including a 21-step tester program to check that the routines are working properly.
7-page article which includes a small 48-step program that will allow you to find a real or complex root of an arbitrary equation with real and/or complex coefficients starting from just one real or complex initial guess. The root will be displayed as labeled output and left both in the X stack register and direct register X. Roots will be returned as genuine real/complex values as appropriate, i.e., a computed real root will be a proper real value, not a complex value with a zero or very small imaginary component.
Further, a real initial guess may find a complex root and vice versa. The program implements an optimized version of an advanced, cubically-convergent numerical method that typically converges very quickly to a root with speed comparable to that of the built-in Solver (which can't generally find complex roots) or better, and which, unlike Newton’s method, will foray into the complex domain if need be, even when starting from a real initial guess.
Full documentation, with emphasis on programming techniques, as well as 5 comprehensive examples duly annotated.
3-page article having to do with my short Sci-Fi story "Time Voyager", featured in my "Article VA003 - Time Voyager.pdf" (which you can download using the link above in this page). The original story was well liked by a number or readers, and some people even took the trouble to let me know their enthusiastic opinion about my story, which was much appreciated of course, but certain readers went even further to ask some amusing questions about its fine details, even to the point of suggesting the possibility of trying to check whether it actually might hold some water by combing the original manuscripts and locations for telltale indicia ! LOL !
However, among all the questions there was one in particular which actually was a pretty good one which I never stopped to consider in the first place and I really felt at the time that the question was interesting enough for other people who did read the story to be able to consider it and get to know my (hopefully also interesting) answer, so I included it in the present article for the benefit of all interested readers.
Nevertheless, as the answer to the question entails spoiling the catchy end of the story, I strongly advise all of you intent on reading this "sequel" article who haven’t yet read the original story to please read it first (using the link above), then return to this article for the question & answer. The original story is a short 11 pages and it would make much more sense to read it first, trust me.
These articles, programs, pictures, their descriptions and other materials created by me are (c) Valentin Albillo, and can be used freely for non-profit purposes as long as (1) the contents aren't modified in any way and (2) the copyright is acknowledged.
In plain words, you can download them and use them for non-profit purposes but do not include them in any media and/or site for which you're asking money, do not tamper with their contents and do not say or imply that you created them or that you don't know who created them, you must always give due credit to the copyright holder (that's me).