Post Reply 
RE: HP48-HP50G : Error functions ERF(z), FRESNEL integrals, PROBIT, etc.
11-14-2023, 06:42 PM
Post: #24
RE: RE: HP48-HP50G : Error functions ERF(x or z), ERFC (x or z) & iERF/iERFc —>x
(11-09-2023 12:46 PM)Albert Chan Wrote:  Erfc(x) = « 0 0.5 ROT UTPN 2 * »

Getting Erfc from UTPN is accurate. (only scaling, no subtraction cancellation)
With good Erfc, we expected getting IErfc should also be accurate.

Unfortunately, we don't have same formula pattern for Erf(x)
(is there a normal distribution area function for center part?)

Here, we use erf(x) slope to improve Erf and IErf

erf(x)' = 2/sqrt(pi) * exp(-x*x)

Code:
function ierf_taylor(x)
    if x<0 then return -ierf_taylor(-x) end
    local y = ierfc(1-x)    -- assume good ierfc
    local h = x - (x-1+1)
    return h==0 and y or y + sqrt(pi)/2 * exp(y*y) * h
end
function erf_taylor(x)
    local y = 1 - erfc(x)   -- assume good erfc
    local h = x - ierf_taylor(y)
    return h==0 and y or y + 2/sqrt(pi) * exp(-x*x) * h
end

lua> x = 1e-9
lua> erf(x), 1-erfc(x)
1.1283791670955127e-09     1.1283791678806665e-09
lua> erf_taylor(x)
1.1283791670955127e-09

lua> ierf(x), ierfc(1-x)
8.862269254527581e-10       8.862269003885489e-10
lua> ierf_taylor(x)
8.86226925452758e-10
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RE: HP48-HP50G : Error functions ERF(x or z), ERFC (x or z) & iERF/iERFc —>x - Albert Chan - 11-14-2023 06:42 PM



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