From: jhmeyers@miu.edu (John H Meyers)
Newsgroups: comp.sys.hp48
Subject: Re: multiplying polynomials
Date: 14 Oct 1998 07:27:03 GMT
Organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
Lines: 107
Message-ID: <701jo7$pig$1@news.iastate.edu>
Reply-To: jhmeyers@miu.edu
NNTP-Posting-Host: vax1.mum.edu
Xref: republic.btigate.com comp.sys.hp48:17271

At this point, we know about some very large software libraries
which contain the ability to manipulate polynomials as a part
of their total capabilities, and we also know of a small (under 3K)
set of User-RPL programs (POLY on Goodies Disk #7 / Math)
made specifically to manipulate polynomials only,
which occupies much less memory.

But do we know how to perform polynomial operations using
*no* additional software (or memory) at all?

For example:

Suppose we have the following two polynomials on the stack:

'2*X^4-7*X^3+16*X^2-17*X+12'

'X^2-2*X+3'

To divide the first polynomial by the second:

-3 CF   [for symbolic results, in case a variable named 'X' exists]

/       [divide]

'X' 2 TAYLR   [convert the result to a 2nd degree polynomial]

The result is now seen to be '2*X^2-3*X+4'

You recognize the result, even though it appears backwards
and has 2.00000000002 as one of the coefficients.

We know to use 2 as the degree of the result polynomial,
by subtracting the degrees of the polynomials which we divided,
which is the mental price we have to pay to use no software at all;
besides this, we have to wait several long seconds for the HP48 to
"think," and we have to accept a slight roundoff error.

If you use the fairly small 'P\->L' program (below) in place of the
TAYLR command, the result appears instead as a list of coefficients,
in the normal expected order, because this program is just Wickes'
abbreviated version of TAYLR, skipping the final steps which
perform *user* operations (^, *, +) to construct the polynomial.

----------------------

  To make the creation and manipulation of polynomials easier,
  I reproduce here some short programs from past posts;
  these programs should work on any HP48S/SX/G/GX:

  %%HP: T(3); @ Kermit info: \-> means "right arrow" etc.

  @ L\->P Make a poly from a coefficient list and a variable name:

  @ Example:  { 2 -3 4 } 'X' ==> '2*X^2-3*X+4'

  \<< -3 CF 0 ROT 1 \<< 3 PICK ENDSUB NSUB - ^ * + \>> DOSUBS
      SWAP DROP \>>

  @ S/SX owners: Get DOSUBS from:
  @ <http://www.dejanews.com/getdoc.xp?AN=318142735&fmt=raw>

  @ BTW, this is just about how the HP48 does it internally anyway,
  @ both in the final stage of the TAYLR command, and in the
  @ G/GX "Solve poly" application form (using the SYMB key).

  @ Next program:

  @ P\->L Make a list of coefficients from a poly;
  @ additional arguments are the variable name and degree of poly
  @ (exactly the same arguments as for the TAYLR command).
  @ This program is a modified form of Bill Wickes' "pcoef"
  @ (not related to the newer G/GX command) from Goodies Disk #1.

  @ Example:  '2*X^2-3*X+4' 'X' 2 ==> { 2 -3 4 }

  \<< -3 CF 3 DUPN TYPE SWAP TYPE ROT
    TYPE 3 \->LIST { 0 6 9 } IF == THEN DUP 1 + \-> n
    \<< #18CEAh SYSEVAL @ COERCE
      SWAP #63A29h SYSEVAL @ dvarlsBIND
      #59373h SYSEVAL @ taylor (unsupported entry point)
      DROP #7497h SYSEVAL @ ABND
      1 n FOR m m ROLL COLCT NEXT n \->LIST \>> END \>>
  @ 184.5 bytes, #01B8h (*Verify* this checksum!)

The unsupported entry point is at the same address in rom rev R
as it was in the S/SX.  Verifying the checksum will help avoid
the dangers (e.g. all memory lost) of mistakes using SYSEVAL.

To see how the above improves upon the program found in the
POLY files on Goodies Disk #7, see this post:

'algebraic poly' ==> [ coefficients ]      [1998/05/14]
<http://www.dejanews.com/getdoc.xp?AN=353153809&fmt=raw>

Conversion between vectors (used for polynomial coefficients
for G/GX functions PROOT, PCOEF, PEVAL) and lists:

To make a vector from a list of numbers:  OBJ\->  \->ARRY

To make a list of numbers from a vector:  OBJ\->  EVAL  \->LIST

--------------

Does this make me a "polymath," and if not, what does?

-----------------------------------------------------------
With best wishes from:   John H Meyers   <jhmeyers@mum.edu>