Saturday, November 18, 2023

HP 32S and HP 15C: Synthetic Division

HP 32S and HP 15C:   Synthetic Division



These programs perform synthetic division, where a polynomial of degree n is divided by the binomial term x - x_0:


[a_n × x^n + a_(n-1) × x^(n-1) + a_(n-2) × x^(n-2) + ... a_1 × x + a_0] ÷ (x - x_0)


With the result of the division is:


[q_(n-1) × x^(n-1) + q_(n-2) × x^(n-2) + ... + q_1 × x + q_0] + R ÷ (x - x_0)


where: 


q_(n-1) = a_n

R is the remainder.



HP 32S/32SII:  Synthetic Division


The degree of the polynomial can go up to 24, with the variables set up as:


p(x) = [ A + B × x + C × x^2 + D × x^3 + ... + Y × x^24 ] ÷ (x - Z)


where

A is the constant

B is the coefficient of x

C is the coefficient of x^2 

and so on...

Z = x_0


Flag 1 is used as an indicator that there are coefficients q_k.  



Code:


S01  LBL S

S02  CF 1

S03  1

S04  +

S05  STO i

S06  SF 1

S07  RCL (i)

S08  STOP

S09  DSE i


Z01  LBL Z

Z02  RCL× Z

Z03  RCL+ (i)

Z04  STOP

Z05  DSE i

Z06  GTO Z

Z07  CF 1

Z08  RTN


Total Memory:  S:  13.5 bytes, Z:  12.0 bytes, Total:  25.5 bytes


To run:  store the coefficients and x0.  Enter the degree of the polynomial and press XEQ S.  



HP 15C:  Synthetic Division


The degree of the polynomial can go as high as you want, as long as you have registers.   The variables set up as:


p(x) = [ R0 + R1 × x + R2 × x^2 + R3 × x^3 + ... ] ÷ (x - R0)


where

R0 is the constant

R1 is the coefficient of x

R2 is the coefficient of x^2 

and so on...

R0 = x_0


Flag 8 is used as an indicator (C on the screen) that there are coefficients q_k.  In effect, this turns on complex mode, which would create a stack of imaginary numbers.  The complex mode for the HP 15C requires five registers to run.  


Code:


001  LBL A:   42,21,11

002  CF 8:  43, 5, 8

003  1:  1

004  +:  40

005  STO I:  44, 25

006  SF 8:  43, 4, 8

007  RCL (i):  45, 24

008  R/S:   31

009  DSE I:  42, 5, 25


010  LBL 0:  42, 21, 0

011  RCL× 0:  45, 20, 0

012  RCL+ (i):  45,40,24

013  R/S:  31

014  DSE I:  42, 5,25

015  GTO 0:  22, 0

016  CF 8:  43, 5, 8

017  RTN:  43,32


To run:  store the coefficients and x0.  Enter the degree of the polynomial and press GSB A.  



Examples



Example 1:  [ 4x^3 + 3x^2 + 2x - 5 ] ÷ [ x -  1 ]


HP 32S:

A:  -5,  B:  2,  C:  3,  D:  4,  Z:  1


HP 15C: 

R1:  -5,  R2:  2,  R3:  3,  R4:  4,  R0:  1


Degree: 3


3 XEQ S/GSB A:


Results:  

4   (x^2)  R/S

7   (x)   R/S

9   (constant)  R/S

4  (remainder)


4x^2 + 7x + 9 + 4 ÷ (x-1)



Example 2:  [ x^4 - 3x^2 + 6x + 3 ] ÷ [ x + 3 ]


HP 32S:

A:  3,  B:  6,  C:  -3, D:  0,  E:  1,  Z:  -3


HP 15C:

R1:  3,  R2:  6,  R3:  -3, R4:  0,  R5:  1,  R0:  -3


Degree:  4


4 XEQ S/GSB A


Results:

3   (x^3)  R/S

6   (x^2)  R/S

-3   (x)   R/S

0   (constant)  R/S

1  (remainder)


x^3 - 3x^2 + 6x - 12 + 39 ÷ (x + 3)



Example 3:  [ x^3 - 42x^2 + 395x + 966 ] ÷ [ x - 21 ]


HP 32S:

A:  966,  B:  395,  C:  -42,  D:  1,  Z:  21


HP 15C:

R1:  966,  R2:  395,  R3:  -42,  R4:  1,  R0:  21


Degree:  3


3 XEQ S/GSB A:


Results:  

1   (x^2)  R/S

-21   (x)   R/S

-46   (constant)  R/S

0 (remainder)


x^2 - 21x - 46



Source


Hewlett Packard.  "Synthetic Division"   HP-65 Math Pac 1.   September 1974.   pp. 34-35, 99




Next blog post:  November 25, 2023


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Circular Sector: Finding the Radius and Angle

  Circular Sector: Finding the Radius and Angle Here is the problem: We are given the area of the circular segment, A, and th...