Trigonometry
Examples in
Go
package main
import (
"fmt"
"math"
)
func main() {
c := math.Hypot(3, 4)
fmt.Printf("%.1f", c)
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Sin(math.Pi))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Cos(math.Pi/2))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Tan(0))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Asin(0))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Acos(1))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Atan(0))
}
Computes the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.
package main
import (
"fmt"
"math"
)
/*
Special Cases:
Atan2(y, NaN) = NaN
Atan2(NaN, x) = NaN
Atan2(+0, x>=0) = +0
Atan2(-0, x>=0) = -0
Atan2(+0, x<=-0) = +Pi
Atan2(-0, x<=-0) = -Pi
Atan2(y>0, 0) = +Pi/2
Atan2(y<0, 0) = -Pi/2
Atan2(+Inf, +Inf) = +Pi/4
Atan2(-Inf, +Inf) = -Pi/4
Atan2(+Inf, -Inf) = 3Pi/4
Atan2(-Inf, -Inf) = -3Pi/4
Atan2(y, +Inf) = 0
Atan2(y>0, -Inf) = +Pi
Atan2(y<0, -Inf) = -Pi
Atan2(+Inf, x) = +Pi/2
Atan2(-Inf, x) = -Pi/2
*/
func main() {
fmt.Printf("%.2f", math.Atan2(0, 0))
}
Last Run
:
0.00
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Sinh(0))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Cosh(0))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Tanh(0))
}
Last Run
:
0.00
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Asinh(0))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Acosh(2))
}
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Atanh(0))
}