Polynomials2

# Polynomials(III) for the HP-41

Overview

1°)  Cubic Equations
2°)  Quartic Equations
3°)  Palindromic Polynomials

a)  Degree = 4
b)  Degree = 5
c)  Degree = 6
d)  Degree = 7
e)  Degree = 8
f)  Degree = 9

4°)  Integer Roots

a)  Real Roots
b)  Complex Roots

5°)  A few Quintic Equations

a)  Program#1
b)  Program#2
c)  Program#3

6°)  A few Sextic Equations
7°)  A few Septic Equations

a)  Program#1
b)  Program#2

8°)  A few Octic Equations

-There are already 2 programs listed in "Polynomials for the HP41" to solve cubic & quartic equations
-The following ones are sometimes more accurate... and sometimes less accurate !

-If the polynomial is palindromic, we can find its roots easily, provided its degree is < 10.

-In paragraph 4°), the routines employ the brute force to find the roots if all the roots are integers ( Gaussian integrers with complex polynomials )

-It's impossible to solve all polynomial equations of degree > 4  with similar formulae
-But there are special cases where it's still possible.

1°)  Cubic Equations

-"P3"  solves  a.x3+b.x2+c.x+d = 0

Data Registers:  R00 .... R05:  temp
Flag:  F01             ( indicates complex roots )
Subroutines:  /

 01 LBL "P3"  02 CF 01  03 R^  04 ST/ T  05 ST/ Z  06 /  07 27  08 *  09 X<>Y  10 STO 02  11 9  12 *  13 R^  14 STO 01            15 X^2  16 ST+ X  17 -  18 RCL 01  19 *  20 -  21 STO 00  22 X^2 23 RCL 01  24 X^2  25 RCL 02  26 3  27 ST/ 01  28 *  29 -  30 STO 04            31 3  32 Y^X  33 4  34 *  35 XY  64 ST* T  65 ST* Z  66 * 67 RCL 01  68 ST- T  69 GTO 01  70 LBL 00  71 -  72 SQRT  73 RCL 00            74 ABS  75 +  76 2  77 /  78 3  79 1/X  80 Y^X  81 RCL 00  82 SIGN  83 *  84 CHS  85 STO 05  86 RCL 04  87 RCL 05  88 / 89 STO 03  90 -  91 12  92 SQRT  93 /  94 RCL 03            95 RCL 05  96 +  97 3  98 /  99 STO 03 100 2 101 / 102 CHS 103 RCL 03 104 RCL 01 105 SF 01 106 LBL 01 107 ST- Z 108 - 109 END

( 134 bytes / SIZE 006 )

 STACK INPUTS OUTPUTS T a # 0 / Z b z Y c y X d x

-If  CF 01  the 3 solutions are  x ; y ; z
-If  SF 01  the 3 solutions are  x ; y+i.z ; y-i.z

Example:      Solve  2.x3-5.x2-7.x+1 = 0  and   2.x3-5.x2+7.x+1 = 0

2   ENTER^
-5  ENTER^
-7  ENTER^
1   XEQ "P3"  >>>>   3.467727065   RDN   0.131206041   RDN   -1.098933110    which are the 3 real solutions since flag F01 is clear.

2  ENTER^
-5  ENTER^
7   ENTER^
1     R/S         >>>>   -0.130131633   RDN   1.315065816   RDN   -1.453569820

-Flag F01 is set , therefore the 3 solutions are  -0.130131633  ;  1.315065816 - 1.453569820.i  ;  1.315065816 + 1.453569820.i

Note:

-It's better to replace lines  78-79-80  by the M-Code routine  CBRT  ( cf "A few M-Code routines for the HP41" )

2°)  Quartic Equations

-"P4" solves the equation   x4+a.x3+b.x2+c.x+d = 0

Data Registers:  R00 thru R05: temp
Flags:   F01 F02
Subroutines:  /

 01 LBL "P4"  02 CF 01  03 STO 04  04 X<>Y  05 STO 03  06 R^  07 STO 01            08 *  09 X<>Y  10 4  11 *  12 -  13 STO 00  14 X<>Y  15 STO 02  16 4  17 *  18 RCL 01  19 X^2  20 -  21 RCL 04  22 *  23 RCL 03  24 X^2  25 -  26 27 27 *  28 RCL 02  29 X^2  30 ST+ X  31 RCL 00            32 9  33 *  34 -  35 RCL 02  36 *  37 -  38 STO 05  39 X^2  40 RCL 02  41 X^2  42 RCL 00  43 3  44 *  45 -  46 STO 00  47 3  48 Y^X  49 4  50 *  51 XY 109 SF 02 110 RTN 111 LBL 00 112 - 113 SQRT 114 RCL 05           115 ABS 116 + 117 2 118 / 119 3 120 1/X 121 Y^X 122 RCL 05 123 SIGN 124 CHS 125 * 126 RCL 00 127 RCL Y 128 / 129 + 130 LBL 01 131 RCL 02 132 + 133 3 134 / 135 STO 00 136 RCL 02 137 - 138 RCL 01           139 2 140 ST/ 00 141 ST/ 01 142 ST/ 03 143 / 144 X^2 145 + 146 XEQ 03 147 STO 05 148 RCL 00 149 X^2 150 RCL 04 151 - 152 XEQ 03 153 RCL 00 154 RCL 01 155 * 156 RCL 03 157 - 158 SIGN 159 * 160 RCL 00           161 X<>Y 162 ST- 00 163 + 164 RCL 01 165 RCL 05 166 ST- 01 167 + 168 XEQ 02 169 FS? 02 170 SF 01 171 STO 03 172 X<>Y 173 STO 04 174 RCL 00 175 RCL 01 176 XEQ 02 177 RCL 04 178 RCL 03 179 END

( 217 bytes / SIZE 006 )

 STACK INPUTS OUTPUTS T a t Z b z Y c y X d x

-If  CF 01  &  CF 02  the 4 solutions are    x ; y ; z ; t
-If  SF 01  &  CF 02  the 4 solutions are    x+i.y ; x-i.y ; z ; t
-If  CF 01  &  SF 02  the 4 solutions are    x ; y ;  z+i.t ; z-i.t
-If  SF 01  &  SF 02  the 4 solutions are    x+i.y ; x-i.y ; z+i.t ; z-i.t

Example1:    Solve  x4-2.x3-35.x2+36.x+180 = 0

-2   ENTER^
-35  ENTER^
36   ENTER^
180  XEQ "P4"  >>>>   -5  RDN   -2   RDN   6   RDN   3    Flags F01 & F02 are clear , the 4 solutions are   -5 ; -2 ;  6  ;  3

Example2:    Solve  x4-5.x3+11.x2-189.x+522 = 0

-5   ENTER^
11   ENTER^
-189   ENTER^
522      R/S     >>>>   -2  RDN    5   RDN   6   RDN   3  Flag F01 is set & F02 is clear , the 4 solutions are  -2+5.i ; -2-5.i ; 6 ;  3

Example3:    Solve  x4-8.x3+26.x2-168.x+1305 = 0

-8   ENTER^
26   ENTER^
-168  ENTER^
1305    R/S      >>>>   -2  RDN    5   RDN   6   RDN   3    Flags F01 & F02 are set , the 4 solutions are  -2+5.i ; -2-5.i ; 6+3.i ; 6-3.i

