The programming language Go uses the Y0
function to find the order-zero Bessel function of the second kind for any argument it is passed.
To use this function, you must import the math
package in your file and access the Y0
function within it using the .
notation (math.Y0
). Here, Y0
is the actual function, while math
is the Go package that stores the definition of this function.
The Bessel functions are canonical solutions to Bessel’s differential equation. These solutions are in the form:
In the equation above, subscript determines the order of the functions (the Bessel functions are defined for all real values of ). So, for , the produced solutions will be of order-zero.
In the equation above, represents the second solution to the Bessel equation, also known as the Bessel function of the second kind.
The definition of the Y0
function inside the math
package is shown below:
The Y0
function takes a single argument of type float64
that represents the number for which you want to find the second kind order-zero Bessel function.
The Y0
function returns a single value of type float64
that represents the second kind order-zero Bessel function of the given argument.
Some special cases are when you pass infinity, 0, or NAN
as an argument:
If the argument has a value of +Inf, the return value will be 0.
If the argument has a value of 0, the return value will be -Inf.
If the argument is a NAN
value or is less than 0 (a negative value), then the return value will be NAN
.
Below is a simple example where we find the second order-zero Bessel function of 5.35
.
package mainimport("fmt""math")func main() {var x float64 = 5.35y := math.Y0(x)fmt.Print("The second kind order-zero Bessel function of ", x," is ", y)}
The example below shows how the Y0
function deals with an argument with a value of positive infinity.
To generate the infinite value, we use the
Inf
function in themath
package.Inf
generates an infinite value with the same sign as the argument passed to it.
package mainimport("fmt""math")func main() {var x float64 = math.Inf(1)y := math.Y0(x)fmt.Print("The second kind order-zero Bessel function of ", x," is ", y, "\n")}
The example below shows how the Y0
function handles NAN
values.
Here, we use the
NaN
function present in themath
package to generate aNAN
value.
package mainimport("fmt""math")func main() {my_nan := math.NaN()y := math.Y0(my_nan)fmt.Print("The second kind order-zero Bessel function of ", my_nan," is ", y, "\n")}