The Go programming language uses the Erfcinv
function to find the inverse of the complementary error function of a certain decimal number.
To use this function, you must import the math
package in your file and access the Erfcinv
function within it using the .
notation (math.Erfcinv
). Here, Erfcinv
is the actual function, while math
is the Go package that stores the definition of this function.
The complementary error function is a sigmoid function used in probability, statistics, and partial differential equations. It equals the error function subtracted from 1 (1 - erf(x)
); Erfcinv
is defined as the functional inverse of this function. It is represented using erfc(x)
, and the following formula defines the erfc(x)
function:
The definition of the Erfcinv
function inside the math
package is:
The Erfcinv
function takes a single argument of type float64
. This argument represents the decimal number whose inverse complementary error function you want to find.
The Erfcinv
function returns a single value of type float64
. This value represents the inverse complementary error function for a particular input argument.
Following are two types of return values only used by the function under certain circumstances:
NAN
: Not a number, or NAN
, is returned in all cases where the input argument is of undefined value or if input x
is out of the range, i.e., x
< 0 or x
> 2.
+Inf
: The Erfcinv
function returns +Inf
if the input argument has a value of 0.
-Inf
: The Erfcinv
function returns -Inf
if the input argument has a value of 2.
Giving an empty argument or an argument that is not a numeric value results in an error.
Following is a simple example where we find out the inverse complementary error function of a positive decimal value:
package mainimport ("fmt""math")func main() {x := 0.8y := math.Erfcinv(x)fmt.Print("The inverse complementary error function of ", x, " is ", y)}
The following example shows how the Erfcinv
function deals with arguments that are outside its domain:
package mainimport ("fmt""math")func main() {x := -1.0y := math.Erfcinv(x)fmt.Print("The complementary error function of ",x ," is ", y)fmt.Print("\n")}
Free Resources