Polynomial Coefficient Finder

Posted by Jonathan on June 19, 2005

This problem comes from the brain of Valentin Albillo on the HP Calculator Museum.

Given a polynomial Ax^3 + Bx^2 + Cx + D = 0 find the coefficients A B C D that give a root at x = pi.

A is in the range 1 to 9
B, C, D are in the range -9 to 9
Use a range [3.1, 3.2] for x

Here’s a program for the HP-41cx (Run-time is about 80 minutes) :


Registers:


01 A hardcoded to start at 1
02 B -M to M
03 C ditto
04 D ditto
05 x1 3.1
06 x2 3.2
07 f(x1)
08 f(x2)
09 M 9


Labels:


LBL SM start of program
LBL 01 main loop
LBL 02 compute f(x1)
LBL 03 compute f(x2)
LBL 04 success!


The program:


01 LBL SM set up variables
02 1
03 STO 01
04 RCL 09
05 CHS
06 STO 02
07 STO 03
08 STO 04
09 3.1
10 STO 05
11 3.2
12 STO 06
13 LBL 01 main loop
14 XEQ 02 calc f(x1)
15 XEQ 03 calc f(x2)
16 RCL 07
17 RCL 08
18 / divide them and look for -ve
19 0
20 X<>Y
21 X<=Y? -ve?
22 GTO 04 success !! x1 and x2 straddle the root
23 RCL 04
24 1
25 +
26 STO 04 D=D+1
27 RCL 09
28 X<>Y
29 X<=Y? <=M ?
30 GTO 01 loop
31 X<>Y
32 CHS
33 STO 04 else D=-M
34 1
35 RCL 03
36 +
37 STO 03 C=C+1
38 RCL 09
39 X<>Y
40 X<=Y? C<=M?
41 GTO 01 loop
42 X<>Y
43 CHS
44 STO 03 else C=-M
45 1
46 RCL 02
47 +
48 STO 02 B=B+1
49 RCL 09
50 X<>Y
51 X<=Y? B<=M?
52 GTO 01 loop
53 X<>Y
54 CHS
55 STO 02 B=-M
56 1
57 RCL 01
58 +
59 STO 01 A=A+1
60 GTO 01 loop — should be a check here
61 "FAILED"

62 AVIEW
63 LBL 04 we come here if we find a root in [x1,x2]
64 "FOUND IT"
65 AVIEW
66 RTN
67 END
68 LBL 02 Calculate f(x1)
69 RCL 05
70 3
71 Y^X
72 RCL 01
73 *
74 RCL 05
75 X^2
76 RCL 02
77 *
78 +
79 RCL 05
80 RCL 03
81 *
82 +
83 RCL 04
84 +
85 STO 07
86 RTN
87 LBL 03 Calculate f(x2)
88 RCL 06
89 3
90 Y^X
91 RCL 06
92 X^2
93 RCL 02
94 *
95 +
96 RCL 06
97 RCL 03
98 *
99 +
100 RCL 04
101 +
102 STO 08
103 RTN
104 END

Take a Stand Against Software Piracy

Posted by Jonathan on June 14, 2005

This blog linked to from slashdot talks a great deal of sense about the crazy numbers coming from the Microsoft and other big company shills who disparage software piracy.

Keep reading, I’m not going to condone software piracy. I completely believe that companies that write software deserve to be paid for that software if it is their choice to license its use commercially. I work for a consulting company. My job is to design and implement software to perform tasks as specified by clients of our company. I’d be a complete hypocrite if I believed that people shouldn’t earn a living from software.

Did you read the link ? You should.

Welcome back!

Here’s why the shills who declaim software piracy are wrong:

– People who have money to buy software will invest their money in software if it is worth it. For example, Microsoft Office costs hundreds of dollars.

– People who don’t have money, or who just want to test a piece of software may download a cracked copy in order to test it. Or they may ‘borrow’ a copy from work. They may believe the software is not worth using, or may just not be able to afford it. For example, Microsoft Office costs hundreds of dollars. (!)

