×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang math.Erfcinv() Function with Examples

Golang | math.Erfcinv() Function: Here, we are going to learn about the Erfcinv() function of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 30, 2021

math.Erfcinv()

The Erfcinv() function is an inbuilt function of the math package which is used to get the inverse of Erfc(x), where x is the given parameter.

It accepts a parameter (x) and returns the inverse of Erfc(x).

Syntax

func Erfcinv(x float64) float64

Parameters

  • x : The value of float64 type to found the inverse of Erfc(x).

Return Value

The return type of Erfcinv() function is a float64, it returns the inverse of Erfc(x).

Special cases are:

  • Erfcinv(0) = +Inf
    If the parameter is 0, the function returns +Inf.
  • Erfcinv(2) = -Inf
    If the parameter is 2, the function returns -Inf.
  • Erfcinv(x) = NaN if x < 0 or x > 2
    If the parameter is less then 0 or greater then 2, the function returns NaN.
  • Erfcinv(NaN) = NaN
    If the parameter is NaN, the function returns NaN.

Example 1

// Golang program to demonstrate the
// example of math.Erfcinv() Function

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println(math.Erfcinv(1.5))
	fmt.Println(math.Erfcinv(1.9))
	fmt.Println(math.Erfcinv(0.50))

	fmt.Println(math.Erfcinv(0))
	fmt.Println(math.Erfcinv(2))
	fmt.Println(math.Erfcinv(-1))
	fmt.Println(math.Erfcinv(3))
	fmt.Println(math.Erfcinv(math.NaN()))
}

Output:

-0.4769362762044699
-1.1630871536766736
0.4769362762044699
+Inf
-Inf
NaN
NaN
NaN

Example 2

// Golang program to demonstrate the
// example of math.Erfcinv() Function

package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	var ErfcinvX float64

	x = 0.5
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)

	x = 1
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)

	x = 1.5
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)

	x = 0
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)

	x = 2
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)

	x = -0.5
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)

	x = math.NaN()
	ErfcinvX = math.Erfcinv(x)
	fmt.Println("Erfcinv(", x, ") = ", ErfcinvX)
}

Output:

Erfcinv( 0.5 ) =  0.4769362762044699
Erfcinv( 1 ) =  0
Erfcinv( 1.5 ) =  -0.4769362762044699
Erfcinv( 0 ) =  +Inf
Erfcinv( 2 ) =  -Inf
Erfcinv( -0.5 ) =  NaN
Erfcinv( NaN ) =  NaN

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.