Example4:    Solve  x4 + 2.x3+ 5.x2 + 4.x+ 4 = 0

2  ENTER^
5  ENTER^
4  ENTER^   R/S    >>>>   -0.5  RDN  1.322875656   RDN  -0.5  RDN  1.322875656   Flags F01 & F02 are set , the 4 solutions are -0.5 +/- 1.322875656 i  ,   -0.5 +/- 1.322875656 i

Notes:

-It's better to replace lines  119-120-121  by the M-Code routine  CBRT  ( cf "A few M-Code routines for the HP41" )
-LBL 03 avoids a small negative number ( instead of 0 ) that would produce a DATAERROR  with  SQRT

-We can also delete LBL 03 ( lines 70 to 85 )  after replacing lines 152 & 146  by  0?  SQRT  where  0?  is the following M-Code routine:

0BF  "?"
030   "0"
2A0  SETDEC
0F8  C=X
10E  A=C ALL
138  C=L
2EE  ?C#0
01F  JC+03
0AE  A<>C ALL
01B  JNC+03
261  C=
060  A/C
05E  C=|C|
10E  A=C ALL
04E   C
2BE
35C
050   =
21C
250
250
090   -1 10^(-8)
01D  C=
060  A+C
2FE  ?C<0?
3A0  ?NC RTN
04E  C=0
0E8  X=C
3E0  RTN

3°)  Palindromic Polynomials

a)  Degree = 4

-Palindromic polynomials are   p(x) = an.xn+an-1.xn-1+ ... + a1.x+a0   with  an = a0   ,    an-1 = a1  ,    an-2 = a2  and so on   ......

"PAL4" solves   x4 + a x3 + b x2 + a x + 1 = 0     we use   x + 1/x = y     it becomes a quadratic equation.

Data Registers:  R00: unused     R01 thru R04 = roots
Flags:   F01 F02
Subroutines:  /

 01 LBL "PAL4"  02 CF 01  03 CF 02  04 2  05 ST/ Z  06 -  07 X<>Y  08 CHS  09 ENTER  10 X^2  11 RCL Z  12 -  13 X<0?  14 GTO 02          15 SQRT  16 RCL Y  17 SIGN  18 *  19 +  20 X#0?  21 ST/ Y  22 2 23 ST/ Z  24 /  25 STO 03  26 X<>Y  27 STO 01  28 X^2  29 1  30 -  31 X<0?  32 GTO 00  33 SQRT  34 RCL 01            35 SIGN  36 *  37 RCL 01  38 +  39 STO 01  40 1/X  41 STO 02  42 GTO 01  43 LBL 00  44 CHS 45 SQRT  46 STO 02  47 SF 01  48 LBL 01  49 RCL 03  50 X^2  51 1  52 -  53 X<0?  54 GTO 00  55 SQRT  56 RCL 03            57 SIGN  58 *  59 RCL 03  60 +  61 STO 03  62 1/X  63 STO 04  64 GTO 03  65 LBL 00  66 CHS 67 SQRT  68 STO 04  69 SF 02  70 GTO 03  71 LBL 02  72 CHS  73 SQRT  74 2  75 ST/ Z  76 /  77 STO 02  78 STO 04            79 X<>Y  80 STO 01  81 STO 03  82 R-P  83 X^2  84 X<>Y  85 ST+ X  86 X<>Y  87 P-R  88 1 89 -  90 R-P  91 SQRT  92 X<>Y  93 2  94 /  95 X<>Y  96 P-R  97 ST+ 01  98 ST- 03  99 X<>Y 100 ST+ 02 101 ST- 04 102 SF 01 103 SF 02 104 LBL 03 105 RCL 04 106 RCL 03           107 RCL 02 108 RCL 01 109 END

( 141 bytes / SIZE 005 )

 STACK INPUTS OUTPUTS T / t Z / z Y a y X b x

-If  CF 01  &  CF 02  the 4 solutions are    x ; y ; z ; t
-If  SF 01  &  CF 02  the 4 solutions are    x+i.y ; x-i.y ; z ; t
-If  CF 01  &  SF 02  the 4 solutions are    x ; y ;  z+i.t ; z-i.t
-If  SF 01  &  SF 02  the 4 solutions are    x+i.y ; x-i.y ; z+i.t ; z-i.t

Example:         x4 + 4 x3 - 7 x2 + 4 x + 1 = 0

4  ENTER^
-7  XEQ "PAL4"   >>>>   0.802775638 = R01
RDN   0.596281205 = R02
RDN   -5.421086406 = R03
RDN   -0.184464870 = R04

-F01 is set & F02 is clear, so the solutions are   0.802775638 +/-  0.596281205 i   ;   -5.421086406   ;   -0.184464870

b)  Degree = 5

"PAL5" solves p(x) =  x5 + a x4 + b x3 + b x2 + a x + 1 = 0

(-1)  is always a root, so we can divide  p  by  (x+1)  thus  p(x) = (x+1) q(x)   where  q(x)  is a palindromic polynomial of degree 4

Data Registers:  R00: unused      R01 thru R04 = roots   R05 = -1
Flags:   F01 F02
Subroutine:  "PAL4"

 01 LBL "PAL5"  02 RCL Y  03 -  04 1  05 CHS  06 STO 05  07 ST+ Z  08 -  09 XEQ "PAL4"  10 END

26 bytes / SIZE 006 )

 STACK INPUTS OUTPUTS T / t Z / z Y a y X b x

-If  CF 01  &  CF 02  the 4 solutions are    x ; y ; z ; t
-If  SF 01  &  CF 02  the 4 solutions are    x+i.y ; x-i.y ; z ; t                   and the 5th root = -1 = R05
-If  CF 01  &  SF 02  the 4 solutions are    x ; y ;  z+i.t ; z-i.t
-If  SF 01  &  SF 02  the 4 solutions are    x+i.y ; x-i.y ; z+i.t ; z-i.t

Example:              x5 + 4 x4 -7 x3 - 7 x2 + 4 x + 1 = 0

4  ENTER^
-7  XEQ "PAL5"   >>>>    1.679502968 = R01
RDN     0.595414250 = R02
RDN    -5.077988862 = R03
RDN    -0.196928356 = R04

-Since F01 & F02  are clear, these numbers are the first 4 roots and the 5th root = -1 is stored in R05

c)  Degree = 6

"PAL6" solves p(x) = x6 + a x5 + b x4 + c x3 + b x2 + a x + 1 = 0        with  x + 1/x = y ,  it becomes a cubic equation.

