05-24-2020, 09:54 PM (This post was last modified: 05-04-2023 09:13 PM by mchris.)
Post: #1
 mchris Junior Member Posts: 37 Joined: Apr 2020
Probably someone has done it before, but...
Inspired by a HP41C program I found for the quadratic formula that uses only the 4 level stack, no INPUTs, no extra registers, I thought maybe I could do something similar with the HP35s, despite that it doesn't have the register arithmetic with the stack registers. The program uses the equivalent formula -(b/2a)±SQRT((b/2a)^2-(c/a)). The fact there is only 2 terms makes it easier. I don't think it could be done with the (-b±SQRT(b^2-4ac))/2a formula. We press a ENTER b ENTER c XEQ Q and the 2 solutions, real or complex returned in X and Y registers. No INPUTs, no extra registers, just the stack, in just 29 steps.
Code:
Q001        LBL Q Q002        EQN REGZ Q003        / Q004        RDN Q005        X<>Y Q006        / Q007        2 Q008        / Q009        +/- Q010        ENTER Q011        X^2 Q012        RUP Q013        - Q014        X>=0? Q015        GTO Q021 Q016        +/- Q017        SQRT Q018        i Q019        * Q020        GTO Q022 Q021        SQRT Q022        ENTER Q023        ENTER Q024        EQN REGT Q025        + Q026        RDN Q027        - Q028        RUP Q029        RTN
05-25-2020, 11:23 AM
Post: #2
 PedroLeiva Member Posts: 230 Joined: Jun 2014
I tried this examples from HP 25 Application Program Manual:

ax2 + bx + c = 0

Examples
1 . X2 + X - 6 = 0
2. 3 X2 + 2x -1 = 0
3. 2X2 - 3x + 5 = 0

Solution
1. D = 6.25
Xl = -3.00
X2 = 2.00
2. D = 0.44
Xl = -1.00
X2 = 0.33
3. D = -1.94
Xl , X2 = 0.75 ± 1.39 i

For the first case with your program: x1= -3, x2= 3; the rest INVALID DATA
The program looks nice, but some corrections have to be made. Pedro
05-25-2020, 03:52 PM
Post: #3
 mchris Junior Member Posts: 37 Joined: Apr 2020
I tried the examples you mentioned and I get the correct answers. Did you key the program correctly?
05-25-2020, 04:19 PM (This post was last modified: 05-25-2020 04:25 PM by PedroLeiva.)
Post: #4
 PedroLeiva Member Posts: 230 Joined: Jun 2014
(05-25-2020 03:52 PM)mchris Wrote:  I tried the examples you mentioned and I get the correct answers. Did you key the program correctly?
Yes I did. Only one doubt, in steps 04 and 26, RDN code I got it by pressing blue shift (right arrow) and key coordinate 1,4 (first colum, forth row) -> E, wich shows in blue RND intaed of RDN. Maybe I am confused. Please confirm. Another option is to send an emulator file. Pedro
05-25-2020, 04:23 PM
Post: #5
 pinkman Senior Member Posts: 434 Joined: Mar 2018
(05-25-2020 03:52 PM)mchris Wrote:  I tried the examples you mentioned and I get the correct answers. Did you key the program correctly?

Same for me, it works fine.
05-25-2020, 04:25 PM
Post: #6
 pinkman Senior Member Posts: 434 Joined: Mar 2018
(05-25-2020 04:19 PM)PedroLeiva Wrote:
(05-25-2020 03:52 PM)mchris Wrote:  I tried the examples you mentioned and I get the correct answers. Did you key the program correctly?
Yes I did. Only one doubt, in steps 04 and 26, RDN code I got it by pressing blue shift (right arrow) and key coordinate 1,4 (first colum, forth row) -> E, wich shows in blue RND intaed of RDN. Maybe I am confused. Please confirm. Pedro

RDN stands for Register Down: R↓
RUP stands for Register Up: R↑
05-25-2020, 04:49 PM (This post was last modified: 05-26-2020 12:11 PM by PedroLeiva.)
Post: #7
 PedroLeiva Member Posts: 230 Joined: Jun 2014
(05-25-2020 04:25 PM)pinkman Wrote:
(05-25-2020 04:19 PM)PedroLeiva Wrote:  Yes I did. Only one doubt, in steps 04 and 26, RDN code I got it by pressing blue shift (right arrow) and key coordinate 1,4 (first colum, forth row) -> E, wich shows in blue RND intaed of RDN. Maybe I am confused. Please confirm. Pedro

RDN stands for Register Down: R↓
RUP stands for Register Up: R↑
Great, TYVM. It Works perfect now. Pedro
05-04-2023, 09:02 PM
Post: #8
 mchris Junior Member Posts: 37 Joined: Apr 2020
RE: (35s 42s 50g) Quadratic formula
The same logic can be ported to 42s/DM42 and 50g.
42s/DM42
Code:
01▸LBL "QE" 02 RCL ST Z 03 +/- 04 STO÷ ST Z 05 ÷ 06 X<>Y 07 2 08 ÷ 09 STO ST Z 10 STO ST T 11 X↑2 12 + 13 SQRT 14 STO- ST Z 15 + 16 END
50g
Code:
« 3 PICK / 3 ROLLD SWAP / 2 / NEG DUP SQ ROT – √ DUP2 + EVAL 3 ROLLD – EVAL »
05-04-2023, 09:59 PM (This post was last modified: 05-04-2023 09:59 PM by Joe Horn.)
Post: #9
 Joe Horn Senior Member Posts: 2,009 Joined: Dec 2013
RE: (35s 42s/DM42 50G) Quadratic formula
This is "cheating" but the 50g can do it in two steps:

<< →V3 PROOT >>

BYTES: 18 #75EEh

<0|ɸ|0>
-Joe-
05-04-2023, 10:57 PM
Post: #10
 John Keith Senior Member Posts: 1,039 Joined: Dec 2013
RE: (35s 42s/DM42 50G) Quadratic formula
(05-04-2023 09:02 PM)mchris Wrote:  50g
Code:
« 3 PICK / 3 ROLLD SWAP / 2 / NEG DUP SQ ROT – √ DUP2 + EVAL 3 ROLLD – EVAL »

On the HP 49 and HP 50, 3 PICK can be replaced by PICK3, and 3 ROLLD can be replaced by UNROT. Each of those changes saves 2.5 bytes and a small amount of time.

Also, on the 28 and 48, ROT ROT is faster than 3 ROLLD. This only matters inside a loop but it may be useful to know.
05-05-2023, 07:37 AM
Post: #11
 mchris Junior Member Posts: 37 Joined: Apr 2020
RE: (35s 42s/DM42 50G) Quadratic formula
Thanks, I'm beginner RPL user.
 « Next Oldest | Next Newest »

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