Trigonometry functions
Work with angles and waves directly in a statement.
Syntax
Write the function's name and a number. Angles are in radians.
SIN(angle)
COS(angle)
TAN(angle)
ASIN(value)
ACOS(value)
ATAN(value)
SINH(number)
TANH(number)
ASINH(number)
ACOSH(number)
ATANH(number)
DEGREES(radians)
RADIANS(degrees)
SEC(angle)
COT(angle)
CSC(angle)
ACOT(number)
COTH(number)
CSCH(number)
SECH(number)Parameters and arguments
Arguments are written in brackets, separated by commas. An argument in square brackets is optional.
SIN
Required: YesangleCOS
Required: YesangleTAN
Required: YesangleASIN
Required: YesvalueACOS
Required: YesvalueATAN
Required: YesvalueSINH
Required: YesnumberTANH
Required: YesnumberASINH
Required: YesnumberACOSH
Required: YesnumberATANH
Required: YesnumberDEGREES
Required: YesradiansRADIANS
Required: YesdegreesSEC
Required: YesangleCOT
Required: YesangleCSC
Required: YesangleACOT
Required: YesnumberCOTH
Required: YesnumberCSCH
Required: YesnumberSECH
Required: Yesnumber
Examples
SIN, COS and TAN work in radians, so a bearing in degrees is converted first and an answer in radians is converted back.
Return type and behaviour
Each function returns one value. The table shows its type, what it does and one way to write it; the examples use the functions in realistic statements.
| Function | Returns | Behaviour | Form |
|---|---|---|---|
SIN | decimal | The sine | SIN(0.5) |
COS | decimal | The cosine | COS(0.5) |
TAN | decimal | The tangent | TAN(0.5) |
ASIN | decimal | The angle in radians whose sine is the value | ASIN(1.0) |
ACOS | decimal | The angle in radians whose cosine is the value | ACOS(1.0) |
ATAN | decimal | The angle in radians whose tangent is the value | ATAN(1.0) |
SINH | decimal | The hyperbolic sine | SINH(1.0) |
TANH | decimal | The hyperbolic tangent | TANH(1.0) |
ASINH | decimal | The inverse hyperbolic sine | ASINH(1.0) |
ACOSH | decimal | The inverse hyperbolic cosine | ACOSH(2.0) |
ATANH | decimal | The inverse hyperbolic tangent | ATANH(0.5) |
DEGREES | decimal | The angle in degrees | DEGREES(3.14159) |
RADIANS | decimal | The angle in radians | RADIANS(180.0) |
SEC | decimal | The secant | SEC(0.5) |
COT | decimal | The cotangent | COT(1.0) |
CSC | decimal | The cosecant | CSC(1.0) |
ACOT | decimal | The inverse cotangent in radians, worked out as the arctangent of 1 divided by the number. Zero gives half of pi | ACOT(2.0) |
COTH | decimal | The hyperbolic cotangent. Zero is refused with HTQL-8002 | COTH(1.5) |
CSCH | decimal | The hyperbolic cosecant. Zero is refused with HTQL-8002 | CSCH(1.5) |
SECH | decimal | The hyperbolic secant, 1 divided by the hyperbolic cosine | SECH(1.5) |
Errors and exceptions
| Error | What happened | How to recover |
|---|---|---|
HTQL-5001 | The function was given the wrong number of arguments. The message names the function and the counts | Give it the arguments listed under Parameters |
HTQL-1004 Unsupported function | The name is not a function this engine runs | Check the name and its spelling against this entry |
HTQL-2005 Conversion error | The argument is not a number, such as SIN("x") | Pass a number |
HTQL-2002 | ATANH was given a value outside -1 to 1 | Pass a value strictly between -1 and 1 |
HTQL-8002 | CSC(0) or a COT of a multiple of pi divides by zero | Avoid those angles |
Limitations
- Write an argument as a decimal, such as
0.5or0.0. ACOSandACOSHreturn a wrapped number thatROUNDrefuses:ROUND(ACOS(0.5), 4)answersHTQL-2001"Expected a numeric value, ExcelValue(F64(1.0471975511965976))". Convert first withDEGREES(ACOS(0.5)), or return the value unrounded.- Keep
ASINandACOSto values from -1 to 1 andACOSHto 1 or more. The engine does not refuse a value outside the range in these three:ASIN(2.0)answers 0, andACOS(2.0)andACOSH(0.5)stop with the messagecalled Option::unwrap() on a None value. ATANHrefuses a value that is not strictly between -1 and 1, andCSC(0)is refused as a division by zero.COSHandATAN2are not available: the engine answersHTQL-1004Unsupported function.
Permissions and security
These functions read nothing from your tables and write nothing.
When a function is applied to a column or a variable, the statement that reads the data needs read access, as its own entry says.
Best practices
- Convert degrees with RADIANS before you call SIN, COS or TAN.
- Use DEGREES to show an angle a reader expects in degrees.