Data Registers:  R00: temp   R01 thru R06 = roots
Flags:   F01 F02 F03
Subroutine:  "P3"

 01 LBL "PAL6"  02 RCL Z  03 ST+ X  04 -  05 X<>Y  06 3  07 -  08 X<>Y  09 1  10 RDN  11 XEQ "P3"  12 CF 02  13 CF 03  14 2  15 ST/ T  16 ST/ Z  17 /  18 STO 05            19 RDN  20 FS?C 01  21 GTO 02  22 STO 03  23 X<>Y  24 STO 01  25 X^2 26 1  27 -  28 X<0?  29 GTO 00  30 SQRT  31 RCL 01  32 SIGN  33 *  34 RCL 01  35 +  36 STO 01  37 1/X  38 STO 02  39 GTO 01  40 LBL 00  41 CHS  42 SQRT  43 STO 02            44 SF 01  45 LBL 01  46 RCL 03  47 X^2  48 1  49 -  50 X<0? 51 GTO 00  52 SQRT  53 RCL 03  54 SIGN  55 *  56 RCL 03  57 +  58 STO 03  59 1/X  60 STO 04  61 GTO 03  62 LBL 00  63 CHS  64 SQRT  65 STO 04            66 SF 02  67 GTO 03  68 LBL 02  69 STO 01  70 STO 03  71 X<>Y  72 STO 02  73 STO 04  74 X<>Y  75 R-P 76 X^2  77 X<>Y  78 ST+ X  79 X<>Y  80 P-R  81 1  82 -  83 R-P  84 SQRT  85 X<>Y  86 2  87 /  88 X<>Y  89 P-R  90 ST+ 01  91 ST- 03  92 X<>Y  93 ST+ 02  94 ST- 04  95 SF 01  96 SF 02  97 LBL 03  98 RCL 05            99 X^2 100 1 101 - 102 X<0? 103 GTO 00 104 SQRT 105 RCL 05 106 SIGN 107 * 108 RCL 05 109 + 110 STO 05 111 1/X 112 STO 06         113 GTO 01 114 LBL 00 115 CHS 116 SQRT 117 STO 06 118 SF 03 119 LBL 01 120 RCL 04 121 RCL 03 122 RCL 02 123 RCL 01 124 END

( 161 bytes / SIZE 007 )

 STACK INPUTS OUTPUTS T / t Z a z Y b y X c x

-If CF 01 the first 2 roots are    x ; y
-If SF 01  the first 2 roots are   x+i.y ; x-i.y
-If CF 02 the 2nd 2 roots are z ; t                             x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd 2 roots are  z+i.t ; z-i.t
-If CF 03 the last 2 roots are  u ; v                              u , v  =  R05  R06
-If SF 03  the last 2 roots are  u+i.v ; u-i.v

Example:         x6 + 2 x5 - 4 x4 + 3 x3 - 4 x2 + 2 x + 1 = 0

2   ENTER^
-4   ENTER^
3   XEQ "PAL6"   >>>>   -3.495175097 = R01
RDN    -0.286108699 = R02
RDN    -0.068902601 = R03
RDN    0.997623392  = R04

and    R05 = 0.959544499    &    R06 = 0.281557020     we have   CF 01  SF 02  &  SF 03

-So the 6 roots are   -3.495175097  ;   -0.286108699   ;   -0.068902601  +/-  0.997623392 i  ;  0.959544499 +/-  0.281557020 i

d)  Degree = 7

-Like all the palindromic polynomials with an odd degree,  -1  is a root
-So, there is a ploynomial  q  such that  (x) = ( x  + 1 ) q(x)  and  deg q = -1 + deg p
-Thus "PAL7" calls "PAL6" as a subroutine

Data Registers:  R00: temp   R01 thru R06 = roots   R07 = -1
Flags:   F01 F02 F03
Subroutine:  "PAL6"

 01 LBL "PAL7"  02 RCL Z  03 1  04 CHS  05 STO 07  06 +  07 R^  08 RCL Y  09 -  10 R^  11 RCL Y  12 -  13 XEQ "PAL6"  14 END

31 bytes / SIZE 008 )

 STACK INPUTS OUTPUTS T / t Z a z Y b y X c x

-If CF 01 the first 2 roots are    x ; y
-If SF 01  the first 2 roots are   x+i.y ; x-i.y
-If CF 02 the 2nd 2 roots are z ; t                             x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd 2 roots are  z+i.t ; z-i.t
-If CF 03 the 3rd 2 roots are  u ; v                              u , v  =  R05  R06          and       R07 = -1
-If SF 03  the 3rd 2 roots are  u+i.v ; u-i.v

Example:       x7 + 2 x6 - 4 x5 + 3 x4 + 3 x3 - 4 x2 + 2 x + 1 = 0

2   ENTER^
-4   ENTER^
3   XEQ "PAL7"   >>>>   -3.346973965 = R01
RDN    -0.298777347 = R02
RDN     0.500000000  = R03
RDN     0.866025404  = R04

and    R05 = 0.822875656    &    R06 = 0.568221485  &  R07 = -1   we have   CF 01  SF 02  &  SF 03

-So the 7 roots are   -3.346973965  ;   -0.298777347  ;   0.5 +/-  0.866025404 i  ;  0.822875656  +/-  0.568221485 i  ;  -1

e)  Degree = 8

"PAL8" solves p(x) = x8 + a x7 + b x6 + c x5 + d x4 + c x3 + b x2 + a x + 1 = 0        with  x + 1/x = y ,  it becomes a quartic equation.

Data Registers:  R00: temp  R01 thru R08:  roots
Flags:   F01 F02 F03 F04
Subroutine:  "P4"

 01 LBL "PAL8"  02 CF 03  03 CF 04  04 STO 00  05 RDN  06 STO 01  07 CLX  08 SIGN  09 -  10 ST- 00  11 ST- 00  12 3  13 -  14 RCL Y  15 LASTX  16 *  17 CHS  18 RCL 01            19 +  20 RCL 00  21 XEQ "P4"  22 STO 01  23 RDN  24 STO 03  25 CLX 26 2  27 ST/ 01  28 ST/ 03  29 ST/ Z  30 /  31 FS?C 02  32 GTO 02  33 STO 07  34 X<>Y  35 STO 05  36 X^2  37 1  38 -  39 X<0?  40 GTO 00  41 SQRT  42 RCL 05            43 SIGN  44 *  45 RCL 05  46 +  47 STO 05  48 1/X  49 STO 06  50 GTO 01 51 LBL 04  52 R-P  53 X^2  54 X<>Y  55 ST+ X  56 X<>Y  57 P-R  58 1  59 -  60 R-P  61 SQRT  62 X<>Y  63 2  64 /  65 X<>Y  66 P-R  67 RTN  68 LBL 00  69 CHS  70 SQRT  71 STO 06            72 SF 03  73 LBL 01  74 RCL 07  75 X^2 76 1  77 -  78 X<0?  79 GTO 00  80 SQRT  81 RCL 07  82 SIGN  83 *  84 RCL 07  85 +  86 STO 07  87 1/X  88 STO 08  89 GTO 03  90 LBL 00  91 CHS  92 SQRT  93 STO 08            94 SF 04  95 GTO 03  96 LBL 02  97 STO 05  98 STO 07  99 X<>Y 100 STO 06 101 STO 08 102 X<>Y 103 XEQ 04 104 ST+ 05 105 ST- 07 106 X<>Y 107 ST+ 06 108 ST- 08 109 SF 03 110 SF 04 111 LBL 03 112 FS?C 01 113 GTO 02 114 RCL 01         115 X^2 116 1 117 - 118 X<0? 119 GTO 00 120 SQRT 121 RCL 01 122 SIGN 123 * 124 RCL 01 125 + 126 STO 01 127 1/X 128 STO 02 129 GTO 01 130 LBL 00 131 CHS 132 SQRT 133 STO 02 134 SF 01 135 LBL 01 136 RCL 03 137 X^2 138 1 139 - 140 X<0? 141 GTO 00 142 SQRT 143 RCL 03         144 SIGN 145 * 146 RCL 03 147 + 148 STO 03 149 1/X 150 STO 04 151 GTO 03 152 LBL 00 153 CHS 154 SQRT 155 STO 04 156 SF 02 157 GTO 03 158 LBL 02 159 RCL 03 160 STO 02 161 STO 04 162 RCL 01 163 STO 03         164 XEQ 04 165 ST+ 01 166 ST- 03 167 X<>Y 168 ST+ 02 169 ST- 04 170 SF 01 171 SF 02 172 LBL 03 173 RCL 04 174 RCL 03 175 RCL 02 176 RCL 01 177 END

