HP50g simplifing a root
10-10-2020, 03:58 PM
Post: #22
 Albert Chan Senior Member Posts: 2,682 Joined: Jul 2018
RE: HP50g simplifing a root
(10-09-2020 05:21 PM)Albert Chan Wrote:  $$\sqrt[3]{A ± \sqrt{R}} = a ± \sqrt{r} \quad﻿ ⇒ \quad a = \large\frac{\sqrt[3]{A+\sqrt{R}} \;+\; \sqrt[3]{A-\sqrt{R}}}{2}$$

Slightly off topics. I was curious how to calculate a accurately (assumed R > 0)
Since cube root is odd function, we pull out the sign.

a = sign(A)/2 * (³√(|A|+√R) + ³√(|A|-√R))

Last term can be rewritten as ³√(A²-R) / ³√(|A|+√R)

Let c = ³√(A²-R), d = ³√(|A|+√R)², we have:

a = sign(A)/2 * (d + c) / √d

Since both c, d are cube roots, we try identity c³ + d³ = (c + d) (c² - c d + d²)

c³ + d³ = (A² - R) + (A² + R + 2|A|√R) = |2A| * (|A|+√R) = |2A| * d√d

Substitute back in, many terms get cancelled, a = A / (c²/d - c + d)

If ³√(A ± √R) can be simplified, c turns to integer (we had shown this earlier).
In fact, the whole denominator turns to integer = a² + 3r = 4a² - 3c

Code:
function calc_a(A,R)     local c = cbrt(A*A-R)     local d = cbrt(A*A+R + 2*abs(A)*sqrt(R))     return A / (c*c/d - c + d) end

lua> function test_a(A,R)
: ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ local q = sqrt(R)
: ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ return calc_a(A,R), (cbrt(A+q) + cbrt(A-q))/2
: ﻿ ﻿ ﻿ ﻿ ﻿ end
lua>
lua> test_a(26, 15^2 * 3)
2 ﻿ ﻿ ﻿ ﻿ ﻿ 1.9999999999999982
lua> test_a(9416, 4256^2 * 5)
11 ﻿ ﻿ ﻿ 11.000000000000005
lua> test_a(300940299,103940300^2 * 101)
99 ﻿ ﻿ ﻿ 99.00000000000006
 « Next Oldest | Next Newest »

 Messages In This Thread HP50g simplifing a root - peacecalc - 09-29-2020, 09:22 PM RE: HP50g simplifing a root - Albert Chan - 09-29-2020, 11:47 PM RE: HP50g simplifing a root - Albert Chan - 09-30-2020, 02:22 AM RE: HP50g simplifing a root - Albert Chan - 09-30-2020, 10:50 PM RE: HP50g simplifing a root - Albert Chan - 10-01-2020, 07:31 AM RE: HP50g simplifing a root - peacecalc - 09-30-2020, 05:33 AM RE: HP50g simplifing a root - peacecalc - 10-01-2020, 02:20 PM RE: HP50g simplifing a root - Albert Chan - 10-01-2020, 05:22 PM RE: HP50g simplifing a root - peacecalc - 10-04-2020, 06:05 PM RE: HP50g simplifing a root - Albert Chan - 10-04-2020, 11:48 PM RE: HP50g simplifing a root - peacecalc - 10-04-2020, 07:36 PM RE: HP50g simplifing a root - peacecalc - 10-05-2020, 11:36 AM RE: HP50g simplifing a root - Albert Chan - 10-05-2020, 05:01 PM RE: HP50g simplifing a root - peacecalc - 10-06-2020, 05:25 AM RE: HP50g simplifing a root - Albert Chan - 10-06-2020, 09:40 AM RE: HP50g simplifing a root - Albert Chan - 10-06-2020, 12:06 PM RE: HP50g simplifing a root - Albert Chan - 10-06-2020, 04:13 PM RE: HP50g simplifing a root - Albert Chan - 10-07-2020, 06:12 PM RE: HP50g simplifing a root - Albert Chan - 10-09-2020, 12:20 AM RE: HP50g simplifing a root - Albert Chan - 10-09-2020, 02:31 PM RE: HP50g simplifing a root - Albert Chan - 10-11-2020, 06:28 PM RE: HP50g simplifing a root - Albert Chan - 10-12-2020, 03:17 AM RE: HP50g simplifing a root - Albert Chan - 10-24-2020, 02:19 PM RE: HP50g simplifing a root - Albert Chan - 10-12-2020, 10:54 PM RE: HP50g simplifing a root - CMarangon - 10-12-2020, 11:45 PM RE: HP50g simplifing a root - grsbanks - 10-13-2020, 06:46 AM RE: HP50g simplifing a root - Albert Chan - 10-09-2020, 05:21 PM RE: HP50g simplifing a root - Albert Chan - 10-10-2020 03:58 PM RE: HP50g simplifing a root - Albert Chan - 10-10-2020, 04:49 PM RE: HP50g simplifing a root - peacecalc - 10-12-2020, 08:49 PM RE: HP50g simplifing a root - peacecalc - 10-13-2020, 06:30 AM RE: HP50g simplifing a root - peacecalc - 10-13-2020, 06:36 AM

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