Post Reply 
Polynomial with real coefficients —> array w/ real coeff
05-08-2023, 12:07 PM
Post: #10
RE: Polynomial with real coefficients —> array w/ real coeff
(05-05-2023 02:03 PM)Gil Wrote:  Very nice indeed.

Thanks.

Perhaps we could simplify your tests by a single one as follows:
« 0 { } —> N L
« DUP DEGREE 'N' STO N 1 <
IF
THEN 1 —>LIST
ELSE 0 N 1 -
START 0 HORNER 'L' STO+ DROP
NEXT L +
END AXL
»
»

And to have your program work without being asked if we want to go to real, add the following 3 instructions
-105 SF for real, PUSH to save the initial flags and POP to restore the initial flags:

« PUSH -105 SF 0 { } —> N L
« DUP DEGREE 'N' STO N 1 <
IF
THEN 1 —>LIST
ELSE 0 N 1 -
START 0 HORNER 'L' STO+ DROP
NEXT L +
END AXL POP
»
»

There is no limit to perfection.

Enabling the PUSH and POP instructions with -105 SF is a questionable idea, because in exact mode you can't get an array with exact polynomial coefficients. My original program gives an approximate result in approximate mode and an exact result in exact mode. With real coefficients of the polynomial in the approximate mode, the program does not ask about changing the mode.

I didn't think about any optimization of my program, but if you want, then let the next iteration be like this:
       


.hp  p2a2.hp (Size: 117 bytes / Downloads: 2)

.txt  p2a2.txt (Size: 153 bytes / Downloads: 6)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Polynomial with real coefficients —> array w/ real coeff - gor1060 - 05-08-2023 12:07 PM



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