( 232 bytes / SIZE 009 )

 STACK INPUTS OUTPUTS T a t Z b z Y c y X d x

-If CF 01 the first roots are    x ; y
-If SF 01  the first roots are   x+i.y ; x-i.y
-If CF 02 the 2nd  roots are z ; t                             x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd  roots are  z+i.t ; z-i.t
-If CF 03 the 3rd  roots are  u ; v                              u , v  =  R05  R06    w , r = R07  R08
-If SF 03  the 3rd roots are  u+i.v ; u-i.v
-If CF 04 the last roots are  w ; r
-If SF 04  the last roots are w+i.r ; w-i.r

Example:         x8 + 2 x7 - 4 x6 + 3 x5 + 7 x4 + 3 x3 - 4 x2 + 2 x + 1 = 0

2   ENTER^
-4   ENTER^
3   ENTER^
7   XEQ "PAL8"  >>>>   -3.321130852 = R01
RDN    -0.301102258 = R02
RDN    -0.792609764 = R03
RDN     0.609729254 = R04

and   R05 = 1.134460522   R06 = 1.063259900   R07 = 0.469265796   R08 = -0.439813897

-Since we have  CF 01  SF 02  SF 03  SF 04  the 8 roots are:

-3.321130852  ;   -0.301102258   ;   -0.792609764 +/-  0.609729254 i  ;  1.134460522  +/-  1.063259900 i  ;  0.469265796 +/- 0.439813897 i

f)  Degree = 9

-1  is always a root of   p(x) = x9 + a x8 + b x7 + c x6 + d x5 + d x4 + c x3 + b x2 + a x + 1 = 0  so  p(x) = ( x + 1 ) q(x)  with deg q = 8 & q palindromic too.

"PAL9" calls "PAL8" as a subroutine.

Data Registers:  R00: temp   R01 thru R08 = roots   R09 = -1
Flags:   F01 F02 F03 F04
Subroutine:  "PAL8"

 01 LBL "PAL9"  02 STO 00  03 RDN  04 STO 01  05 CLX  06 RCL Z  07 -  08 ST- 01  09 RCL 01  10 ST- 00  11 1  12 CHS  13 STO 09  14 ST+ T  15 ST- Z  16 ST+ Y  17 ST- 00  18 X<> 00  19 XEQ "PAL8"  20 END

42 bytes / SIZE 010 )

 STACK INPUTS OUTPUTS T a t Z b z Y c y X d x

-If CF 01 the first roots are    x ; y
-If SF 01  the first roots are   x+i.y ; x-i.y
-If CF 02 the 2nd  roots are z ; t                               x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd  roots are  z+i.t ; z-i.t
-If CF 03 the 3rd  roots are  u ; v                              u , v  =  R05  R06    w , r = R07  R08     R09 = -1
-If SF 03  the 3rd roots are  u+i.v ; u-i.v
-If CF 04 the last roots are  w ; r
-If SF 04  the last roots are w+i.r ; w-i.r

Example:       x9 + 2 x8 - 4 x7 + 3 x6 + 7 x5 + 7 x4 + 3 x3 - 4 x2 + 2 x + 1 = 0

2   ENTER^
-4   ENTER^
3   ENTER^
7   XEQ "PAL9"  >>>>   -3.328907873 = R01
RDN    -0.300398821 = R02
RDN    -0.428871616 = R03
RDN     0.903365450 = R04

and   R05 = 1.289363998   R06 = 1.084685542   R07 = 0.454160965   R08 = -0.382065757   R09 = -1

-Since we have  CF 01  SF 02  SF 03  SF 04  the 9 roots are:

-3.328907873  ;  -0.300398821   ;   -0.428871616 +/-  0.903365450 i  ;  1.289363998  +/- 1.084685542 i  ;  0.454160965 +/- 0.382065757 i  ;   -1

4°)  Integer Roots

a)  Real Roots

-We assume the polynomial  p(x) = an.xn+an-1.xn-1+ ... + a1.x+a0  ( a0 # 0 ) has integer coefficients and integer roots

Data Registers:  R00 .... R04:  temp                             ( Registers Rbb thru Ree are to be initialized before executing "IROOT" )

•  Rbb = an  •  Rbb+1 = an-1 , ........ ,  •  Ree = a0    ( bb > 04 )

Flag:  F10
Subroutines:  /

 01 LBL "IROOT"  02 CF 10  03 STO 00  04 STO 04  05 FRC  06  E3  07 *  08 RCL 00            09 INT  10 -  11 1  12 STO 01  13 -  14 STO 03  15 GTO 03  16 LBL 00 17 RCL 00  18 RCL 01            19 0  20 LBL 01  21 RCL Y  22 *  23 RCL IND Z  24 +  25 ISG Z  26 GTO 01  27 X#0?  28 RTN  29  E-3  30 ST- 00  31 RCL 00  32 STO 02 33 CLX  34 DSE 03  35 LBL 02  36 RCL 01            37 *  38 ST+ IND 02  39 RCL IND 02  40 ISG 02  41 GTO 02  42 RCL 01  43 STO IND 02  44 SF 10  45 RTN  46 LBL 03  47 RCL 03  48 X=0? 49 GTO 05  50 XEQ 00  51 FS?C 10  52 GTO 03  53 RCL 01            54 CHS  55 STO 01  56 LBL 04  57 RCL 03  58 X=0?  59 GTO 05  60 XEQ 00  61 FS?C 10  62 GTO 04  63 1  64 RCL 01 65 -  66 STO 01  67 GTO 03  68 LBL 05  69 SIGN  70 RCL 00  71 +  72 RCL IND X  73 RCL IND L  74 /  75 CHS  76 STO IND Y  77 RCL 04            78 ISG X  79 END

( 121 bytes / SIZE ??? )

 STACK INPUTS OUTPUTS Y / Rbb+1 X bbb.eee 1+bbb.eee

( with  bbb > 004 )

Example:
p(x) = x5 - 64 x3 - 66 x2 + 927 x + 1890 = 0

-If you choose  bbb = 011     1  STO 11   0  STO 12   -64  STO 13   -66  STO 14   927  STO 15   1890  STO 16

11.016  XEQ "IROOT"   >>>>  12.016                                    ---Execution time = 26s---
X<>Y      7     = R12

R12 = 7   R13 = -6   R14 = 5   R15 = -3   R16 = -3

-Thus,   p(x) = ( x - 7 ) ( x+6 ) ( x - 5 ) ( x + 3 )2

Notes:

-In fact, the last root ( stored in Rbb+1 ) might be non-integer.
-The precision is exact, provided the calculations do not involve numbers > 1010

-Of course, this program is slow if the roots are very large...

b)  Complex Roots

-The same method is used by "IRZ" to comput the complex roots ( Gaussian integers ) of a polynomial

