Go Expm1()
Anonymous contributor
Published Oct 19, 2023
Contribute to Docs
The Expm1() function calculates e (the base of the natural logarithm) raised to the given argument minus one. The formula is written as follows:
Syntax
import math
value := math.Expm1(x)
Where value will contain the result of the calculation using the passed argument, x, returned as a float64.
Special cases:
Expm1(+Inf)yields+InfExpm1(-Inf)yields-1Expm1(NaN)yieldsNaN
Example
The example below demonstrates the basic use of Expm1():
package mainimport ("fmt""math")func main() {result := math.Expm1(2)fmt.Printf("%.1f\n", result)}
The output will be:
6.4
Codebyte Example
The following example is runnable and shows how the Expm1() function handles special cases:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Go on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use Go (Golang), an open-source programming language supported by Google!
- Beginner Friendly.6 hours