Post Reply 
Mathematician Finds Easier Way to Solve Quadratic Equations
05-03-2024, 02:02 PM (This post was last modified: 05-04-2024 07:07 PM by Gerson W. Barbosa.)
Post: #28
RE: Mathematician Finds Easier Way to Solve Quadratic Equations
(05-02-2024 02:00 PM)Albert Chan Wrote:  
(05-01-2024 11:08 PM)Gerson W. Barbosa Wrote:  \(x_{1,2}=\sqrt{q}\times e^{±\cosh^{-1}{(-\frac{p}{2\sqrt{q}}})}\)

exp/cosh quadratic formula avoided subtraction canellation, but introduced another.
Exponential function slope is also an exponential function!

e^(x*(1-ε)) ≈ e^x - (x*e^x)*ε

RelErr(x) = ε      ⇒ RelErr(e^x) = (exact - approx) / exact ≈ (x*e^x)*ε / e^x = x*ε

Fortunately, acosh is similar to log, keeping size of x in check.
Still, Trig (tan/asin) quadratic version is perhaps more accurate.

Code:
00 { 24-Byte Prgm }
01▸LBL "T"          ; c     b   a
02 RCL÷ ST Z        ; q     b   a
03 SQRT             
04 X<> ST Z         ; a     b   √q
05 +/-              
06 ENTER            
07 +                ; -2a   b   √q   √q me
08 ÷                
09 ÷                ; -2√q/p    √q   √q
10 ASIN
11 2
12 ÷
13 TAN
14 STO× ST Z
15 ÷
16 END

Very nice! Thanks for this alternative method, useful for both Free42 and the HP-42S.

The following is longer, but preserves the previous stack register X for later use. Some optimization is still possible, I think.

Code:

00 { 31-Byte Prgm }
01▸LBL "T"
02 X<> ST Z
03 STO÷ ST Z
04 +/-
05 STO+ ST X
06 ÷
07 X<>Y
08 SQRT
09 STO ST Z
10 X<>Y
11 ÷
12 ASIN
13 2
14 ÷
15 TAN
16 RCL× ST Y
17 X<>Y
18 RCL÷ ST L
19 END

On the real HP-42S, in DEG mode:

E 13 +/- ENTER 2 +/- ENTER 1 XEQ T ->

Y: 4.99999999999E-1
Y: 2.00000000000E13


Same answers in RAD mode. RAD mode appears to be slightly more accurate. No reason to change the angular mode just for that reason, I think. (Mine is most of the time in DEG mode).

This is my very first calculator program, written for the SHARP EL-5813 back in 1981:

2ndF LRN ( ( ( K₂ +/- + ( K₂ x² - 4 K₁ K₃ ) 2ndF √ ) ÷ 2 K₁ ) 2ndF LOOK + K₂ ÷ K₁ ) +/- 2ndF LRN

I don’t have it anymore, but I remember the usage was

a STO K₁
b STO K₂
c STO K₃
COMP


Quadratic equations were often needed to be solved during my first college years, Physics then EE, so I always kept a quadratic solver in the programmable calculator I was using at the moment (TI-51-III, TI-59, HP-15C, HP-28S and HP-48GX). No Cadillac solvers needed for those trivial equations, though. My Beetle solvers did just fine! :-)

Edited to fix a typo and an orthographic error.
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 - Gerson W. Barbosa - 05-03-2024 02:02 PM



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