p(z) = cn zn + cn-1 zn-1 + .................. + c1 z + c0          with         ck = ak + i.bk     where   ak & bk  are integers   ( c0 # 0 )

Data Registers:  R00 .... R09:  temp                             ( Registers Rbb thru Ree are to be initialized before executing "IRZ" )

•  Rbb = an  •  Rbb+1 = bn , ........ ,   •  Ree-1 = a0   •  Ree= b0     ( bb > 09 )

Flag:  F10
Subroutines:  /

 01 LBL "IRZ"  02 CF 10  03 STO 00  04 STO 03  05 FRC  06 3  07 10^X  08 *  09 RCL 00  10 INT  11 -  12 3  13 -  14 2  15 STO 08            16 /  17 STO 04  18 GTO 03  19 LBL 00  20 RCL 00  21 STO 05  22 CLST  23 LBL 01  24 STO 06  25 RCL 02  26 *  27 X<>Y  28 STO 07 29 RCL 01  30 *  31 +  32 RCL 01  33 RCL 06  34 *  35 RCL 02  36 RCL 07  37 *  38 -  39 RCL IND 05  40 +  41 X<>Y  42 ISG 05  43 RCL IND 05  44 +  45 X<>Y  46 ISG 05  47 GTO 01  48 X=0?  49 X#Y?  50 RTN  51 2 E-3  52 ST- 00  53 RCL 00            54 STO 05  55 CLST  56 DSE 04 57 LBL 02  58 STO 06  59 RCL 01  60 *  61 X<>Y  62 STO 07  63 RCL 02  64 *  65 -  66 RCL IND 05  67 +  68 STO IND 05  69 RCL 02  70 RCL 06            71 *  72 RCL 01  73 RCL 07  74 *  75 +  76 ISG 05  77 RCL IND 05  78 +  79 STO IND 05  80 X<>Y  81 ISG 05  82 GTO 02  83 RCL 01  84 STO IND 05 85 ISG 05  86 CLX  87 RCL 02  88 STO IND 05  89 SF 10  90 RTN  91 LBL 03  92 RCL 08  93 STO 09  94 DSE X  95 STO 01            96 CLX  97 STO 02  98 LBL 04  99 RCL 04 100 X=0? 101 GTO 09 102 XEQ 00 103 FS?C 10 104 GTO 04 105 RCL 02 106 X=0? 107 GTO 08 108 CHS 109 STO 02 110 LBL 05 111 RCL 04 112 X=0? 113 GTO 09 114 XEQ 00 115 FS?C 10 116 GTO 05 117 LBL 08 118 RCL 01 119 X=0? 120 GTO 08 121 CHS 122 STO 01 123 LBL 06 124 RCL 04         125 X=0? 126 GTO 09 127 XEQ 00 128 FS?C 10 129 GTO 06 130 RCL 02 131 X=0? 132 GTO 08 133 CHS 134 STO 02 135 LBL 07 136 RCL 04 137 X=0? 138 GTO 09 139 XEQ 00 140 FS?C 10 141 GTO 07 142 LBL 08 143 RCL 01 144 ABS 145 STO 01 146 SIGN 147 ST- 01 148 ST+ 02 149 DSE 09 150 GTO 04 151 ST+ 08 152 GTO 03 153 LBL 09 154 RCL 03         155 ISG X 156 RCL IND X 157 STO 04 158 ISG Y 159 RCL IND Y 160 STO 05 161 * 162 ISG Y 163 RCL IND Y 164 STO 06 165 RCL IND 03 166 STO 07 167 * 168 - 169 RCL 05 170 RCL 07 171 * 172 RCL 04 173 RCL 06 174 * 175 + 176 CHS 177 RCL 04 178 X^2 179 RCL 07         180 X^2 181 + 182 ST/ Z 183 / 184 2 185 ST+ 03 186 RDN 187 STO IND 03 188 ISG 03 189 X<>Y 190 STO IND 03 191 X<>Y 192 RCL 03 193 1 194 - 195 END

( 268 bytes / SIZE ??? )

 STACK INPUTS OUTPUTS Z / Rbb+3 Y / Rbb+2 X bbb.eee 2+bbb.eee

( with  bbb > 009 )

Example:
p(x) = (2+3.i) z5 + (34-27.i) z4 + (-122-66.i) z3 + (738-466.i) z2 + (-4080-3065.i) z + (-5100+6325.i) = 0

-If you choose  bbb = 011

2  STO 11    34  STO 13    -122  STO 15     738  STO 17   -4080  STO 19   -5100  STO 21
3  STO 12   -27  STO 14    -66    STO 16   -466  STO 18   -3065  STO 20    6325  STO 22

11.022   XEQ "IRZ"   >>>>    13.022                                   ---Execution time = 6m45s---
RDN        -4
RDN         7

-And we have   R13 = -4   R14 = 7   R15 = 3   R16 = 4   R17 = 3   R18 = 4   R19 = 0   R20 = -5   R20 = -1   R21 = 2

-Thus,   p(z)  = ( 2 + 3.i ) ( z + 4 - 7.i ) ( z - 3 - 4.i )2 ( z + 5.i ) ( z + 1 - 2.i )

Notes:

-In fact, the last root ( stored in Rbb+2 & Rbb+3 ) might be non-integer.
-The precision is exact, provided the calculations do not involve numbers > 1010

-Of course, this program is very slow if the roots are very large...

5°)  A Few Quintic Equations

a)  Program#1

-We have   Sinh 5y = 16 Sinh5 y + 20 Sinh3 y + 5 Sinh y
and        Sin 5y  = 16 Sin5 y - 20 Sin3 y + 5 Sin y

-So, we can use these formulae to solve   x5 + 5 k x3 + 5 k2 x + A = 0

Data Registers:  R00 thru R06: temp   R05 = 5th root
Flags:   F01 F02
Subroutine:  "P4"

 01 LBL "P5"  02 CF 01  03 CF 02  04 CHS  05 X<>Y  06 STO 01  07 X<0?  08 GTO 00  09 X#0?  10 GTO 01  11 X<>Y  12 SIGN  13 LASTX  14 ABS  15 5  16 1/X  17 Y^X  18 *  19 GTO 03  20 LBL 00  21 CHS  22 X^2  23 LASTX  24 SQRT  25 ST+ X  26 STO 00            27 *  28 /  29 ABS 30 1  31 X L  98 SIGN  99 X<>Y 100 LASTX 101 X^2 102 1 103 - 104 SQRT 105 + 106 LN 107 5 108 / 109 E^X 110 ENTER 111 1/X 112 + 113 * 114 RCL 01           115 CHS 116 SQRT 117 * 118 LBL 03 119 STO 06 120 RCL 01 121 X^2 122 5 123 * 124 STO 05 125 X<>Y 126 X^2 127 RCL 01           128 5 129 * 130 + 131 STO Y 132 RCL 06 133 * 134 RCL X 135 LASTX 136 * 137 RCL 05 138 + 139 RCL 06 140 RDN 141 XEQ "P4" 142 STO 05 143 X<> 06 144 X<> 05 145 LBL 04 146 END

177 bytes / SIZE 007 )

 STACK INPUTS OUTPUTS T / t Z / z Y k y X A x

-If  CF 01  &  CF 02  the 4 solutions are    x ; y ; z ; t
-If  SF 01  &  CF 02  the 4 solutions are    x+i.y ; x-i.y ; z ; t                   and the 5th root  R05 = u
-If  CF 01  &  SF 02  the 4 solutions are    x ; y ;  z+i.t ; z-i.t
-If  SF 01  &  SF 02  the 4 solutions are    x+i.y ; x-i.y ; z+i.t ; z-i.t

