The following warnings occurred:
Warning [2] Undefined array key 198468 - 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 198470 - 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 198472 - 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 198482 - 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 198512 - 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 198526 - 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 198573 - 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 198682 - 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 198470 - 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 198472 - 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 198682 - 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 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





Which quadratic formula is use?



#2

I'm amaze by the fact that this quadratic formula is so short :

001- LBL E
002- ENTER
003- R^
004- /
005- R^
006- LSTx
007- /
008- 2
009- CHS
010- /
011- ENTER
012- ENTER
013- x^2
014- R^
015- -
016- SQRT
017- -
018- x<>y
019- LSTx
020- +
021- RTN

I found this on a museum's archive 17 :

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv017.cgi?read=114345

My shortest program have 30 step. I realize that the formula use for this program is not the same old one we learn at high school.

I'm still learning the RPN stack and programming on the 15C. What is the "modified" formula use?

Thanks


#3

It's probably the same formula in the end, it's just using a ton of RPN tricks to cram the computation into as short a program as possible.

#4

Here it is, courtesy of Allen:

On the HP-42S, 15 steps suffice:

00 { 28-Byte Prgm }                        
01 LBL "Q"
02 RCL/ ST Z
03 X<> ST Z
04 /
05 -2
06 /
07 STO ST Z
08 x^2
09 X<>Y
10 -
11 SQRT
12 RCL+ ST Y
13 X<>Y
14 RCL- ST L
15 END

Edited: 29 Sept 2011, 9:54 a.m.

#5

Definitely the standard quadratic formula with optimum use of stack to provide both answers in x and y, as shown in the following listing which shows the stack contents after each function:

Step	Function	     Stack Contents
--------------------------------------------------------
T: --
Z: A
Y: B
1 LBL E X: C
--------------------------------------------------------
T: A
Z: B
Y: C
2 ENTER X: C
--------------------------------------------------------
T: B
Z: C
Y: C
3 R^ X: A
--------------------------------------------------------
T: B
Z: B
Y: C
4 / X: C/A
--------------------------------------------------------
T: B
Z: C
Y: C/A
5 R^ X: B
--------------------------------------------------------
T: C
Z: C/A
Y: B
6 LSTx X: A
--------------------------------------------------------
T: C
Z: C
Y: C/A
7 / X: B/A
--------------------------------------------------------
T: C
Z: C/A
Y: B/A
8 2 X: 2
--------------------------------------------------------
T: C
Z: C/A
Y: B/A
9 CHS X: -2
--------------------------------------------------------
T: C
Z: C
Y: C/A
10 / X: -B/2A
--------------------------------------------------------
T: C
Z: C/A
Y: -B/2A
11 ENTER X: -B/2A
--------------------------------------------------------
T: C/A
Z: -B/2A
Y: -B/2A
12 ENTER X: -B/2A
--------------------------------------------------------
T: C/A
Z: -B/2A
Y: -B/2A
13 x^2 X: B2/4A2
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: B2/4A2
14 R^ X: C/A
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: -B/2A
15 - X: B2/4A2-C/A
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: -B/2A
16 SQRT X: SQRT(B2/4A2-C/A)
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: -B/2A
17 - X: -B/2A-SQRT(B2/4A2-C/A)
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: -B/2A-SQRT(B2/4A2-C/A)
18 x<>y X: -B/2A
--------------------------------------------------------
T: -B/2A
Z: -B/2A-SQRT(B2/4A2-C/A)
Y: -B/2A
19 LSTx X: SQRT(B2/4A2-C/A)
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: -B/2A-SQRT(B2/4A2-C/A)
20 + X: -B/2A+SQRT(B2/4A2-C/A)
--------------------------------------------------------
T: -B/2A
Z: -B/2A
Y: -B/2A-SQRT(B2/4A2-C/A)
21 RTN X: -B/2A+SQRT(B2/4A2-C/A)
--------------------------------------------------------

Of course SQRT(B2/4A2-C/A) is equal to SQRT(B2-4AC)/2A

listing edited to hopefully make it easier to read

Edited: 29 Sept 2011, 10:05 p.m. after one or more responses were posted


#6

Very impressive use of the stack! I will study it tonight after work...


#7

Agreed. I have edited the listing to hopefully make it easier to read. In case it is not clear, the stack contents on each line are as they will be after the function on that line is executed.


#8

Thank you.



Usefull code. Here a more compact version of your code I have input into a personal note format:

