Post Reply 
Mathematician Finds Easier Way to Solve Quadratic Equations
05-10-2024, 05:11 PM (This post was last modified: 05-10-2024 08:04 PM by Albert Chan.)
Post: #60
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-09-2024 02:34 PM)Gerson W. Barbosa Wrote:  As you said, KISS is not simple.

Q(1,0,1) stops with a “Divide by 0” message (as does my program using COS/ASIN).

x^2 + p*x + q = 0
x = m ± √Δ                          // m = -p/2, Δ = m^2 - q

x1 = m + m * √(Δ/m^2)      // big root, m^2≠0

For Free42, SIGN(0) = 1, SIGN(0+0i) = (0+0i)
I needed a nice transition, SIGN(0+0i) = SIGN(0) = 1 too

s = SIGN(m), or 1 if |m|=0

x1 = m + s * √(Δ/s^2)        // big root, m=0 OK too

Code:
00 { 36-Byte Prgm }
01▸LBL "Q"
02 X<> ST Z         ;   a   b   c         
03 STO÷ ST Z        
04 STO+ ST X 
05 +/-              
06 ÷                ;   m   q
07 ENTER            
08 ABS              ;  |m|  m   q
09 X≠0?             
10 X<> ST L         
11 SIGN             ;   s   m   q    
12 RCL ST Y         
13 X↑2              
14 RCL- ST T        ;   Δ   s   m   q
15 RCL÷ ST Y        
16 RCL÷ ST Y        
17 SQRT             
18 ×                
19 +                ;  x1   q   q   q
20 STO÷ ST Y        ;  x1  x2   q   q
21 END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Mathematician Finds Easier Way to Solve Quadratic Equations - Albert Chan - 05-10-2024 05:11 PM



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