Example1:              x5 - 15 x3 + 45 x + 4 = 0      ( k = -3 , A = 4 )

-3  ENTER^
4  XEQ "P5"   >>>>   -3.321006904
RDN    -1.963370398
RDN     2.107577266
RDN     3.265924783     and    R05 =  -0.089124743

-Since we have  CF 01 & CF 02, these 5 numbers are the 5 roots of this quintic equation

Example2:              x5 + 15 x3 + 45 x + 100 = 0      ( k = 3 , A = 100 )

3    ENTER^
100  XEQ "P5"   >>>>   -0.412527941
RDN     3.530731294
RDN     1.080012167
RDN     2.182111936     and    R05 =  -1.334968451

-We have  SF 01 & SF 02 , so the 5 roots are:   -0.412527941 +/- 3.530731294 i  ;  1.080012167 +/- 2.182111936 i  ;  -1.334968451

b)  Program#2

-The following program solves    x5 + A x3 + a x2 + b x + c = 0    IF   A =  c / a + a b / c

Data Registers:  R00 thru R07: temp
Flags:   F00  F01
Subroutine:  "P3"

 01 LBL "P5"  02 CF 00  03 RCL Z  04 /  05 STO 06  06 STO 07  07 /  08 ST+ 06  09 0  10 X<> Z  11 1  12 RDN  13 XEQ "P3"  14 RCL 07  15 X>0?  16 SF 00  17 ABS  18 SQRT  19 END

34 bytes / SIZE 008 )

 STACK INPUTS OUTPUTS T / t Z a z Y b y X c x

-If  CF 00  &  CF 01  the 5 solutions are    x ; -x ; y ; z ; t
-If  SF 00  &  CF 01  the 5 solutions are    i.x ; -i.x ; y ; z ; t
-If  CF 00  &  SF 01  the 5 solutions are    x ; -x ; y ;  z+i.t ; z-i.t
-If  SF 00  &  SF 01  the 5 solutions are    i.x ; -i.x ; y ; z+i.t ; z-i.t

Example:   x5 + A x3 + 3 x2 + 4 x - 9 = 0      with  A = - 13/3

3  ENTER^
4  ENTER^
-9  XEQ "P5"   >>>>    1.732050808
RDN   -1.746676973
RDN    0.873338487
RDN    -0.977152498

- CF 00 & SF 01  so the 5 roots are    1.732050808  ;   -1.732050808  ;   -1.746676973  ;  0.873338487 +/-  0.977152498 i

Notes:

A is calculated and stored in R06. In this example,  R06 = A = -4.333333333

-We have solved  ( x2 + c/a ) ( x3 + (ab/c) x + a ) = 0

c)  Program#3

-The following program solves    x5 + A x4 + B x3 + C x2 + D x + E = 0     after rewriting it   ( x2 + a x + b ) ( x3 + a x2 + b x + c ) = 0

-You choose  B , C , D  and  "P5" solves an equivalent quartic equation

If the quartic equation has no real root, no result.
If the quartic equation has 2 real roots, , there are 2 solutions.
If the quartic equation has 4 real roots , there are 4 solutions.

-When there is no more solutions, the HP41 displays " END"

Data Registers:  R00 thru R17: temp    R01 thru R05 = 5 roots   R06 = A , R07 = B , R08 = C , R09 = D , R10 = E
Flags:   F00  F01  F02
Subroutines:  "P2"  "P3"  "P4"

 01 LBL "P5"  02 STO 09  03 RDN  04 STO 08  05 X<>Y  06 STO 07  07 6  08 *  09 CHS  10 X<>Y  11 4  12 *  13 RCL 09            14 LASTX  15 *  16 CHS  17 RCL 07  18 X^2  19 +  20 5 21 ST/ T  22 ST/ Z  23 /  24 0  25 RDN  26 XEQ "P4"  27 STO 11  28 RDN  29 STO 12  30 RDN  31 STO 13  32 X<>Y  33 STO 14            34 FS? 01  35 GTO 00  36 RCL 11  37 XEQ 01  38 RCL 12  39 XEQ 01  40 LBL 00 41 FS?C 02  42 GTO 00  43 RCL 13  44 XEQ 01  45 RCL 14  46 XEQ 01  47 GTO 00  48 LBL 01  49 STO 06            50 X^2  51 CHS  52 RCL 07  53 +  54 2  55 /  56 STO 15  57 1  58 X<>Y  59 RCL 06  60 X<>Y 61 XEQ "P2"  62 STO 16  63 X<>Y  64 STO 17  65 RCL 08  66 RCL 07  67 RCL 06            68 *  69 -  70 RCL 06  71 3  72 Y^X  73 +  74 STO 10  75 1  76 RCL 06  77 RCL 15  78 R^  79 XEQ "P3"  80 STO 05  81 RDN 82 STO 03  83 X<>Y  84 STO 04  85 RCL 15  86 ST* 10  87 RCL 06            88 ST+ 06  89 RCL 17  90 STO 02  91 X<> 16  92 STO 01  93 RCL 04  94 RCL 03  95 RCL 02  96 RCL 01  97 STOP  98 RTN  99 LBL 00 100 " END" 101 AVIEW 102 END

143 bytes / SIZE 018 )

 STACK INPUTS OUTPUTS T / t Z B z Y C y X D x

-If  CF 00  &  CF 01  the 4 roots are    x ; y ; z ; t
-If  SF 00  &  CF 01  the 4 roots are    x+i.y ; x-i.y ; z ; t                   and the 5th root  R05 = u
-If  CF 00  &  SF 01  the 4 roots are    x ; y ;  z+i.t ; z-i.t
-If  SF 00  &  SF 01  the 4 roots are    x+i.y ; x-i.y ; z+i.t ; z-i.t

Example:      x5 + A x4 + 3 x3 + 7 x2 + 6 x + E = 0

3   ENTER^
7   ENTER^
6   XEQ "P5"   >>>>    3.052611654
RDN   -0.541473338
RDN    -0.326247858
RDN    0.552188522    and   R05 = 3.163634031

CF 00 &  SF 01 so the roots are  3.052611654  ;   -0.541473338  ;  -0.326247858 +/-  0.552188522 i  ;  3.163634031

-The equation is   x5 - 5.022276632 x4 + 3 x3 + 7 x2 + 6 x + 2.151028651 = 0   because   R06 = A = -5.022276632  &  R10 = E = 2.151028651

R/S  >>>>  -0.500000000
RDN    0.866025405
RDN    0.440619700
RDN    -1.569610322    and   R05 = -1.881239400

SF 00 &  SF 01 so the roots are  -0.5 +/- 0.866025405 i  ;  0.440619700 +/- 1.569610322 i  ;  -1.881239400

-The equation is   x5 + 2 x4 + 3 x3 + 7 x2 + 6 x + 5 = 0   because   R06 = A = 1.999999999  &  R10 = E = 5.000000005

R/S   >>>>  " END"    thus, there is nomore solution.

6°)  A Few Sextic Equations

"P6" solves   x6 + A x4 + B x3 + C x2 + D x + E = 0    if   E = B2/4 - ( -C + (D/B)2 )2 / 4 / ( -A + 2D/B )

