From: Joe Veazey on
"John H Meyers" <jhmeyers(a)nomail.invalid> wrote in
news:op.teng5px1nn735j(a)w2kjhm.ia.mum.edu:

> My 48G has neither COLLECT nor EXPAND
> (tho it does have COLCT and EXPAN :)
>
> [r->] [OFF]
>

Um, yes, I was imprecise in saying COLLECT and EXPAND, but you knew what I
meant anyway....

From: Joe Veazey on
Joe Veazey <nobody(a)nowhere.nohow> wrote in
news:Xns9825EB32E90ABSleazeyWombat(a)207.115.17.102:

>
> I haven't quite tested utterly thouroughly yet, so I'll post it later.
>

Here's what I came up with on my own.

# Stack arg is the single variable polynomial algebraic.
# All coefficients of the polynomial must be numeric, (real, or complex).
# Non-numeric coefficients are not supported!
#
# Polynomial variable matches name stored in 'VX'.
# For example, '1.1*X^2 + 2.2*X + 1.4', iff VX=='X';
# or, '1.1*Z^2 + (1.4, -3.)', iff VX=='Z'.
# Result left on stack will be the polynomial coefficient array,
# in descending order of powers of X.
# Results from the above 2 examples would be
# [1.1 2.2 1.4]; or [1.1 0. (1.4 -3.)]
#
# The basic algorithm is to repeatedly use HORNER to evaluate the
# polynomial at X=0, by dividing it by (x-0.). The result is the
# constant term of the current polynomial.
# HORNER also leaves the quotient on the stack, that is, the
# polynomial reduced by 1 degree by the division.
# On the next pass thru the loop, the reduced polynomial is
# reused. The polynomial is reduced by 1 degree each time thru the loop,
# until the only thing left is a numeric term; which terminates the loop,
# and is incidentally, the coefficient of the highest power of the
# polynomial.
/<< -105. FS? # get state of approximate mode flag
-105. SF # make sure approximate is on for HORNER
SWAP { } SWAP # Initialize empty list of poly coeffs.
WHILE
DUP # save a copy of algebraic on stack
TYPE DUP # get the type and make a copy on stack
9. == # algebraic?
SWAP # swap test result and saved type value
6. == # only a variable name?
OR # repeat while either is true
REPEAT
0. HORNER # divide poly by (X-0.)
4. ROLL # remainder (new constant term)
+ # add new constant term to front of stack
3. ROLLD DROP # re-order stack; drop uneeded divisor 0.
END
SWAP + AXL # final term to front of list
SWAP # get saved flag value
IF NOT # was flag value changed?
THEN -105. CF # yes, restore it
END
/>>


I welcome any improvements, comments, or criticisms.
From: Virgil on
In article <Xns9826A7149D427coloneljohnnymars(a)216.168.3.44>,
Joe Veazey <Sleazey(a)station2.iapetus.jupiter.sol> wrote:

> Joe Veazey <nobody(a)nowhere.nohow> wrote in
> news:Xns9825EB32E90ABSleazeyWombat(a)207.115.17.102:
>
> >
> > I haven't quite tested utterly thouroughly yet, so I'll post it later.
> >
>
> Here's what I came up with on my own.
>
> # Stack arg is the single variable polynomial algebraic.
> # All coefficients of the polynomial must be numeric, (real, or complex).
> # Non-numeric coefficients are not supported!
> #
> # Polynomial variable matches name stored in 'VX'.
> # For example, '1.1*X^2 + 2.2*X + 1.4', iff VX=='X';
> # or, '1.1*Z^2 + (1.4, -3.)', iff VX=='Z'.
> # Result left on stack will be the polynomial coefficient array,
> # in descending order of powers of X.
> # Results from the above 2 examples would be
> # [1.1 2.2 1.4]; or [1.1 0. (1.4 -3.)]
> #
> # The basic algorithm is to repeatedly use HORNER to evaluate the
> # polynomial at X=0, by dividing it by (x-0.). The result is the
> # constant term of the current polynomial.
> # HORNER also leaves the quotient on the stack, that is, the
> # polynomial reduced by 1 degree by the division.
> # On the next pass thru the loop, the reduced polynomial is
> # reused. The polynomial is reduced by 1 degree each time thru the loop,
> # until the only thing left is a numeric term; which terminates the loop,
> # and is incidentally, the coefficient of the highest power of the
> # polynomial.
> /<< -105. FS? # get state of approximate mode flag
> -105. SF # make sure approximate is on for HORNER
> SWAP { } SWAP # Initialize empty list of poly coeffs.
> WHILE
> DUP # save a copy of algebraic on stack
> TYPE DUP # get the type and make a copy on stack
> 9. == # algebraic?
> SWAP # swap test result and saved type value
> 6. == # only a variable name?
> OR # repeat while either is true
> REPEAT
> 0. HORNER # divide poly by (X-0.)
> 4. ROLL # remainder (new constant term)
> + # add new constant term to front of stack
> 3. ROLLD DROP # re-order stack; drop uneeded divisor 0.
> END
> SWAP + AXL # final term to front of list
> SWAP # get saved flag value
> IF NOT # was flag value changed?
> THEN -105. CF # yes, restore it
> END
> />>
>
>
> I welcome any improvements, comments, or criticisms.

Your program appears to use only hp48 compatible commands.
I think one can do a bit better on 49's and 50's using some 49 commands
\<<
{} @ list to hold coefficients
SWAP
WHILE
DUP O SAME NOT@ while quotient not 0
REPEAT
RCLVX @ assumes VX variable
IFERR @ handles error when
DIV2 @ DIV2 has real number
THEN @ as dividend
DROP O SWAP
END
ROT + SWAP @ prepends coefficient to list
END
DROP
AXL @ converts list to vector.
\>>

NOTE: DIV2 does quotient and remainder polynomial division.
It assumes a dividend polynomial on level 2, a divisor polynomial on
level 1, and the polynomial variable in VX in the CASDIR directory, and
returns the quotient polynomial on level 2 and remainder polynomial on
level 1
BUT if the dividend on level 2 is a real number, DIV2 causes an error,
which is handled by the IFERR in the program.
If you only want to work in exact mode with exact coefficients, you can
replace all of

IFERR DIV2
THEN DROP O SWAP
END

by a simple

DIV2 .
From: John H Meyers on
On Sat, 19 Aug 2006 15:52:49 -0500, Joe Veazey wrote:

> I did have one that worked fine on the HP-48G

Here are more Polynomial -> Array functions for HP48 *only*
(because TAYLR lost its original finesse in the new CAS :)

http://groups.google.com/group/comp.sys.hp48/msg/b80bf42420d067d7?dmode=source


Array -> Polynomial are trivial, e.g. for HP48G/49G/50G:

Args:

{ 2 3 5 } Coefficients (symbolic okay), use AXL on array input
'X' Variable name

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

On the 49G/50G, [array] 'X' \<< PEVAL EVAL \>> works
(but the CAS springs into "annoyance mode" if any reals are seen :)

[r->] [OFF]
From: John H Meyers on
On Tue, 22 Aug 2006 17:27:09 -0500:

> On the 49G/50G, [array] 'X' \<< PEVAL EVAL \>> works
> (but the CAS springs into "annoyance mode" if any reals are seen :)

Could also be: [array] 'X' \<< PEVAL EXPAND \>>
(but now the CAS gets "annoying" even for integers :)

Extract Coeffs of polynoms [by "Beto"] 2000/09/18
http://groups.google.com/group/comp.sys.hp48/msg/1dbd2f19454161db

[r->] [OFF]
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: hp 50g rom
Next: HP 50g + ROM 2.09