How to Find the Sin and Cos Value of a Number in Golang? Last Updated : 21 Apr, 2020 Comments Improve Suggest changes Like Article Like Report Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the value of sin and cos of the specified number with the help of Sincos() function provided by the math package. So, you need to add a math package in your program with the help of the import keyword to access the Sincos() function. Syntax: func Sincos(a float64) (sin, cos float64) If you pass -Inf or +Inf in this function like Sincos(-Inf) or Sincos(+Inf), then this function will return NaN, NaN. If you pass -0 or +0 in this function like Sincos(-0) or Sincos(+0), then this function will return -0 or +0, 1. If you pass NaN in this function like Sincos(NaN), then this function will return NaN, NaN. Example 1: C // Golang program to illustrate the Sincos() Function package main import ( "fmt" "math" ) // Main function func main() { // Using Sincos() function res_1, res_2 := math.Sincos(math.Pi / 3) res_3, res_4 := math.Sincos(0) res_5, res_6 := math.Sincos(math.Inf(-1)) res_7, res_8 := math.Sincos(math.NaN()) res_9, res_10 := math.Sincos(math.Pi) // Displaying the result fmt.Printf("Result 1: %.1f, %.1f", res_1, res_2) fmt.Printf("\nResult 2: %.1f, %.1f", res_3, res_4) fmt.Printf("\nResult 3: %.1f, %.1f", res_5, res_6) fmt.Printf("\nResult 4: %.1f, %.1f", res_7, res_8) fmt.Printf("\nResult 5: %.1f, %.1f", res_9, res_10) } Output: Result 1: 0.9, 0.5 Result 2: 0.0, 1.0 Result 3: NaN, NaN Result 4: NaN, NaN Result 5: 0.0, -1.0 Example 2: C // Golang program to illustrate the Sincos() Function package main import ( "fmt" "math" ) // Main function func main() { // Using Sincos() function nvalue_1, nvalue_2 := math.Sincos(math.Pi / 2) nvalue_3, nvalue_4 := math.Sincos(math.Pi / 3) // Sum of the given sin values res1 := nvalue_1 + nvalue_3 fmt.Println("Sum of Sin Values:") fmt.Printf("%.2f + %.2f = %.2f\n", nvalue_1, nvalue_3, res1) // Sum of the given cos values res2 := nvalue_2 + nvalue_4 fmt.Println("Sum of Cos Values:") fmt.Printf("%.2f + %.2f = %.2f", nvalue_2, nvalue_4, res2) } Output: Sum of Sin Values: 1.00 + 0.87 = 1.87 Sum of Cos Values: 0.00 + 0.50 = 0.50 Comment More infoAdvertise with us Next Article Go Programming Language (Introduction) K Kirti_Mangal Follow Improve Article Tags : Go Language Similar Reads Go Tutorial Go or you say Golang is a procedural and statically typed programming language having the syntax similar to C programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language and mainly used in Google 2 min read Go Programming Language (Introduction) Go is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports env 11 min read time.Sleep() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Sleep() function in Go language is used to stop the latest go-routine for at least the stated duration d. And a negative or zero duration of sleep will cause this method to return instantly. Moreover, t 3 min read Golang Tutorial - Learn Go Programming Language This Golang tutorial provides you with all the insights into Go Language programming, Here we provide the basics, from how to install Golang to advanced concepts of Go programming with stable examples. So, if you are a professional and a beginner, this free Golang tutorial is the best place for your 10 min read Top 10 Golang Project Ideas with Source Code in 2025 Golang, or Go, a programming language was created by Google. It's widely used for building different kinds of applications like websites and cloud services. The fastest way to master this language is by building projects related to it. This article introduces 10 beginner-friendly to medium-difficult 8 min read Interfaces in Golang In Go, an interface is a type that lists methods without providing their code. You canât create an instance of an interface directly, but you can make a variable of the interface type to store any value that has the needed methods.Exampletype Shape interface { Area() float64 Perimeter() float64}In t 3 min read Data Types in Go Data types specify the type of data that a valid Go variable can hold. In Go language, the type is divided into four categories which are as follows: Basic type: Numbers, strings, and booleans come under this category.Aggregate type: Array and structs come under this category.Reference type: Pointer 7 min read strings.Contains Function in Golang with Examples strings.Contains Function in Golang is used to check the given letters present in the given string or not. If the letter is present in the given string, then it will return true, otherwise, return false. Syntax:Â func Contains(str, substr string) bool Here, str is the original string and substr is t 2 min read fmt.Sprintf() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sprintf() function in Go language formats according to a format specifier and returns the resulting string. Moreover, this function is defined under the fmt package. Here, you 2 min read Goroutines - Concurrency in Golang Goroutines in Go let functions run concurrently, using less memory than traditional threads. Every Go program starts with a main Goroutine, and if it exits, all others stop.Examplepackage mainimport "fmt"func display(str string) { for i := 0; i < 3; i++ { fmt.Println(str) }}func main() { go displ 2 min read Like