Data Registers:  R00 thru R15: temp    R01 thru R06 = 6 roots   R11= A , R12 = B , R13 = C , R14 = D , R15 = E
Flags:    F01  F02
Subroutine:   "P3"

 01 LBL "P6"  02 CF 02  03 STO 14  04 RDN  05 STO 13            06 RDN  07 STO 12  08 X<>Y  09 STO 11  10 RCL 14  11 RCL 12  12 /  13 STO 09  14 ST+ X 15 -  16 STO 08  17 RCL 09  18 X^2  19 RCL 13            20 -  21 2  22 /  23 STO 07  24 X^2  25 X<>Y  26 /  27 RCL 12  28 2 29 /  30 STO 10  31 X^2  32 +  33 STO 15            34 RCL 08  35 CHS  36 SQRT  37 ST/ 07  38 STO 08  39 CHS  40 RCL 09  41 RCL 10  42 RCL 07 43 -  44 1  45 RDN  46 XEQ "P3"  47 FS? 01  48 SF 02  49 STO 06            50 RDN  51 X<> 10  52 X<>Y  53 X<> 07  54 +  55 1  56 RCL 08 57 RCL 09  58 R^  59 XEQ "P3"  60 STO 05  61 RDN  62 STO 01            63 X<>Y  64 STO 02  65 RCL 07  66 STO 04  67 RCL 10  68 STO 03  69 RCL 02  70 RCL 01  71 END

91 bytes / SIZE 016 )

 STACK INPUTS OUTPUTS T A t Z B z Y C y X D x

-If CF 01 the first 2 roots are    x ; y
-If SF 01  the first 2 roots are   x+i.y ; x-i.y
-If CF 02 the 2nd 2 roots are z ; t                             x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd 2 roots are  z+i.t ; z-i.t

-The last 2 roots are always real  u ; v                              u , v  =  R05  R06

Example:     x6 + x4 - 4 x3 - x2 - 4 x + E = 0

1  ENTER^
-4  ENTER^
-1  ENTER^
-4  XEQ "P6"   >>>>   -0.771844506
RDN   1.115142508
RDN   -0.287371537
RDN   1.349996398      and    R05 = 0.543689012    R06 =  1.574743073

SF 01 & SF 02  thus the 6 roots are  -0.771844506 +/- 1.115142508 i ;  -0.287371537 +/- 1.349996398 i  ;  0.543689012  ;  1.574743073

-R15 = E = 3.000000000  so the equation is   x6 + x4 - 4 x3 - x2 - 4 x + 3= 0

7°)  A Few Septic Equations

a)  Program#1

-We have:   Sinh 7y = 64 Sinh7 y + 112 Sinh5 y + 56 Sinh3 y + 7 Sinh y     and        Sin 7y  = -64 Sin7 y + 112 Sin5 y - 56 Sin3 y + 7 Sin y

-So we can use these formulae to solve   x7 + 7 k x5 + 14 k2 x3 + 7 k3 x + A = 0

Data Registers:  R00: temp   R01 thru R07 = roots   R08: temp
Flags:   F01 F02 F03
Subroutine:  /

-Lines 19 & 49 are three-byte GTOs

 01 LBL "P7"  02 RAD  03 PI  04 ST+ X  05 7  06 /  07 STO 08  08 RDN  09 CF 00  10 CF 01  11 CF 02  12 CF 03  13 CHS  14 X<>Y  15 STO 01  16 X<0?  17 GTO 01  18 X#0?  19 GTO 03  20 X<>Y  21 SIGN  22 LASTX  23 ABS  24 7  25 1/X  26 Y^X  27 *  28 STO 07            29 RCL 08  30 X<>Y  31 P-R  32 STO 01  33 X<>Y 34 STO 02  35 RCL 08  36 ST+ X  37 ST+ 08  38 RCL 07  39 P-R  40 STO 03  41 X<>Y  42 STO 04  43 RCL 08  44 RCL 07  45 P-R  46 STO 05  47 X<>Y  48 STO 06  49 GTO 05  50 LBL 00  51 RCL 06  52 RCL Y  53 RCL 06            54 E^X  55 P-R  56 R^  57 CHS  58 R^  59 CHS  60 E^X  61 P-R  62 CHS  63 X<>Y  64 CHS  65 ST+ T  66 RDN 67 +  68 FS? 00  69 X<>Y  70 RTN  71 LBL 01  72 CHS  73 ENTER  74 X^2  75 LASTX  76 SQRT  77 ST+ X  78 STO 00  79 *  80 *  81 /  82 ABS  83 1  84 X L 135 SIGN 136 CHS 137 ST* 00 138 X<>Y 139 ENTER 140 X^2 141 2 142 ST/ 00 143 SIGN 144 - 145 SQRT 146 + 147 PI 148 CHS 149 2 150 / 151 STO 04 152 RDN 153 LN 154 7 155 / 156 STO 06           157 E^X 158 ENTER 159 1/X 160 + 161 CHS 162 GTO 04 163 LBL 03 164 X^2 165 LASTX 166 ST* Y 167 SQRT 168 STO 00 169 ST+ X 170 * 171 / 172 ENTER 173 X^2 174 0 175 STO 04 176 SIGN 177 + 178 SQRT 179 + 180 LN 181 7 182 / 183 E^X-1 184 LASTX 185 STO 06 186 CHS 187 E^X-1 188 - 189 LBL 04 190 STO 07           191 RCL 04 192 RCL 08 193 + 194 XEQ 00 195 STO 01 196 X<>Y 197 STO 02 198 RCL 08 199 ST+ X 200 ST+ 08 201 RCL 04 202 + 203 XEQ 00 204 STO 03 205 X<>Y 206 X<> 04 207 RCL 08 208 + 209 XEQ 00 210 STO 05 211 X<>Y 212 RCL 00 213 ST* 01 214 ST* 02 215 ST* 03 216 ST* 04 217 ST* 05 218 ST* 07 219 * 220 STO 06           221 LBL 05 222 SF 01 223 SF 02 224 SF 03 225 LBL 06 226 DEG 227 CF 00 228 RCL 04 229 RCL 03 230 RCL 02 231 RCL 01 232 END

( 289 bytes / SIZE 009 )

 STACK INPUTS OUTPUTS T / t Z / z Y k y X A x

-If CF 01 the first 2 roots are    x ; y
-If SF 01  the first 2 roots are   x+i.y ; x-i.y
-If CF 02 the 2nd 2 roots are z ; t                             x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd 2 roots are  z+i.t ; z-i.t
-If CF 03 the 3rd 2 roots are  u ; v                              u , v  =  R05  R06          and       R07 = w = the 7th root  ( always real )
-If SF 03  the 3rd 2 roots are  u+i.v ; u-i.v

Example1:       x7 + 49 x5 + 686 x3 + 2401 x - 100 = 0     ( k = 7 , A = -100 )

7   ENTER^
-100  XEQ "P7"   >>>>  0.025955070
RDN   4.137191362
RDN   -0.009263257
RDN   5.158993245     and   R05 = -0.037506163   R06 =  2.295967991   R07 = 0.041628699

SF 01 & SF 02 & SF 03  so the 7 roots are:

0.025955070 +/- 4.137191362 i  ;   -0.009263257 +/-  5.158993245 i  ;  -0.037506163 +/-  2.295967991 i  ;  0.041628699

