The Museum of HP Calculators

HP Forum Archive 20

 Complex Cubic Equation - 41Z VersionMessage #1 Posted by 聲gel Martin on 18 Oct 2011, 4:00 p.m. Here's a corolary of this thread on solving the cubic equation using the trigonometric method.- 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.

 Re: Complex Cubic Equation - 41Z VersionMessage #2 Posted by 聲gel Martin on 19 Oct 2011, 2:29 a.m.,in response to message #1 by 聲gel Martin 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? ;-)

 Re: Complex Cubic Equation - 41Z VersionMessage #3 Posted by Thomas Klemm on 19 Oct 2011, 3:42 p.m.,in response to message #2 by 聲gel Martin This was pointed out once by Valentin Albillo. Nice extension of my program by the way. Cheers Thomas

 Re: Complex Cubic Equation - 41Z VersionMessage #4 Posted by 聲gel Martin on 19 Oct 2011, 4:23 p.m.,in response to message #3 by Thomas Klemm 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.

Go back to the main exhibit hall