(71B) Polynomial Coefficients from a given list of roots -- for the HP-71B
|
12-26-2018, 12:11 AM
(This post was last modified: 06-18-2021 08:39 PM by Gene.)
Post: #1
|
|||
|
|||
(71B) Polynomial Coefficients from a given list of roots -- for the HP-71B
Here is an HP-71B program that converts the list of roots into the coefficients of the polynomial that has these roots. The DATA statement(s) contain the number of roots, followed by the list of roots. This data can appear on one or more DATA statements. Run the program to view the coefficients along with their associated power of X:
Code: 10 REM POLY COEFFS FROM ROOTS |
|||
06-13-2021, 03:28 PM
(This post was last modified: 06-13-2021 03:58 PM by C.Ret.)
Post: #2
|
|||
|
|||
RE: Polynomial Coefficients from a given list of roots -- for the HP-71B
HI,
Here is the same task without DATA/READ structure, only one FOR TO NEXT loop and a more convivial interface for output and input : 10 DESTROY A,D,I,R @ OPTION BASE 0 @ DIM A(29) @ A(0)=1 12 INPUT "Add root x.=";R @ D=D+1 14 FOR I= D TO 0 STEP -1 @ IF I>0 THEN A(I)=A(I-1)-R*A(I) ELSE A(0)=-R*A(0) 16 GOSUB 20 @ NEXT I @ PAUSE @ GOTO 12 20 IF A(I)>0 AND I<D THEN DISP "+"; ELSE IF A(I)<0 THEN DISP "-"; 22 IF A(I)=0 THEN RETURN ELSE IF ABS(A(I))#1 OR I=0 THEN DISP STR$(ABS(A(I)); 24 IF I<1 THEN RETURN ELSE DISP "x"; @ IF I>1 THEN DISP "^"&STR$(I); 26 RETURN Usage : New polynomials coefficients are deduce at each step by multiplying the previous polynomial by (x-r). This increase its degree by one unit (variable D indicate polynomial's degree)
Example 1: Code: > (RUN) Code: x^3-6x^2+11x-6 (RUN) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)