Home »
Golang »
Golang Reference
Golang math.Y0() Function with Examples
Golang | math.Y0() Function: Here, we are going to learn about the Y0() function of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 04, 2021
math.Y0()
The Y0() function is an inbuilt function of the math package which is used to get the order-zero Bessel function of the second kind.
It accepts a parameter (x) and returns the order-zero Bessel function of the second kind.
Syntax
func Y0(x float64) float64
Parameters
- x : The value to be used to get the order-zero Bessel function of the second kind.
Return Value
The return type of Y0() function is a float64, it returns the order-zero Bessel function of the second kind.
Special Cases
- Y0(+Inf) = 0
If the parameter is +Inf, the function returns 0.
- Y0(0) = -Inf
If the parameter is 0, the function returns -Inf.
- Y0(x < 0) = NaN
If the parameter is less than 0, the function returns NaN.
- Y0(NaN) = NaN
If the parameter is NaN, the function returns the same value (NaN).
Example 1
// Golang program to demonstrate the
// example of math.Y0() Function
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(math.Y0(1))
fmt.Println(math.Y0(1.5))
fmt.Println(math.Y0(5))
fmt.Println(math.Y0(-1))
fmt.Println(math.Y0(-1.5))
fmt.Println(math.Y0(-5))
fmt.Println(math.Y0(0))
fmt.Println(math.Y0(math.Inf(1)))
fmt.Println(math.Y0(math.Inf(-1)))
fmt.Println(math.Y0(math.NaN()))
}
Output:
0.08825696421567697
0.3824489237977589
-0.30851762524903376
NaN
NaN
NaN
-Inf
0
NaN
NaN
Example 2
// Golang program to demonstrate the
// example of math.Y0() Function
package main
import (
"fmt"
"math"
)
func main() {
var x float64
var Y0X float64
x = 1
Y0X = math.Y0(x)
fmt.Println("Y0(", x, ") = ", Y0X)
x = 10.5
Y0X = math.Y0(x)
fmt.Println("Y0(", x, ") = ", Y0X)
x = 0
Y0X = math.Y0(x)
fmt.Println("Y0(", x, ") = ", Y0X)
x = math.NaN()
Y0X = math.Y0(x)
fmt.Println("Y0(", x, ") = ", Y0X)
x = math.Inf(1)
Y0X = math.Y0(x)
fmt.Println("Y0(", x, ") = ", Y0X)
x = math.Inf(-1)
Y0X = math.Y0(x)
fmt.Println("Y0(", x, ") = ", Y0X)
}
Output:
Y0( 1 ) = 0.08825696421567697
Y0( 10.5 ) = -0.0675303724978764
Y0( 0 ) = -Inf
Y0( NaN ) = NaN
Y0( +Inf ) = 0
Y0( -Inf ) = NaN
Golang math Package Constants and Functions »