Menu Close

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

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

Function prototype:

func Jn(num float64) float64

Return value:

Jn() function in math package returns
the order-n Bessel function of the
first kind

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Jn(1, 2.51)
  fmt.Printf("%.1f\n", no)

  no = math.Jn(2, 2.39)
  fmt.Printf("%.1f\n", no)

  no = math.Jn(0, 3.12)
  fmt.Printf("%.1f\n", no)

  no = math.Jn(3, -3.21)
  fmt.Printf("%.1f\n", no)
}

Output:

0.5
0.4
-0.3
-0.3

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

https://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 *