Menu Close

Go – How to get the order-n Bessel function of the second kind in go

Here, We will learn how to get the order-n Bessel function of the second kind in go. We can get it by using Yn() function in math package in go golang.

Function prototype:

func Yn(n int, x float64) float64

Return value:

Yn() function in math package returns 
the order-n Bessel function of the second kind.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Yn(2, 1.2)
  fmt.Println(no)

  no = math.Yn(3, -2.7)
  fmt.Println(no)

  no = math.Yn(0, 0.0)
  fmt.Println(no)

  no = math.Yn(5, 2.9)
  fmt.Println(no)

  no = math.Yn(2, 5)
  fmt.Println(no)
}

Output:

-1.2633108028086102
NaN
-Inf
-2.1542769359321716
0.3676628826055245

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, math

Leave a Reply

Your email address will not be published. Required fields are marked *