Post Reply 
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:
«
  @ HALT
  @  1. -3. 2.
  @  1. 2. 3.
  @  A B C
  -4 *      @ Multiplica por -4 el primer nivel → A B -4*C
  PICK3 *   @ copia nivel 3 (A) al nivel 1, y luego lo multiplica con el nivel 2 → A B -4*C A → A B -4*C*A
  OVER SQ + @ copia nivel 2 (B) a 1, lo eleva al cuadrado y suma → A B -4*C*A+B^2
  √         @ saca raíz cuadrada → A B '√(B^2-4*A*C)'
  UNROT     @ Sube al 3cer nivel → '√(B^2-4*A*C)' A B
  SWAP 2 *  @ Invierte y multiplica * 2  → '√(B^2-4*A*C)' B 2*A
  SWAP NEG  @ Invierte y negativo → '√(B^2-4*A*C)' 2*A -B
  DUP2      @ duplica los dos primeros niveles → '√(B^2-4*A*C)' 2*A -B 2*A -B
  5 PICK +  @ copia nivel 5 (√B^2-4*A*C) a 1 y suma → '√B^2-4*A*C' 2*A -B 2*A '-B+√(B^2-4*A*C)'
  SWAP /    @ Invierte y divide → '√B^2-4*A*C' 2*A -B '-B+√(B^2-4*A*C)/2*A'
  4 ROLLD   @ Sube al 4to nivel → '-B+√(B^2-4*A*C)/2*A' '√(B^2-4*A*C)' 2*A -B
  ROT       @ baja el 3cer nivel al 1er nivel → '-B+√(B^2-4*A*C)/2*A' 2*A -B '√(B^2-4*A*C)'
  - SWAP /  @ resta, invierte y divide → '-B+√(B^2-4*A*C)/2*A' '-B-√(B^2-4*A*C)/2*A'
»

the previous code have 26 instructions
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
challenge HP50G RPL - compsystems - 09-24-2016 04:02 AM
RE: challenge HP50G RPL - Joe Horn - 09-24-2016, 07:36 AM
RE: challenge HP50G RPL - compsystems - 09-24-2016, 01:04 PM
RE: challenge HP50G RPL - Juan14 - 09-26-2016, 12:46 AM
RE: challenge HP50G RPL - Juan14 - 09-26-2016, 11:56 PM
RE: challenge HP50G RPL - compsystems - 09-24-2016, 10:20 PM
RE: challenge HP50G RPL - peacecalc - 09-25-2016, 08:14 AM
RE: challenge HP50G RPL - compsystems - 09-25-2016, 03:40 PM
RE: challenge HP50G RPL - compsystems - 09-25-2016, 10:41 PM
RE: challenge HP50G RPL - compsystems - 10-05-2016, 12:28 AM



User(s) browsing this thread: