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:<P> 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<P> Labels:<P> LBL SM start of program LBL 01 main loop LBL 02 compute f(x1) LBL 03 compute f(x2) LBL 04 success!<P> The program:<P> 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

