Post Reply 
HP-35’s x^y Why?
11-03-2021, 06:22 PM
Post: #37
RE: HP-35’s x^y Why?
(11-03-2021 03:21 PM)Albert Chan Wrote:  Does HP71B has XROOT (or equivalent ?)
I am curious of how to efficiently implement this ...

First try ...

y^(1/n) = y^float(1/n) * y^ε       , where ε = 1/n - float(1/n) = (1 - n*float(1/n)) / n

Correction y^ε = exp(ε*ln(y)) ≈ 1 + ε*ln(y)

Code:
function surd(y,n)      -- nthroot of y
    local z, sgn = 1/n, 1
    if y<0 and n%2==1 then y=-y; sgn=-1 end
    local x = y^z * sgn
    z = fma(n,-z,1) * x
    return z==0 and x or x + z*log(y)/n
end


lua> surd(-8, 3)
-2
lua> surd(-8, 3.1)
-NaN

lua> surd(12345,3)
23.111618749807267
lua> 12345 ^ (1/3)
23.111618749807263
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-35’s x^y Why? - Matt Agajanian - 10-30-2021, 06:33 PM
RE: HP-35’s x^y Why? - toml_12953 - 10-30-2021, 06:43 PM
RE: HP-35’s x^y Why? - TomC - 10-30-2021, 07:41 PM
RE: HP-35’s x^y Why? - Peet - 10-30-2021, 08:46 PM
RE: HP-35’s x^y Why? - Gerson W. Barbosa - 10-30-2021, 09:54 PM
RE: HP-35’s x^y Why? - Steve Simpkin - 10-30-2021, 11:43 PM
RE: HP-35’s x^y Why? - Peet - 10-31-2021, 07:45 AM
RE: HP-35’s x^y Why? - Steve Simpkin - 10-31-2021, 07:07 PM
RE: HP-35’s x^y Why? - Peet - 10-31-2021, 09:18 PM
RE: HP-35’s x^y Why? - Didier Lachieze - 10-31-2021, 09:49 PM
RE: HP-35’s x^y Why? - lrdheat - 10-31-2021, 12:00 AM
RE: HP-35’s x^y Why? - Steve Simpkin - 10-31-2021, 12:23 AM
RE: HP-35’s x^y Why? - rprosperi - 10-31-2021, 01:09 AM
RE: HP-35’s x^y Why? - Steve Simpkin - 10-31-2021, 01:34 AM
RE: HP-35’s x^y Why? - Dave Britten - 10-31-2021, 01:31 PM
RE: HP-35’s x^y Why? - rprosperi - 10-31-2021, 08:18 PM
RE: HP-35’s x^y Why? - Steve Simpkin - 10-31-2021, 09:39 PM
RE: HP-35’s x^y Why? - rprosperi - 10-31-2021, 11:59 PM
RE: HP-35’s x^y Why? - Steve Simpkin - 11-01-2021, 12:51 AM
RE: HP-35’s x^y Why? - ijabbott - 11-01-2021, 08:40 PM
RE: HP-35’s x^y Why? - EdS2 - 11-01-2021, 09:54 AM
RE: HP-35’s x^y Why? - rprosperi - 11-01-2021, 12:40 PM
RE: HP-35’s x^y Why? - John Keith - 11-01-2021, 02:47 PM
RE: HP-35’s x^y Why? - robve - 11-03-2021, 02:37 AM
RE: HP-35’s x^y Why? - robve - 11-03-2021, 03:46 AM
RE: HP-35’s x^y Why? - Albert Chan - 11-03-2021, 07:45 AM
RE: HP-35’s x^y Why? - robve - 11-03-2021, 01:44 PM
RE: HP-35’s x^y Why? - Albert Chan - 11-03-2021, 03:21 PM
RE: HP-35’s x^y Why? - J-F Garnier - 11-03-2021, 07:47 AM
RE: HP-35’s x^y Why? - robve - 11-03-2021, 02:38 PM
RE: HP-35’s x^y Why? - J-F Garnier - 11-03-2021, 03:43 PM
RE: HP-35’s x^y Why? - robve - 11-03-2021, 05:46 PM
RE: HP-35’s x^y Why? - J-F Garnier - 11-03-2021, 06:41 PM
RE: HP-35’s x^y Why? - robve - 11-03-2021, 08:04 PM
RE: HP-35’s x^y Why? - Albert Chan - 11-03-2021 06:22 PM
RE: HP-35’s x^y Why? - cdmackay - 11-02-2021, 04:22 PM
RE: HP-35’s x^y Why? - ijabbott - 11-02-2021, 08:09 PM
RE: HP-35’s x^y Why? - Gene - 11-02-2021, 04:31 PM
RE: HP-35’s x^y Why? - Jeff O. - 11-04-2021, 09:15 PM
RE: HP-35’s x^y Why? - Guenter Schink - 11-04-2021, 09:21 PM



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