ADVERTISEMENT
ADVERTISEMENT

Golang math.Asin() Function with Examples

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

math.Asin()

The Asin() function is an inbuilt function of the math package which is used to get the arcsine value (in radians) of the given value.

It accepts one parameter and returns the arcsine.

Syntax:

func Asin(x float64) float64

Parameter(s):

  • x : The value whose arcsine value is to be found.

Return Value:

The return type of Asin() function is a float64, it returns the arcsine value (in radians) of the given value.

Special cases are:

  • Asin(±0) = ±0
    If the parameter is either positive or negative zero (±0), it returns the same (±0).
  • Asin(x) = NaN if x < -1 or x > 1
    If the parameter is either less than -1 or greater than 1, it returns the NaN.

Example 1:

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

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println(math.Asin(1))
	fmt.Println(math.Asin(0.23))

	fmt.Println(math.Asin(-1))
	fmt.Println(math.Asin(-0.23))

	fmt.Println(math.Asin(-1.23))
	fmt.Println(math.Asin(1.23))

	fmt.Println(math.Asin(-0))
	fmt.Println(math.Asin(0))
}

Output:

1.5707963267948966
0.23207768286271319
-1.5707963267948966
-0.23207768286271319
NaN
NaN
0
0

Example 2:

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	var AsinX float64

	x = 0
	AsinX = math.Asin(x)
	fmt.Println("Arcsine value of", x, "is", AsinX)

	x = 0.23
	AsinX = math.Asin(x)
	fmt.Println("Arcsine value of", x, "is", AsinX)

	x = 1
	AsinX = math.Asin(x)
	fmt.Println("Arcsine value of", x, "is", AsinX)

	x = -0.23
	AsinX = math.Asin(x)
	fmt.Println("Arcsine value of", x, "is", AsinX)

	x = -2
	AsinX = math.Asin(x)
	fmt.Println("Arcsine value of", x, "is", AsinX)

	x = 10
	AsinX = math.Asin(x)
	fmt.Println("Arcsine value of", x, "is", AsinX)
}

Output:

Arcsine value of 0 is 0
Arcsine value of 0.23 is 0.23207768286271319
Arcsine value of 1 is 1.5707963267948966
Arcsine value of -0.23 is -0.23207768286271319
Arcsine value of -2 is NaN
Arcsine value of 10 is NaN

Golang math Package Constants and Functions »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.