The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Solving for the roots of a cubic polynomial
06-30-2024, 08:46 PM (This post was last modified: 07-01-2024 09:47 PM by Namir.)
Post: #1
Solving for the roots of a cubic polynomial
This is a Free42 printout of an HP-41C program that uses the instructions found on page 75 of the HP-4 Application Book. The program calculates the real and complex roots of a cubic polynomial:

x^3 + a*x^2 + b^x + c = 0

The program prompts you for the coefficients, b, a, and c in that order. The HP-41C adaptation uses labels and flags 00 and 01 to direct the flow of the calculations. The output includes the determinant d and the roots x1, x2, and x3. When the roots are complex the output appears as <real,imaginary>.

The listing (revised from HP-42s to HP-41C) is:

Code:
01 LBL "CUBE"
02 LBL A
03 CF 00
04 CF 01
05 "b?"
06 PROMPT
07 STO 07
08 "a?"
09 PROMPT
10 STO 08
11 ENTER
12 *
13 3
14 /
15 -
16 STO 01
17 RCL 08
18 3
19 /
20 ENTER
21 ENTER
22 ENTER
23 *
24 *
25 2
26 *
27 X<>Y
28 RCL 07
29 *
30 -
31 "c?"
32 PROMPT
33 +
34 STO 02
35 ENTER
36 *
37 4
38 /
39 RCL 01
40 ENTER
41 ENTER
42 *
43 *
44 27
45 /
46 +
47 RND
48 STO 03
49 "d="
50 ARCL X
51 PROMPT
52 LBL 11
53 DEG
54 X=0?
55 SF 00
56 X<0?
57 GTO 31
58 SQRT
59 STO 03
60 RCL 02
61 CHS
62 2
63 /
64 STO 02
65 +
66 X>0?
67 GTO 16
68 X=0?
69 GTO 18
70 CHS
71 LBL 16
72 3
73 1/X
74 Y↑X
75 X>0?
76 GTO 18
77 CHS
78 LBL 18
79 STO 04
80 RCL 02
81 RCL 03
82 -
83 X>0?
84 SF 01
85 X>0?
86 GTO 21
87 X=0?
88 GTO 23
89 CHS
90 LBL 21
91 3
92 1/X
93 Y↑X
94 FS?C 01
95 GTO 23
96 CHS
97 LBL 23
98 STO 05
99 RCL 04
100 +
101 STO 04
102 RCL 08
103 3
104 /
105 STO 08
106 -
107 "X1="
108 ARCL X
109 PROMPT
110 RCL 04
111 2
112 /
113 CHS
114 STO 06
115 RCL 08
116 -
117 STO 11
118 FS?C 00
119 GTO 00
120 RCL 04
121 RCL 05
122 2
123 *
124 -
125 2
126 /
127 3
128 SQRT
129 *
130 STO 05
131 STO 12
132 CLA
133 ARCL 11
134 ├","
135 ARCL 12
136 PROMPT
137 CLA
138 RCL 12
139 CHS
140 ARCL 11
141 ├","
142 ARCL X
143 PROMPT
144 RTN
145 LBL 31
146 RCL 02
147 RCL 01
148 ENTER
149 ENTER
150 *
151 *
152 CHS
153 27
154 /
155 SQRT
156 2
157 *
158 /
159 CHS
160 ACOS
161 3
162 /
163 STO 02
164 COS
165 RCL 01
166 3
167 /
168 X↑2
169 SQRT
170 SQRT
171 2
172 *
173 STO 01
174 *
175 RCL 08
176 3
177 /
178 STO 08
179 -
180 "X1="
181 ARCL X
182 PROMPT
183 RCL 02
184 120
185 +
186 COS
187 RCL 01
188 *
189 RCL 08
190 -
191 "X2="
192 ARCL X
193 PROMPT
194 RCL 02
195 240
196 +
197 COS
198 RCL 01
199 *
200 RCL 08
201 -
202 "X3="
203 ARCL X
204 PROMPT
205 RTN
206 LBL 00
207 "X2="
208 ARCL 11
209 PROMPT
210 "X3="
211 ARCL 11
212 PROMPT
213 RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Solving for the roots of a cubic polynomial - Namir - 06-30-2024 08:46 PM



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