(42S) Polynomial Operations
|
01-11-2019, 04:59 AM
Post: #1
|
|||
|
|||
(42S) Polynomial Operations
Note: These programs presented in today's blog are can also be programmed on the Free42 app and the DM 42. The default setting, 25 memory registers, is assumed to be set. The programs are written use R24 as a counter.
This program uses indirect storage (R24). The maximum order is 23. HP 42S Program SPOLY This program asks for the order of a polynomial and then asks the user to store the coefficients. The order of registers are coefficients of powers of x in descending order from n to 0. For example, for a cubic polynomial, the coefficients are stored as such: R01 = coefficient of x^3 R02 = coefficient of x^2 R03 = coefficient of x R04 = constant coefficient Program: Code:
Keystrokes: [ XEQ ] (SPOLY) "ORDER?" 3 [ R/S ] "X↑3.0000=" 2 [R/S] "X↑2.0000=" 1 [ +/- ] [R/S] "X↑1.0000=" 5 [R/S] "X↑0.0000=" 7 [R/S] "DONE" Results R01 = 2.0000 R02 = -1.0000 R03 = 5.0000 R04 = 7.0000 HP 42S Program HORNER The HORNER evaulates the polynomial p(x). The assumes that the order of registers are coefficients of powers of x in descending order from n to 0. The user is asked about the order of the polynomial and the value of x. Program: Code:
Example: Let p(x) be the polynomial, p(x) = 2*x^3 - x^2 + 5*x + 7 Calculate p(-3). The coefficients are have already been stored (from last example). R01 = 2.0000 R02 = -1.0000 R03 = 5.0000 R04 = 7.0000 Keystrokes: [XEQ] (HORN) "X?" 3 [ +/- ] [ R/S ] "ORDER?" 3 [ R/S ] Result: -71.0000 HP 42S Program DX_PX This program calculates coefficients of the derivative of the polynomial p(x), using the form: d/dx x^n = n * x^(n-1) The order of registers are coefficients of powers of x in descending order from n to 0. Program: Code:
Example: Calculate the derivative of p(x) = 2*x^3 - x^2 + 5*x + 7. Assume that coefficients from the previous example. Keystrokes: [ XEQ ] (DX_PX) "ORDER?" 3 [R/S] Results: "X↑2.0000=" 6.0000 [R/S] "X↑1.0000=" -2.0000 [R/S] "X↑0.0000=" 5.0000 [R/S] "DONE" dp/dx = 6*x^2 - 2*x + 5 Registers: R1 = 6.0000 R2 = -2.0000 R3 = 5.0000 R4 = 0.0000 Link to blog entry: https://edspi31415.blogspot.com/2019/01/...tions.html |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(42S) Polynomial Operations - Eddie W. Shore - 01-11-2019 04:59 AM
RE: (42S) Polynomial Operations - Werner - 01-11-2019, 01:37 PM
RE: (42S) Polynomial Operations - Albert Chan - 01-11-2019, 03:51 PM
RE: (42S) Polynomial Operations - rprosperi - 01-12-2019, 12:27 AM
RE: (42S) Polynomial Operations - Dieter - 01-12-2019, 08:41 AM
RE: (42S) Polynomial Operations - Thomas Klemm - 01-12-2019, 06:48 AM
RE: (42S) Polynomial Operations - rprosperi - 01-12-2019, 02:20 PM
|
User(s) browsing this thread: 1 Guest(s)