Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
erf() - The Gauss error function
#1
This calculates the Gauss error function and the complementary Gauss error function:
Code: (Select All)

'The Gauss error function and the complementary Gauss error function
DIM AS _FLOAT a, n
a = 0.05
PRINT erf##(a)
PRINT erfc##(a)

FUNCTION erf## (value AS DOUBLE) 'the Gauss error function
    t## = 1 / (1 + 0.5 * ABS(value))
    tau## = t## * EXP(-value ^ 2 - 1.26551223 + 1.00002368 * t## + 0.37409196 * t## ^ 2 + 0.09678418 * t## ^ 3 - 0.18628806 * t## ^ 4 + 0.27886807 * t## ^ 5 - 1.13520398 * t## ^ 6 + 1.48851587 * t## ^ 7 - 0.82215223 * t## ^ 8 + 0.17087277 * t## ^ 9)
    IF value >= 0 THEN
        erf## = 1 - tau##
    ELSEIF value < 0 THEN
        erf## = tau## - 1
    END IF
END FUNCTION


FUNCTION erfc## (value AS DOUBLE) 'the complementary Gauss error function
    erfc## = 1 - erf##(value)
END FUNCTION
  

This are standard functions of many math libraries of other programming languages.
Reply


Messages In This Thread
erf() - The Gauss error function - by BSpinoza - 11-14-2023, 07:05 AM
RE: erf() - The Gauss error function - by bplus - 11-14-2023, 06:16 PM
RE: erf() - The Gauss error function - by Dimster - 11-14-2023, 03:18 PM



Users browsing this thread: 1 Guest(s)