Example2:       x7 - 49 x5 + 686 x3 - 2401 x + 4 = 0     ( k = -7 , A = 4 )

-7   ENTER^
4   XEQ "P7"   >>>>  -4.136024417
RDN   -5.159204061
RDN   -2.297397818
RDN    2.294395841     and   R05 = 5.158462634   R06 =  4.138101851   R07 = 0.001665974

-Since we have   CF 01 & CF 02 & CF 03  these 7 real numbers are the 7 roots.

b)  Program#2

-The following routine solves the equation   x7 + A x6 + B x5 + C x4 + D x3 + E x2 + F x + G = 0   if it may be re-written:   ( x4 + a x3 + b x + c ) ( x3 + d x + e ) = 0

-You choose A , B , C , D , E

Data Registers:  R00 thru R17: temp                      ( Registers R11 thru R15 are to be initialized before executing "P7" )

R01 thru R07 = 7 roots               •  R11= A , •  R12 = B , •  R13 = C , •  R14 = D , •  R15 = E       and when the program stops:       R16 = F  R17 = G

Flags:    F01  F02  F03
Subroutines:   "P3" "P4"

 01 LBL "P7"  02 CF 03  03 RCL 12            04 RCL 13  05 RCL 11  06 RCL 12  07 *  08 -  09 RCL 15  10 RCL 12  11 /  12 STO 16 13 -  14 STO 10            15 ST* 16  16 STO 17  17 1  18 0  19 RDN  20 RDN  21 XEQ "P3"  22 FS? 01  23 SF 03  24 STO 07 25 RDN  26 STO 08  27 X<>Y  28 STO 09  29 RCL 11            30 RCL 14  31 RCL 10  32 RCL 11  33 *  34 -  35 STO 00  36 ST* 17 37 RCL 15  38 RCL 12  39 ST* 00  40 /  41 RCL 00            42 ST+ 16  43 CLX  44 X<> Z  45 XEQ "P4"  46 STO 01  47 RDN  48 STO 02 49 RDN  50 STO 03  51 X<>Y  52 STO 04  53 RCL 08  54 STO 05            55 RCL 09  56 STO 06  57 RCL 04  58 RCL 03  59 RCL 02  60 RCL 01  61 END

85 bytes / SIZE 018 )

 STACK INPUTS OUTPUTS T / t Z / z Y / y X / x

-If CF 01 the first 2 roots are    x ; y
-If SF 01  the first 2 roots are   x+i.y ; x-i.y
-If CF 02 the 2nd 2 roots are z ; t                             x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd 2 roots are  z+i.t ; z-i.t
-If CF 03 the 3rd 2 roots are  u ; v                              u , v  =  R05  R06          and       R07 = w = the 7th root  ( always real )
-If SF 03  the 3rd 2 roots are  u+i.v ; u-i.v

Example:       x7 + 3 x6 + 2 x5 - 7 x4 + 5 x3 + 4 x2 + F x + G = 0    ( A = 3 , B = 2 , C = -7 , D = 5 , E = 4 )

3  STO 11   -7  STO 13   4  STO 15
2  STO 12    5   STO 14

XEQ "P7"   >>>>  -2.825275998
RDN    1.404195934
RDN    1.325275998
RDN    1.807422116     and   R05 = -1.098545526   R06 =  2.370739719   R07 = 2.197091051

SF 01 & SF 02 & SF 03  so the 7 roots are:

-2.825275998 +/- 1.404195934 i  ;   1.325275998 +/-  1.807422116 i  ;  -1.098545526 +/-  2.370739719 i  ;  2.197091051

-And we have   R16 = 70  &  R17 = -750

-So, we have found the 7 roots of   x7 + 3 x6 + 2 x5 - 7 x4 + 5 x3 + 4 x2 + 70 x - 750 = 0

8°)  A Few Octic Equations

-The following routine solves the equation   x8 + A x4 + B x2 + C x + D = 0   if it may be re-written:   ( x4 + a x + b ) ( x4 - a x + c ) = 0

-You choose A , B < 0 & C

Data Registers:  R00 thru R15: temp              R11= A ,  R12 = B ,  R13 = C ,  R14 = D

R01 thru R08 = 8 roots

Flags:    F01  F02  F03  F04
Subroutine:   "P4"

 01 LBL "P8"  02 CF 03  03 CF 04  04 STO 13  05 RDN  06 STO 12  07 CHS  08 SQRT  09 STO 14  10 X<>Y  11 STO 11            12 *  13 STO 15 14 RCL 13  15 ST+ 15  16 -  17 RCL 14  18 ST+ X  19 ST/ 15  20 /  21 STO 08  22 0  23 ENTER  24 ENTER  25 RCL 14            26 R^ 27 XEQ "P4"  28 FS? 01  29 SF 03  30 FS? 02  31 SF 04  32 STO 09  33 RDN  34 STO 10            35 RDN  36 STO 07  37 X<>Y  38 X<> 08  39 RCL 15 40 *  41 X<> 14  42 CHS  43 LASTX  44 0  45 ENTER  46 R^  47 R^  48 XEQ "P4"  49 STO 01            50 RDN  51 STO 02  52 RDN 53 STO 03  54 X<>Y  55 STO 04  56 RCL 10  57 STO 06  58 RCL 09  59 STO 05  60 RCL 04  61 RCL 03            62 RCL 02  63 RCL 01  64 END

88 bytes / SIZE 016 )

 STACK INPUTS OUTPUTS T / t Z A z Y B < 0 y X C x

-If CF 01 the first 2 roots are    x ; y
-If SF 01  the first 2 roots are   x+i.y ; x-i.y
-If CF 02 the 2nd 2 roots are z ; t                               x , y , z , t  = R01  R02  R03  R04
-If SF 02 the 2nd 2 roots are  z+i.t ; z-i.t
-If CF 03 the 3rd 2 roots are  u ; v
-If SF 03  the 3rd 2 roots are  u+i.v ; u-i.v                  u , v , w , p = R05  R06  R07  R08
-If CF 04 the last 2 roots are  w ; p
-If SF 04  the last 2 roots are  w+i.p ; w-i.p

Example:           x8 + 4x4 - 9 x2 + 6 x + D = 0

4  ENTER^
-9  ENTER^
6   XEQ "P8"   >>>>   -0.973561484  = R01
RDN    1.310797213   = R02
RDN    0.973561484   = R03
RDN    0.421253594   = R04

and    R05 = -1.307486100     R06 = -0.337666766    R07 = 0.822576433   R08 =  1.260317961

-We have  SF 01  SF 02  CF 03  SF 04  thus, the roots are:

-0.973561484 +/- 1.310797213 i   ;   0.973561484 +/-  0.421253594 i  ;  -1.307486100  ;  -0.337666766  ;  0.822576433 +/- 1.260317961 i        and  R14 = 3

-So these numbers are the 8 roots of the equation:     x8 + 4x4 - 9 x2 + 6 x + 3 = 0

References:

[1]  Abramowitz and Stegun - "Handbook of Mathematical Functions" -  Dover Publications -  ISBN  0-486-61272-4
[2]  David J. Wolters - "Tutorial on Analytic Algorithms to Solve Cubic and Quartic Equations"
[3]  Raghavendra G. Kulkarni - "Solving certain quintics"
[4]  Raghavendra G. Kulkarni - "Solving Sextic Equations"