Post Reply 
Generating a Polynomial Given Its Roots
12-23-2018, 08:15 AM (This post was last modified: 12-23-2018 09:28 AM by Thomas Klemm.)
Post: #3
RE: Generating a Polynomial Given Its Roots
If you really only want to do that up to order 4 you can use:

Code:
LBL "POLY4"
CHS   ENTER↑   X<> 00   ST+ 00
RCL Y   *   X<> 01   ST+ 01
RCL Y   *   X<> 02   ST+ 02
RCL Y   *   X<> 03   ST+ 03
END

Example:

CLRG
-3 XEQ "POLY4"
3 R/S
4 R/S
6 R/S

The coefficients of the polynomial can then be found in the registers:

R 00:  -10.0000
R 01:   15.0000
R 02:   90.0000
R 03: -216.0000



But we can do better than loop unrolling and use for the general case:

Code:
01 LBL "POLY"
02 CHS
03 ENTER↑
04 GTO 01
05 LBL 00
06 RCL Y
07 *
08 LBL 01
09 X<> IND Z
10 ST+ IND Z
11 ISG Z
12 GTO 00
13 RDN
14 RDN
15 FRC
16 1 E-3
17 +
18 END

Example:

CLRG
CLST
-3 XEQ "POLY"
3 R/S
4 R/S
6 R/S

The coefficients of the polynomial can again be found in the registers:

R 00:  -10.0000
R 01:   15.0000
R 02:   90.0000
R 03: -216.0000


In both cases the leading coefficient is always 1.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Generating a Polynomial Given Its Roots - Thomas Klemm - 12-23-2018 08:15 AM



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