Complex Cubic Equation - 41Z Version



#2

Here's a corolary of this thread on solving the cubic equation using the trigonometric method.-

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv020.cgi?read=180771#180771

It picked my curiosity and wanted to try it on the 41Z. The following programs are the result, amazingly short (around 65 z-steps) and showcasing the versatility of the machine.

Input: four complex coefs in Z-stack four levels

Output: three roots in Z-Stack levels

Two versions, hyperbolic vs. circular functions.

Enjoy,
'AM

1	LBL "ZCRT" 			LBL "ZCRT" 	
2 ZRUP a3 ZRUP a3
3 Z/ a0/a3 Z/ a0/a3
4 ZSTO (00) a0' ZSTO (00) a0'
5 Z<>W a1 Z<>W a1
6 LASTZ a3 LASTZ a3
7 Z/ a1/a3 Z/ a1/a3
8 ZSTO 01 a1' ZSTO 01 a1'
9 ZRUP a'2 ZRUP a'2
10 LASTZ a3 LASTZ a3
11 Z/ a2/a3 Z/ a2/a3
16 3 3
17 ST/ Z ST/ Z
18 / /
19 ZSTO 02 a2' / 3 ZSTO 02 a2' / 3
12 Z^2 a2^2 / 9 Z^2 a2^2 / 9
13 3 3
14 ST* Z ST* Z
15 * a2^2/3 * a2^2/3
20 Z- a1-a2^2/3 Z- a1-a2^2/3
21 ZRCL 02 a2/3 ZRCL 02 a2 /3
22 Z^3 a2^3/27 Z^3 a2^3/27
23 ZDBL 2a2^3/27 ZDBL 2 a2^3/27
24 ZRCL 01 a1 ZRCL 01 a1
25 ZRCL 02 a2/3 ZRCL 02 a2/3
26 Z* a1*a2/3 Z* a1*a2/3
27 Z- (a2^3/27)-(a1*a2/3) Z- (a2^3/27)- (a1*a2/3)
28 ZRCL (00) a0 ZRCL (00) a0
29 Z+ q=a0+(a2^3/27)-(a1*a2/ Z+ q = a0+(a2^3/27)- (a1*a2/3)
30 ZHALF q/2 ZHALF q/2
31 Z<>W p Z<>W p
32 3 -3
33 ST/ Z ST/ Z
34 / p/3 / -p/3
35 Z/ 3q/2p Z/ -3q/2p
36 LASTZ p/3 LASTZ -p/3
37 ZSQRT sqr(p/3) ZSQRT sqr(-p/3)
38 ZSTO (00) ZSTO (00)
39 Z/ 3q/2p/sqr(p/3) Z/ -3q/2p / sqr(-p/3)
40 ZHASIN ZASIN
41 3 3
42 ST/ Z ST/ Z
43 / 1/3 ash[ ] /
44 ZRPL^ ZRPL^
45 ,002 ,002
46 STO 02 STO 02
47 RDN RDN
48 LBL 02 LBL 02
49 RCL 02 RCL 02
50 INT INT
51 120 2kp/3 120 2kp/3
52 D-R D-R
53 * *
54 ST+ Z add to imaginary part + add to real part
55 RDN tidy up stack ZSIN
56 ZHSIN ZRCL (00)
57 ZRCL (00) Z*
58 Z* ZDBL
59 ZDBL ZRCL 02 a2/3
60 ZNEG Z-
61 ZRCL 02 a2/3 ZAVIEW
62 Z- ZRUP save in Z-stack
63 ZAVIEW ISG 02
64 ZRUP save in Z-stack GTO 02
65 ISG 02 END
66 GTO 02
67 END

Edited: 18 Oct 2011, 4:39 p.m.


#3

In writing a version for the 42S it occurred to me that there's no way to input four complex numbers in the stack without using a data register - how can this be possible on the pinnacle of RPN development? ;-)


#4

This was pointed out once by Valentin Albillo.

Nice extension of my program by the way.

Cheers

Thomas


#5

Yes Thomas, thanks for the pointers to the method. Indeed I used your program as the "core", with a preamble section to prepare the depressed equation, and a provision to obtain the three roots.

You'll no doubt see the parallel between the "standard" functions and those in the 41Z, which does have a proper 4-level complex stack.

Cheers,
'AM

Edited: 19 Oct 2011, 4:24 p.m.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Last call for 41Z/SandMath Overlays... plus new ones Ángel Martin 0 178 12-12-2013, 10:27 AM
Last Post: Ángel Martin
  HP Prime: complex numbers in CAS. Alberto Candel 1 185 12-06-2013, 02:36 PM
Last Post: parisse
  [HP Prime] Plots containing complex numbers bug? Chris Pem10 7 387 12-05-2013, 07:40 AM
Last Post: cyrille de Brébisson
  Complex Number Entry on Prime Jeff O. 19 770 11-16-2013, 12:34 PM
Last Post: Jeff O.
  Equation Library/App for the Prime Harold A Climer 3 221 10-30-2013, 10:14 AM
Last Post: CompSystems
  Sandmath/41Z overlays Bernd Grubert 1 183 10-29-2013, 03:32 PM
Last Post: 'Angel Martin
  Equation Library on the PRIME Harold A Climer 0 126 10-26-2013, 10:01 AM
Last Post: Harold A Climer
  Meltiple Equation Solver PRIME Vs. HP 50G Harold A Climer 5 280 10-07-2013, 05:11 PM
Last Post: CR Haeger
  HP Prime complex results Javier Goizueta 0 125 10-06-2013, 12:59 PM
Last Post: Javier Goizueta
  HP Prime Solving Nonlinear System of Equations for Complex Results Helge Gabert 11 557 09-30-2013, 03:44 AM
Last Post: From Hong Kong

Forum Jump: