Post Reply 
Quadratic Solver for Casio FX-3650P
11-09-2018, 06:43 PM (This post was last modified: 04-10-2019 10:10 PM by Albert Chan.)
Post: #7
RE: Quadratic Solver for Casio FX-3650P
Another way to get discriminant, from Kahans cubic equation paper (page 11)
BTW, page 12 example 2 typo, should be: 1,160,928,203² - 3,234,424,451 * 416,690,636 = -89,060,331,627

PHP Code:
function b2_less_ac(abc)  -- assume a0
    
if c then aca end
    
if verbal then io.write(math.abs(b), '\xfd - 'a' * 'c'\n'end
    local n 
0
    
if c>0 then n math.floor(b/0.5end
    
if == 0 then return b*a*c end
    local h 
math.floor(n/2)
    
- (n-h)*h*b
    b 
- (n-h)*h*c
    
return b2_less_ac(cbn*b)
end 

To show that reduction code work, let reduced a = a', reduced b = b':
b'² = (b - nc)² = b² - nc * (2b - nc) = b² - nc * (b+b')
a'c = (a - nb - nb') * c = ac - nc * (b+b')
-> b'² - a'c = b² - ac

lua> A, B, C = 8441600, -22222222, 14624809 -- previous post example
lua> verbal = true
lua> b2_less_ac(4*A, B, C)
22222222² - 33766400 * 14624809
7027396² - 14624809 * 3376748
273900² - 3376748 * 22217
7296² - 22217 * 2396
108² - 2396 * 5
2² - 64 * 5
-316

Doing by hand, we can do slightly better:

(-22222222)² - (4)(8441600)(14624809)
= 22222222² - (5849923600)(84416) -- n = round(22222222/84416) = 263, b' = b-nc = 20814
= 20814² - (84416)(5849923600 - 263*22222222 - 263*20814)
= 20814² - (84416)(5132)
= -316
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Quadratic Solver for Casio FX-3650P - Albert Chan - 11-09-2018 06:43 PM



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