Add sin, cos and tan trigonometric functions - #2065
Conversation
| switch arg.(type) { | ||
| case int, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64: | ||
| return math.Sin(ToFloat64(arg)) | ||
| default: |
There was a problem hiding this comment.
This currently does not account for complex numbers, but they're also valid in custom commands (do not ask how I know...). The sine of a complex number can be defined as
I'd suggest we
- add complex numbers as a valid input to these function as well using the definition above, or
- also add the hyperbolic functions.
Personally I'm leaning towards both; the hyperbolic functions may have some interesting properties as well and given that we're already here, why not.
| } | ||
| } | ||
|
|
||
| func tmplCos(arg interface{}) float64 { |
There was a problem hiding this comment.
The complex cosine can be defined as
| } | ||
| } | ||
|
|
||
| func tmplTan(arg interface{}) float64 { |
There was a problem hiding this comment.
Similarly,
This PR adds
sin,cosandtantrigonometric functions from the math package.