challenge HP50G RPL
|
09-24-2016, 04:02 AM
Post: #1
|
|||
|
|||
challenge HP50G RPL
Hello
Reduce the number of orders for the algorithm roots quadratic equation Code: « |
|||
09-24-2016, 07:36 AM
Post: #2
|
|||
|
|||
RE: challenge HP50G RPL
How about two instructions?
« →V3 PROOT » <0|ɸ|0> -Joe- |
|||
09-24-2016, 01:04 PM
(This post was last modified: 09-26-2016 01:10 AM by compsystems.)
Post: #3
|
|||
|
|||
RE: challenge HP50G RPL
(09-24-2016 07:36 AM)Joe Horn Wrote: How about two instructions? « →V3 PROOT » 'QUADRATIC1' STO 1. -3. 2. QUADRATIC1 returns [1, 2] // ok 1. 2. 3. QUADRATIC1 returns [(-1.,1.41421356238) (-1., -1.41421356238)] // ok 'A' 'B' 'C' QUADRATIC1 returns "→V3 ERROR" =( with local vars & 8 instructions Code: « with 12 instructions Code: « /!\ First value, different from zero 1. -3. 2. QUADRATIC2 returns 1 2 // ok 1. 2. 3. QUADRATIC2 returns (-1.,1.41421356238) (-1., -1.41421356238) // ok (1,0) (-1,-1) (0,1) QUADRATIC2 returns (1, 0) (0, 1) 'a' 'b' 'c' QUADRATIC2 EVAL returns '(-b+√(c*-4.*a+SQ(b)))/(a*2.)' '(-b-√(c*-4.*a+SQ(b)))/(a*2.)' /!\ but the idea is to use the formula '-B±√(B^2-4*A*C)/2*A' with RPN commands (SWAP DUP ROLL ROLLD etc), also without unused local variables or globales and EVAL as in the first post with the code of firts post ... 'QUADRATIC' STO 1. -3. 2. QUADRATIC returns 1 2 // ok 1. 2. 3. QUADRATIC returns (-1.,1.41421356238) (-1., -1.41421356238) // ok (1,0) (-1,-1) (0,1) QUADRATIC returns (1, 0) (0, 1) 'a' 'b' 'c' QUADRATIC returns '(-b+√(c*-4.*a+SQ(b)))/(a*2.)' '(-b-√(c*-4.*a+SQ(b)))/(a*2.)' PD: Someone who can port it to RPN HP-PRIME Thanks |
|||
09-24-2016, 05:15 PM
Post: #4
|
|||
|
|||
RE: challenge HP50G RPL
Code: « PICK3 / UNROT 16 instructions, 50 bytes. |
|||
09-24-2016, 10:20 PM
(This post was last modified: 09-25-2016 03:56 PM by compsystems.)
Post: #5
|
|||
|
|||
RE: challenge HP50G RPL
It works fine, but it seems you're using another formula? and not '-B±√(B^2-4*A*C)/2*A'
Someone break to lower the Record of Gerson =), SysRPL is accepted Code: « 1. -3. 2. QUADRATIC3 returns 1 2 // ok 1. 2. 3. QUADRATIC3 returns (-1.,1.41421356238) (-1., -1.41421356238) // ok (1,0) (-1,-1) (0,1) QUADRATIC3 returns (1, 0) (0, 1) 'A' 'B' 'C' QUADRATIC3 EVAL returns Code: 'B/A/-2-1/(2*ABS(A))*√-(4*C*A-B^2)' |
|||
09-25-2016, 08:14 AM
(This post was last modified: 09-25-2016 08:24 AM by peacecalc.)
Post: #6
|
|||
|
|||
RE: challenge HP50G RPL
Hello all,
Code:
I tried the method of Joe Horn, and... it works. Even if the solutions are complex. The three coefficients have to be integer or real numbers, then everything is fine. Thank you Joe, for your lucid two command gem! |
|||
09-25-2016, 03:40 PM
(This post was last modified: 09-26-2016 12:57 AM by compsystems.)
Post: #7
|
|||
|
|||
RE: challenge HP50G RPL
PROOT It is a very primitive command (HP48 series) only accepts real an complex coefficients, does not allow symbolic coefficients, the code « →V3 PROOT » fails with symbolic and complex coefficients
Code: « →V3 PROOT » 'QUADRATIC1' STO 1. -3. 2. QUADRATIC1 returns [1, 2] // ok 1. 2. 3. QUADRATIC1 returns [(-1.,1.41421356238) (-1., -1.41421356238)] // ok 'A' 'B' 'C' QUADRATIC1 returns "→V3 ERROR Bad Argument Type" =( (1,0) (-1,-1) (0,1) QUADRATIC1 returns "→V3 ERROR Bad Argument Type" =( Now are 4 instructions or objects with PROOT Code:
1. -3. 2. QUADRATIC4 returns [1, 2] // ok 1. 2. 3. QUADRATIC4 returns [(-1.,1.41421356238) (-1., -1.41421356238)] // ok (1,0) (-1,-1) (0,1) QUADRATIC4 returns [(1, 0) (0, 1)] // OK Using a more powerful predefined function SOLVE CAS, real/complex and/or symbolic entry 12 instructions or objects Code: « or only 6 instructions or objects, perhaps the minimal instructions for full function (HP50) to get the roots of a quadratic equation, from the coefficients in stack Code: « 1. -3. 2. QUADRATIC6 returns { 'X=1' 'X=2' }// ok 1. 2. 3. QUADRATIC6 returns { 'X=(-1, -1.41421356237)' 'X=(-1, 1.41421356237)' } // ok 'A' 'B' 'C' QUADRATIC6 returns { 'X=-(b+√-(4*c*a-b^2.))/(2*a)' 'X=-(b-√-(4*c*a-b^2.))/(2*a)' } // ok (1,0) (-1,-1) (0,1) QUADRATIC6 { 'X=(7.5E-15,1.)' 'X=(1.,-1.E-14)' } ~ 'X=(0,1)' 'X=(1,0)' // ok |
|||
09-25-2016, 05:03 PM
Post: #8
|
|||
|
|||
RE: challenge HP50G RPL
(09-25-2016 08:14 AM)peacecalc Wrote: Hello all, As you say, that won't accept complex coefficients. Another simple program that takes coefficients from the stack: Code:
This won't accept complex coefficients either. Also, it won't find complex solutions. |
|||
09-25-2016, 10:41 PM
Post: #9
|
|||
|
|||
RE: challenge HP50G RPL
is better to use the commands 3 ->LIST AXL
Code: « (1,0) (-1,-1) (0,1) // == 1 -1-i, i QUADRATIC6 returns { 'X=(7.5E-15, 1.)' 'X=(1., -1.E-14)' } == { 'X=i' 'X=1' } |
|||
09-26-2016, 12:46 AM
Post: #10
|
|||
|
|||
RE: challenge HP50G RPL | |||
09-26-2016, 01:51 AM
Post: #11
|
|||
|
|||
RE: challenge HP50G RPL
(09-26-2016 12:46 AM)Juan14 Wrote:(09-24-2016 05:15 PM)Gerson W. Barbosa Wrote: Additionally this lowers the byte count to 47.5. A potential problem with LASTARG might be the status of flag -55, but I don't think we should worry about that on the 50g, where there is plenty of RAM and LASTARG is always enabled. (09-26-2016 12:46 AM)Juan14 Wrote: Do you have the code for the HP 42s? http://www.hpmuseum.org/forum/thread-1156.html |
|||
09-26-2016, 11:56 PM
Post: #12
|
|||
|
|||
RE: challenge HP50G RPL
http://www.hpmuseum.org/forum/thread-1156.html
[/quote] Thank you Gerson, I'll try it in the free42. |
|||
10-05-2016, 12:28 AM
(This post was last modified: 10-05-2016 12:46 AM by compsystems.)
Post: #13
|
|||
|
|||
RE: challenge HP50G RPL
hp48gx: 18 objects minimum (with→LIST cmd). Code by: ElkAr
Code: ≪ 2 →LIST SWAP / EVAL SWAP -2 / DUP SQ ROT - √ DUP2 + ROT ROT - ≫ hp48gx: 19 objects minimum. Code by: Gerson W. Barbosa Code: « 3 PICK / 3 ROLLD hp50g: 16 objects minimum. Code by: Gerson W. Barbosa Code: « PICK3 / UNROT What is the minimum number of objects in other RPN calculators? |
|||
10-05-2016, 04:13 PM
Post: #14
|
|||
|
|||
RE: challenge HP50G RPL
(10-05-2016 12:28 AM)compsystems Wrote: What is the minimum number of objects in other RPN calculators? Creo que quieres decir otras calculadoras RPL. I think you mean other RPL calculators :-) Regarding RPN calculators, nothing beats the wp34s: SLVQ Nice saving of one command by using →LIST and EVAL in the HP-48 code above! Regards, Gerson. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)