Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

GoLang – Find Inverse of Cosine – Acos() Function – Examples & Explanation

Acos() function can be used to find the inverse of a cosine in Go language. The inverse of a cosine is also known as the arc cosine.
The standard math library of Go programming language has Acos() function. The purpose of this function is to calculate arc cosine or the inverse of the cosine of any given numeric value in the range of -1 and 1.

Syntax of Acos() Function in GoLang

The syntax of Acos() function in Go Language is:

Note: float64 is a data type in go language which has IEEE-754 64-bit floating-point numbers.
A special case is:
Acos(x) = NaN if x < -1 or x > 1


Parameters of Acos() Function in GoLang

x – Any Valid Input value (positive or negative within the range of -1 and 1). This parameter is required.
Note: If the x parameter is not a number, Acos() function will return an error.


Return Value of Acos() Function in GoLang

Acos() function will return the arc cosine (inverse of cosine) in radians of the given input (x – parameters).


GoLang Acos() Function Example

Output of GoLang Acos() function:

Note: The input value (x – parameter) should be in the range of (-1 to 1). Any other number will return NaN. But if your input is not a number (you enter character like: a, !, Z) then the compiler will surely give you an error.


LearnAndLearn.com © 2018 - All rights reserved