Open In App

complx.Exp() Function in Golang With Examples

Last Updated : 28 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

complx.Exp() Function in Golang is used to returns e**x, the base-e exponential of x.

Syntax:

func Exp(x complex128) complex128

Here, x is the set of all complex numbers real as well as imaginary parts.

Return Type: The return type of this function is a complex number.

Example 1:




// Golang program to illustrate
// the complx.Exp() Function
  
package main
  
// importing fmt and math/cmplx
import (
"fmt"
"math/cmplx"
)
  
// Calling main method
func main() {
      
    // using the function
    fmt.Printf("%.2f", cmplx.Exp(5 + 6i))
}


Output:

(142.50-41.47i)

Example 2:




// Golang program to illustrate
// the complx.Exp() Function
  
package main
  
// importing fmt and math/cmplx
import (
"fmt"
"math/cmplx"
)
  
// Calling main method
func main() {
      
    n := complex(7, 8)
      
    // using the function
    fmt.Printf("%.2f", cmplx.Exp(n))
}


Output:

(-159.56+1084.96i)

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads