Post Reply 
(11C) Quadratic Equation
03-22-2018, 10:18 AM (This post was last modified: 03-22-2018 11:58 AM by Dieter.)
Post: #2
RE: (11C) Quadratic Equation
(03-21-2018 06:50 AM)Gamo Wrote:  The program calculates the real or complex solutions of a quadratic equation.

aX^2 + bX + c = 0

c [ENTER] > b [ENTER] > a > [LBL A] briefly shown [+] or [-] solution.

If Positive (+) then two real solutions with R/S for second answer.
If Negative (-) then two complex solutions with X<>Y for complex of +,-

One of my first books on RPN and HP calculators also had a program for quadratic equations. To distinguish real and complex solutions it displayed "1111111111" for the latter case. In the calculator display this looks like a line of "i"s that indicate a solution with an imaginary part. ;-)

I like this idea, so here is an adapted version. It differs from yours in three points:

- The coefficients are entered  a [ENTER] b [ENTER] c
- Two real solutions are directly returned in X and Y
- An imaginary solution is indicated by a line of 1s, then real and imaginary part are returned in X and Y again.

Edit:
The program now also handles a=0, i.e. a simple linear equation. The previous versions returned an error in this case.

Code:
LBL A
R↓
x<>y
x=0?
GTO 2
/
R↑
LastX
/
ENTER
ENTER
R↑
2
/
CHS
ENTER
x^2
R↑
-
x<0?
GTO 1
SQRT
x<>y
x>0?
+
x>0?
GTO 0
x<>y
-
LBL 0
ENTER
R↑
x<>y
/
RTN
LBL 1
EEX
1
0
ENTER
9
/
PAUSE
R↓
CHS
SQRT
x<>y
RTN
LBL 2
R↑
-
x<>y
/
ENTER
RTN

Examples:

2x² + 5x + 3 = 0
2 [ENTER] 5 [ENTER] 3 [A] => –1,0000 [X↔Y] –1,5000
Two real solutions: –1 and –1,5.

2x² + 3x + 4 = 0
2 [ENTER] 3 [ENTER] 4 [A] => "1111111111"  –0,7500 [X↔Y] 1,1990
Two conjugate complex solutions: –0,75 ± 1,199 i

BTW, for those who want to try more sophisticated quadratic equation solvers: take a look at the HP15C Advanced Functions Handbook (appendix, "Example 6 continued"). It includes a special version of such a program that shows how the limitations of the standard methods can be overcome. However, note that this solves ax²–2bx+c=0.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Quadratic Equation - Gamo - 03-21-2018, 06:50 AM
RE: (11C) Quadratic Equation - Dieter - 03-22-2018 10:18 AM
RE: (11C) Quadratic Equation - Albert Chan - 08-11-2018, 04:39 PM



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