As well as being factually wrong, they are also killing the very hand that feeds. Every time Microsoft adds product activation, or treats users as criminals by default, a few less users will feel inclined to buy their software.

Now, about me. The main reason I don’t have Microsoft Office on my computer is that I don’t want to blow that kind of money on a software package, and I am sick of being treated like a criminal by Microsoft. For example, copies of Office at Schlumberger don’t have to be activated. Wow! No key. No scrabbling for a license. Schlumberger have the muscle to say “We don’t like your BS, give us software that we can install easily.” On the other hand, if I buy a copy of Office, I have to type a long, easily lost or mistaken key code to allow me to use the software. If I install the software on a machine that subsequently dies, then I have to phone Microsoft and grovel to some nameless minion in order that they allow me to reinstall the software on my new machine, hard drive etc.

But, the most positive reason for not buying Office, is that it forces me to install Open Office. Open Office is an Office compatible suite that grew out of Sun Office. This used to be a slow, bug-ridden app, rather like a software version of a 1920′s automobile. It worked, kinda.

However, Open Office really did grow. The 1.1.3 versions are pretty good, but much much much better is the new Office beta. For the first time, Word and PowerPoint documents can be loaded and edited using a non-Microsoft package that in some cases has better compatibility with older versions than Microsoft Office itself.

Using a pirated version of Microsoft Office *is* wrong. As well as being illegal, it promotes the Microsoft monopoly. Microsoft write some fantastic software, but sometimes their tactics leave a bad taste in the mouth.

A word processor is an appliance. Try a different brand for a while. It’ll be refreshing. Go to Open Office and download it today.

My New HP41cx 2

Posted by Jonathan on June 14, 2005

This is the start of an occasional series of postings on cool stuff (I’ve bought) from Ebay …

HP41cx – The Citroen DS (DS is a French pun for Godess ;-) ) of Calculators

I think as long as I’ve been a gadget geek, I’ve wanted an HP41 of some description. My first experience of any calculator at all was in about 1975 or so when my father brought home some kind of TI calculator. Sadly it wasn’t working reliably, and I wasn’t smart enough to work out what was wrong.

The HP41 series of calculators was the keystone of a complete computer system, including the HPIL serial interface bus (similar to USB), various printers, backing store and other equipment. Every 41 has four module slots which allow additional memory and pre-programmed ‘pacs’ to be plugged in. Most surveyors are probably using HP48gx’s or laptops by now, but back in the day, the HP41 was a great tool for people who needed a tough, preprogrammed calculating asistant.

Here’s a pic of a HP41cv (This pic lives at the wonderful Museum of HP Calculators) :

My HP-41Ccx is physically the same, but has some additional features inside, including a timer and alarm facilities.

The display on the calculator was Hewlett-Packard’s first foray into using liquid crystal, and they did a great design job. The display is very very clear with good contrast and a very distinctive font.

The keyboard is fairly soft to the touch with a nice soft over-center action. There is no audible click, mechanical or otherwise, but there’s no doubt that a key was pressed.

Unlike other calculators of the time, a button is used to toggle the calculator on and off. This is great since the switches on many calculators from this era have most likely failed or getting ready to.

Aside from the on/off toggle, the other buttons on the top row provide the ‘user’ mode, ‘prgm’ mode and ‘alpha’ mode. These allow a customised keyboard, program editing and alphanumeric input respectively.

It is a little smaller in the hand than it appears in pictures. The main thing though, is the sheer quality and appeal of this great design.

This is really hard to believe, but this calculator was designed back in the late 1970′s. As a further testament, production only ended in 1990. It really does seem that great pieces of design never, ever go out of fashion.

I’ll post some more when I’ve worked out how to do some programming.

Date adopted: 06/14/2005
Condition: Mint, with HP zipper case, original manuals, keyboard overlays, stickers and HP promo materials.