HP50g simplifing a root
|
10-07-2020, 06:12 PM
(This post was last modified: 10-10-2020 05:25 PM by Albert Chan.)
Post: #18
|
|||
|
|||
RE: HP50g simplifing a root
(10-06-2020 04:13 PM)Albert Chan Wrote: ³√(A +√R) ³√(A -√R) = (a + √r) (a - √r) We can solve above cubics directly. However, with limited precision, it is hard to get the correct LHS (is it really an integer ?) One trick is assume that it is (with error under ± 1/2), i.e. we use c = round(³√(A² - R)) We solve the cubics, 4a³ = (3c)*a + A, then confirm (a, r) will, in reverse, produce (A, R) (Actually, it calculated 3r both ways, using either A or B; both must match) Below uses Kahan's Solve a Real Cubic Equation method Code: cbrt = require'mathx'.cbrt lua> simp_cbrt2(1859814842094, -59687820010, 415) 11589 -145 415 lua> simp_cbrt2(300940299,103940300,101) 99 100 101 lua> simp_cbrt2(9416,-4256,5) 11 -7 5 lua> simp_cbrt2(26,-15,3) 2 -1 3 lua> simp_cbrt2(26,-15+1,3) -- no returns, as expected lua> For first example, this version run 55X speed of previous simp_cbrt1() To show why, lets add a debug line, "print(a)", right below keyword "repeat" lua> simp_cbrt2(1859814842094, -59687820010, 415) -- debug version 12856.226745378446 11738.132585006717 11591.443457378273 11589.000672078266 11589 -145 415 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)