×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang math.Y1() Function with Examples

Golang | math.Y1() Function: Here, we are going to learn about the Y1() function of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 04, 2021

math.Y1()

The Y1() function is an inbuilt function of the math package which is used to get the order-one Bessel function of the second kind.

It accepts a parameter (x) and returns the order-one Bessel function of the second kind.

Syntax

func Y1(x float64) float64

Parameters

  • x : The value to be used to get the order-one Bessel function of the second kind.

Return Value

The return type of Y1() function is a float64, it returns the order-one Bessel function of the second kind.

Special Cases

  • Y1(+Inf) = 0
    If the parameter is +Inf, the function returns 0.
  • Y1(0) = -Inf
    If the parameter is 0, the function returns -Inf.
  • Y1(x < 0) = NaN
    If the parameter is less than 0, the function returns NaN.
  • Y1(NaN) = NaN
    If the parameter is NaN, the function returns the same value (NaN).

Example 1

// Golang program to demonstrate the
// example of math.Y1() Function

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println(math.Y1(1))
	fmt.Println(math.Y1(1.5))
	fmt.Println(math.Y1(5))

	fmt.Println(math.Y1(-1))
	fmt.Println(math.Y1(-1.5))
	fmt.Println(math.Y1(-5))

	fmt.Println(math.Y1(0))
	fmt.Println(math.Y1(math.Inf(1)))
	fmt.Println(math.Y1(math.Inf(-1)))
	fmt.Println(math.Y1(math.NaN()))
}

Output:

-0.7812128213002887
-0.4123086269739113
0.1478631433912268
NaN
NaN
NaN
-Inf
0
NaN
NaN

Example 2

// Golang program to demonstrate the
// example of math.Y1() Function

package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	var Y1X float64

	x = 1
	Y1X = math.Y1(x)
	fmt.Println("Y1(", x, ") = ", Y1X)

	x = 10.5
	Y1X = math.Y1(x)
	fmt.Println("Y1(", x, ") = ", Y1X)

	x = 0
	Y1X = math.Y1(x)
	fmt.Println("Y1(", x, ") = ", Y1X)

	x = math.NaN()
	Y1X = math.Y1(x)
	fmt.Println("Y1(", x, ") = ", Y1X)

	x = math.Inf(1)
	Y1X = math.Y1(x)
	fmt.Println("Y1(", x, ") = ", Y1X)

	x = math.Inf(-1)
	Y1X = math.Y1(x)
	fmt.Println("Y1(", x, ") = ", Y1X)
}

Output:

Y1( 1 ) =  -0.7812128213002887
Y1( 10.5 ) =  0.23370422835726865
Y1( 0 ) =  -Inf
Y1( NaN ) =  NaN
Y1( +Inf ) =  0
Y1( -Inf ) =  NaN

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.