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