Step  Function       t:                       z:                        y:                       x:             Lastx:
----- -------- ------ ---------------------- ----------------------- ---------------------- ------
01 LBL E ~ a b c
02 ENTER a b c c
03 R^ b c c a
04 / b b c c/a a
05 R^ b c c/a b
06 LSTx c c/a b a
07 / c c c/a b/a a
08 2 c c/a b/a 2
09 CHS c c/a b/a -2 -2
10 / c c c/a -b/2a -2
11 ENTER c c/a -b/2a -b/2a
12 ENTER c/a -b/2a -b/2a -b/2a
13 x^2 c/a -b/2a -b/2a b²/4a² -b/2a
14 R^ -b/2a -b/2a b²/4a² c/a
15 - -b/2a -b/2a -b/2a b²/4a²-c/a c/a
16 SQRT -b/2a -b/2a -b/2a SQRT(b²/4a²-c/a) b²/4a²-c/a
17 - -b/2a -b/2a -b/2a -b/2a-SQRT(b²/4a²-c/a) SQRT(b²/4a²-c/a)
18 x<>y -b/2a -b/2a -b/2a-SQRT(b²/4a²-c/a) -b/2a
19 LSTx -b/2a -b/2a-SQRT(b²/4a²-c/a) -b/2a SQRT(b²/4a²-c/a)
20 + -b/2a -b/2a -b/2a-SQRT(b²/4a²-c/a) -b/2a+SQRT(b²/4a²-c/a) SQRT(b²/4a²-c/a)
21 RTN x1 x2
----- -------- ------ ---------------------- ----------------------- ---------------------- ------
where x1 and x2 are the real roots of equation a.x2+b.x+c=0



Exemple :
Type 2 [ENTER] 10 [CHS][ENTER] 12 [ GSB ][ E ] to solve 2.x2 - 10.x + 12=0 and get x1 = 2 and x2 = 3

The calculator first display x2, you have to press [x<->y]key to get x1.



But you will be in trouble solving 2.x2 - 8.x + 26=0 !



Note that on HP-15c, this code needs very few modifications to also produce real or complex solution(s) to any a.x2+ b.x + c = 0 equation with real or complex coefficients a, b and c.
Step  Func
----- --------
01 LBL E
02 ENTER
03 R^
04 /
05 R^
06 LSTx
07 /
08 2
09 CHS
10 /
11 ENTER
12 ENTER
13 x^2
14 R^
15 -
16 TEST 2 @ ( x<=0 ? )
17 SF 8 @ (Complex mode ON)
18 SQRT
19 -
20 x<>y
21 LSTx
22 +
23 RTN
----- --------

To solve quadratic equation 2.x2 - 8.x + 26 = 0, y have to type :

[ g ][ CF ][ 8 ] to set complex mode OFF in order to enter real coefficients :

[ 2 ][ENTER^][ 8 ][CHS][ENTER^][2][6] to type in respectively a=2, b=-8 and c=26.

[GSB][ E ] to run code.

Note that the ‘C’ enunciator indicates complex solutions z1 = 2-3i and z2 = 2+3i. Imaginary parts have to be displayed using [ f ][Re<->I] switchs or by holding [ f ][(i)] key.

To enter complex coefficients, simply enter a, b and c as complex using [ f][ I ] or [ f ][Re<->Im] method.

Amazing HP-15c!


Edited: 29 Sept 2011, 4:54 p.m.


#9

Thanks.

I considered laying the stack contents out horizontally. But I seem to visualize the stack in a vertical layout and find it easier to follow and/or develop how the contents move around if I present it that way. I'll have to do a layout for the complex version tomorrow to see how it works.


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to manage formula in prime fabrice48 5 2,415 12-05-2013, 01:09 PM
Last Post: Steve Simpkin
  Quadratic & Cubic Regression RPN progs Matt Agajanian 9 2,828 09-17-2013, 11:37 AM
Last Post: Jeff O.
  WP34s program submission: Quadratic fit Andrew Nikitin 2 1,208 06-13-2013, 02:44 AM
Last Post: Paul Dale
  New Quadratic Lagrangian Interpolation Method Namir 2 1,310 07-20-2012, 04:32 PM
Last Post: Namir
  Fast Quadratic Formula for the HP-41C Gerson W. Barbosa 21 5,962 07-18-2012, 08:53 AM
Last Post: Gerson W. Barbosa
  Cubic Formula: HP 71B Eddie W. Shore 8 2,750 07-03-2012, 11:14 PM
Last Post: Eddie W. Shore
  Quadratic formula program help Chris C 18 4,686 06-16-2012, 12:14 AM
Last Post: Matt Agajanian
  Dr Bills Quadratic solver for 35S snaggs 6 2,051 09-12-2011, 05:10 AM
Last Post: Pablo P (Spain)
  35s Quadratic Regression J Noël 11 2,936 02-04-2011, 08:19 AM
Last Post: Dieter
  Re: The lost formula Csaba Tizedes (Hungary) 5 1,788 01-26-2011, 05:59 AM
Last Post: Csaba Tizedes (Hungary)

Forum Jump: