Post Reply 
(12C) Rational Fractions and Horner's Method
05-31-2020, 02:07 PM
Post: #1
(12C) Rational Fractions and Horner's Method
Here are three examples on how Horner's Method can be used to quickly calculate rational fractions with polynomials. The program code is presented for the HP 12C.

Horner's rule involves repeated factoring until the polynomial is represented as a multiplication of polynomials. The idea is to make it easier for some scientific calculators and four-function calculators to evaluate polynomials. Using Horner's Method for the generic cubic polynomial:

a * t^3 + b * t^2 + c * t + d
t * (a * t^2 + b * t + c) + d
t * (t * (a * t + b) + c ) + d

On an RPN keystroke calculator, such as the HP 12C a possible code would look like:

STO t (from the X stack)
RCL a
*
RCL b
+
RCL t
*
RCL c
+
RCL t
*
RCL d
+
RTN

For the code below, the HP 12C uses the following registers:

R0 = x

R1 = a
R2 = b
R3 = c
R4 = d
R5 = e
R6 = f
R7 = g

All but x need to be stored ahead of time before running (you can change the code to suit your needs, of course). x is entered before pressing [ R/S ].

For all of our numerical examples, I assigned the following values:

R0 = 1.72

R1 = 6
R2 = 3
R3 = 4
R4 = 5
R5 = 3
R6 = 1
R7 = 8

Example 1

(ax + b) / (cx^2 + dx + e) = (ax + b) / (x * (cx + d) + e)

Program (key: key code) - 16 steps

Code:
STO 0:  44, 0
RCL 1:  45,1
  *   :  20
RCL 2:  45, 2
  +  :  40
RCL 0:  45, 0
RCL 3:  45, 3
  *  :   20
RCL 4:  45, 4
  +  :  40
RCL 0:  45, 0
  *  :  20
RCL 5:  45, 5
  +  :  40
  ÷  :  10
GTO 00:  43, 33, 00

Result with variables stored above (FIX 4): 0.5684

Example 2

(ax + b) / (cx^3 + dx^ 2 + ex + f) = (ax + b) / (x * (x * (cx + d) + e) + f)

Program (key: key code) - 20 steps

Code:
STO 0:  44, 0
RCL 1:  45,1
  *   :  20
RCL 2:  45, 2
  +  :  40
RCL 0:  45, 0
RCL 3:  45, 3
  *  :   20
RCL 4:  45, 4
  +  :  40
RCL 0:  45, 0
  *  :  20
RCL 5:  45, 5
  +  :  40
RCL 0:  45, 0
  *  :  20
RCL 6:  45, 6
  +  :  40
  ÷  :  10
GTO 00:  43, 33, 00

Result with variables stored above (FIX 4): 0.3225

Example 3

(ax^2 + bx + c) / (dx^3 + ex^2 + fx + g)
= (x * (ax + b) + c) / (x * (x * (dx + e) + f) + g)

Program (key: key code) - 24 steps

Code:
STO 0:  44, 0
RCL 1:  45,1
  *   :  20
RCL 2:  45, 2
  +  :  40
RCL 0:  45, 0
RCL 3:  45, 3
  *  :   20
RCL 4:  45, 4
  +  :  40
RCL 0:  45, 0
  *  :  20
RCL 5:  45, 5
  +  :  40
RCL 0:  45, 0
  *  :  20
RCL 6:  45, 6
  +  :  40
RCL 0:  45, 0
  *   :  20
RCL 7:  45, 7
  +  :  40
  ÷  :  10
GTO 00:  43, 33, 00

Result with variables stored above (FIX 4): 0.6111

Blog Entry: http://edspi31415.blogspot.com/2020/05/h...rners.html
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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