Finding the Decimal Logarithm of Complex Number in Golang Last Updated : 27 Mar, 2020 Comments Improve Suggest changes Like Article Like Report Go language provides inbuilt support for basic constants and mathematical functions for complex numbers with the help of the cmplx package. You are allowed to find the decimal logarithm of the specified complex number with the help of Log10() function provided by the math/cmplx package. So, you need to add a math/cmplx package in your program with the help of the import keyword to access the Log10() function. Syntax: func Log10(y complex128) complex128 Example 1: C // Golang program to illustrate how to find the // decimal logarithm of the given complex number package main import ( "fmt" "math/cmplx" ) // Main function func main() { // Finding decimal logarithm of // the specified complex number // Using Log10() function res_1 := cmplx.Log10(1i) res_2 := cmplx.Log10(-4 + 12i) res_3 := cmplx.Log10(-3 - 9i) // Displaying the result fmt.Printf("Result 1: %.1f", res_1) fmt.Printf("\nResult 2: %.1f", res_2) fmt.Printf("\nResult 3: %.1f", res_3) } Output: Result 1: (0.0+0.7i) Result 2: (1.1+0.8i) Result 3: (1.0-0.8i) Example 2: C // Golang program to illustrate how to find the // decimal logarithm of the given complex number package main import ( "fmt" "math/cmplx" ) // Main function func main() { cnumber_1 := complex(0, 2) cnumber_2 := complex(4, 6) // Finding decimal logarithm cvalue_1 := cmplx.Log10(cnumber_1) cvalue_2 := cmplx.Log10(cnumber_2) // Sum of the given values res := cvalue_1 + cvalue_2 // Displaying results fmt.Println("Complex Number 1: ", cnumber_1) fmt.Printf("Decimal logarithm 1: %.1f", cvalue_1) fmt.Println("\nComplex Number 2: ", cnumber_2) fmt.Printf("Decimal logarithm 2: %.1f ", cvalue_2) fmt.Printf("\nSum : %.1f", res) } Output: Complex Number 1: (0+2i) Decimal logarithm 1: (0.3+0.7i) Complex Number 2: (4+6i) Decimal logarithm 2: (0.9+0.4i) Sum : (1.2+1.1i) Create Quiz Comment K Kirti_Mangal Follow 0 Improve K Kirti_Mangal Follow 0 Improve Article Tags : Go Language Golang-Complex Explore OverviewGo Programming Language (Introduction) 7 min read How to Install Go on Windows? 3 min read How to Install Golang on MacOS? 4 min read Hello World in Golang 3 min read FundamentalsIdentifiers in Go Language 3 min read Go Keywords 2 min read Data Types in Go 7 min read Go Variables 9 min read Constants- Go Language 6 min read Go Operators 9 min read Control StatementsGo Decision Making (if, if-else, Nested-if, if-else-if) 5 min read Loops in Go Language 5 min read Switch Statement in Go 2 min read Functions & MethodsFunctions in Go Language 3 min read Variadic Functions in Go 3 min read Anonymous function in Go Language 2 min read main and init function in Golang 2 min read What is Blank Identifier(underscore) in Golang? 3 min read Defer Keyword in Golang 3 min read Methods in Golang 3 min read StructureStructures in Golang 7 min read Nested Structure in Golang 3 min read Anonymous Structure and Field in Golang 3 min read ArraysArrays in Go 7 min read How to Copy an Array into Another Array in Golang? 3 min read How to pass an Array to a Function in Golang? 2 min read SlicesSlices in Golang 14 min read Slice Composite Literal in Go 3 min read How to sort a slice of ints in Golang? 2 min read How to trim a slice of bytes in Golang? 3 min read How to split a slice of bytes in Golang? 3 min read StringsStrings in Golang 7 min read How to Trim a String in Golang? 2 min read How to Split a String in Golang? 3 min read Different ways to compare Strings in Golang 2 min read PointersPointers in Golang 8 min read Passing Pointers to a Function in Go 3 min read Pointer to a Struct in Golang 3 min read Go Pointer to Pointer (Double Pointer) 4 min read Comparing Pointers in Golang 3 min read ConcurrencyGoroutines - Concurrency in Golang 2 min read Select Statement in Go Language 4 min read Multiple Goroutines 2 min read Channel in Golang 7 min read Unidirectional Channel in Golang 2 min read Like