The following warnings occurred:
Warning [2] Undefined array key 12459 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12461 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12484 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12485 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12492 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12500 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12504 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12528 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12535 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12538 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12543 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12547 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12484 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12500 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12547 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12528 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 12543 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





Programming Challenge



#10

Here is a programming challenge for the RPN addicts.
Write a program that takes as input in the stack:

z: a

y: b

x: c

and outputs

y: (-b - sqrt(b^2 - 4ac))/(2a)

x: (-b + sqrt(b^2 - 4ac))/(2a)

(the solutions to the 2nd degree equation, assuming that they are real).

The program should use only the stack and the Last_x register, but no other registers.
The solution should be developed for the 11C or 15C or 32SII architecture (i.e., no HP48 extensions allowed, and in particular, no PICK instructions).

I have a 35-ish step solution that uses Last_x.
The solution is not particularily optimized, and I am not sure that Last_x is really needed.

The contest is open for the shortest solution,
and for a solution without Last_x!

Luca


#11

Hello;

I wrote this based in an example given at the HP42S Programming Examples and Technics (p.75), which is based in the original for the HP41, published in one HP Key Notes V6 N2, p. 14. The small routine was created by Paul Baker (Stillwaker, Oklahoma) and I include it's original in here, too. This program changed my way of searching for a solution. Both roots are found AND complex solution was available (flag 0 set). This is the original listing:

LBL SOL
X<> Z
ST/ Z
/
-2
/
ENTER^
ENTER^
X^2
R^
CF 00
X>Y?
SF 00
-
ABS
SQRT
ST- Z
X<>Y
FC? 00
+
.END.
Just enter a, b and c and run it. If flag 0 is set, complex results.
This is my (morphed) listing for the HP11C. Enter a, b and c and run it.
ENTER
R^
÷
R^
LASTx
÷
2
CHS
÷
ENTER
ENTER
x^2
R^
-
SF 0
X<0
CF 0
ABS
sqrt
ENTER
R^
x<>y
-
LASTx
R^
F? 0
+
If there is nothing wrong, it should work, even for complex results (real in X, imaginary in Y. Or the opposite...). In this program, flag 0 is clear for complex results. It is 27 steps long (29 if LBL and RTN or R/S are added), but I believe wizards in here will make it look too long...

My R$0.25


#12

Hello;

The program works fine without one step.

ENTER
R^
÷
R^
LASTx
÷
2
CHS
÷
ENTER
ENTER
x^2
R^
-
SF 0
X<0
CF 0
ABS
sqrt
ENTER <- this ENTER can be removed
R^
x<>y
-
LASTx
R^
F? 0
+

Anything else is kept. Now it is 26 step long plus LBL and RTN or R/S.

#13

Very nice solutions!
Luca

#14

Greetings...

I whipped this out in about 10 minutes. It is part elegent and part brute force (i.e. I'm sure it can be improved), and is for the HP-42S. I don't have the other models. Sorry.

01 LBL "QE"
02 RCLx ST Z
03 4
04 x
05 X<>Y
06 ENTER
07 X^2
08 RCL- ST Z
09 SQRT
10 R^ [ROLL UP]
11 -2
12 x
13 X<>Y
14 STO- ST Z
15 STO+ ST T
16 R\ [ROLL DOWN]
17 STO/ ST Z
18 /
19 END

Fred


#15

Well, it was in columns when I typed it. Let's try it again. BTW...how did you get two fonts in your messages? Are there some codes I need to know?

01 LBL "QE"

02 RCLx ST Z

03 4

04 x

05 X<>Y

06 ENTER

07 X^2

08 RCL- ST Z

09 SQRT

10 R^ [ROLL UP]

11 -2

12 x

13 X<>Y

14 STO- ST Z

15 STO+ ST T

16 R\ [ROLL DOWN]

17 STO/ ST Z

18 /

19 END

Fred


#16

Hello;

try Advanced Format Technics http://www.hpmuseum.org/artfmt.htm. Your listing would be like this:

01 LBL "QE"
02 RCLx ST Z
03 4
04 x
05 X<>Y
06 ENTER
07 X^2
08 RCL- ST Z
09 SQRT
10 R^ [ROLL UP]
11 -2
12 x
13 X<>Y
14 STO- ST Z
15 STO+ ST T
16 R\ [ROLL DOWN]
17 STO/ ST Z
18 /
19 END

Just place a [pre] in the start of it and a [/pre] at its end.
Cheers.


#17

Luiz....

Thanks. Now I remember having seen that before. Must have been a "senior moment" (and I'm only 43).

Fred


#18

Hello;

I'm about to believe that, with some exceptions, we're most at the average of 35-40. I'm 40. So, please, having a "senior moment" is almost like "carpe diem". At least for us, 40's. (as long as it doesn't take all day long...)

Cheers.

#19

Some better solutions have already been posted, anyway
here is my version for the HP32SII and the HP15C
(for real solutions only):

ENTER
R^
/
CHS
R^
LASTx
/
2
/
CHS
X^2
LASTx
ENTER
Rv
Rv
+
SQRT
-
x<>y
LASTx
+


Cannot resist to write it for the HP41, too:

ENTER
R^
ST/ T
/
CHS
R^
2
/
CHS
STO Z
STO T
X^2
+
SQRT
-
X<>Y
LASTX
+
#20

I am not really formally trained in math, and haven't sat in a algebra or math classroom since high school, but, are you trying to solve a quadratic equation by setting it (=0) and then entering the numerical coefficient's without having to write a parse scan routine? Just wanted to make sure I understand.


#21

Hello;

the basic challenge is: having a, b and c from

ax^2+bx+c=0  (y=0)
what is the shortest routine that gives us x1 and x2 that solve the equation. The programs herein should get a, b and c from the stack and return x1 and x2:
  ---   T     ---
c Z ---
b Y -> x2
a X -> x1
--- L -> (if not used, better)
That`s what Luca proposed.

Cheers.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HHC 2013 RPN Programming Challenge - Final Thought Jeff O. 7 2,309 10-17-2013, 11:02 AM
Last Post: Jeff O.
  HHC 2012 RPN Programming Challenge Conundrum Jeff O. 15 3,899 10-08-2012, 03:34 PM
Last Post: Gerson W. Barbosa
  Mini-challenge: HHC2012 RPL programming contest with larger input David Hayden 14 3,536 10-05-2012, 10:36 PM
Last Post: David Hayden
  Weekend programming challenge: Euler's Totient function Allen 36 8,804 06-03-2012, 10:39 PM
Last Post: Paul Dale
  A Sunday Programming Challenge Allen 61 13,915 03-17-2012, 06:48 PM
Last Post: Allen
  HHC2012 programming challenge?? Pal G. 28 5,986 09-25-2011, 05:02 PM
Last Post: Paul Dale
  HHC MMC Programming challenge inC code David Hayden 8 2,304 12-31-2010, 09:40 AM
Last Post: David Hayden
  Programming Challenge Namir 16 4,181 09-27-2010, 01:13 PM
Last Post: Namir
  RE: 35s sorting routine challenge - Gene's Challenge Miguel Toro 4 1,542 08-01-2007, 08:36 AM
Last Post: Miguel Toro
  HP-16C programming challenge - Hamming distance Eric Smith 9 2,346 01-27-2006, 12:53 AM
Last Post: Eric Smith

Forum Jump: