Post Reply 
(42S) Polynomial Operations
01-11-2019, 01:37 PM
Post: #2
RE: (42S) Polynomial Operations
Delving into my archives again..

The following will take a vector with the coefficients in Y and x in X

Y: [ an an-1 ... a1 a0 ]
X: x

and calculate P(x), P'(x) and P"(x) simultaneously:

Code:
00 { 51-Byte Prgm }
01▸LBL "P3"
02 ENTER
03 -
04 STO ST Z
05 X<>Y
06 EDIT
07 ENTER
08 GTO 00
09▸LBL 03
10 R↓
11 X<> ST Z
12 LASTX
13 ×
14 X<>Y
15 STO+ ST Y
16 LASTX
17 ×
18 R↑
19 STO+ ST Y
20 LASTX
21 ×
22 RCLEL
23 STO+ ST Y
24▸LBL 00
25 J+
26 FC? 77
27 GTO 03
28 J-
29 EXITALL
30 R↑
31 STO+ ST X
32 R↓
33 END

So, for your example polynomial P(x) = 2*x^3 - x^2 + 5*x + 7
Create a 1x4 matrix [2 -1 5 7]
put -3 on the stack and execute P3 to get

T: -38
Z: 65
Y: -71
X: [2 -1 5 7]

P(-3) = -71
P'(-3) = 65
P"(-3) = -38

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (42S) Polynomial Operations - Werner - 01-11-2019 01:37 PM
RE: (42S) Polynomial Operations - Dieter - 01-12-2019, 08:41 AM



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