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

    angle

    Required: Yes
  • COS

    angle

    Required: Yes
  • TAN

    angle

    Required: Yes
  • ASIN

    value

    Required: Yes
  • ACOS

    value

    Required: Yes
  • ATAN

    value

    Required: Yes
  • SINH

    number

    Required: Yes
  • TANH

    number

    Required: Yes
  • ASINH

    number

    Required: Yes
  • ACOSH

    number

    Required: Yes
  • ATANH

    number

    Required: Yes
  • DEGREES

    radians

    Required: Yes
  • RADIANS

    degrees

    Required: Yes
  • SEC

    angle

    Required: Yes
  • COT

    angle

    Required: Yes
  • CSC

    angle

    Required: Yes
  • ACOT

    number

    Required: Yes
  • COTH

    number

    Required: Yes
  • CSCH

    number

    Required: Yes
  • SECH

    number

    Required: Yes

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.

FunctionReturnsBehaviourForm
SINdecimalThe sineSIN(0.5)
COSdecimalThe cosineCOS(0.5)
TANdecimalThe tangentTAN(0.5)
ASINdecimalThe angle in radians whose sine is the valueASIN(1.0)
ACOSdecimalThe angle in radians whose cosine is the valueACOS(1.0)
ATANdecimalThe angle in radians whose tangent is the valueATAN(1.0)
SINHdecimalThe hyperbolic sineSINH(1.0)
TANHdecimalThe hyperbolic tangentTANH(1.0)
ASINHdecimalThe inverse hyperbolic sineASINH(1.0)
ACOSHdecimalThe inverse hyperbolic cosineACOSH(2.0)
ATANHdecimalThe inverse hyperbolic tangentATANH(0.5)
DEGREESdecimalThe angle in degreesDEGREES(3.14159)
RADIANSdecimalThe angle in radiansRADIANS(180.0)
SECdecimalThe secantSEC(0.5)
COTdecimalThe cotangentCOT(1.0)
CSCdecimalThe cosecantCSC(1.0)
ACOTdecimalThe inverse cotangent in radians, worked out as the arctangent of 1 divided by the number. Zero gives half of piACOT(2.0)
COTHdecimalThe hyperbolic cotangent. Zero is refused with HTQL-8002COTH(1.5)
CSCHdecimalThe hyperbolic cosecant. Zero is refused with HTQL-8002CSCH(1.5)
SECHdecimalThe hyperbolic secant, 1 divided by the hyperbolic cosineSECH(1.5)
Errors and exceptions
ErrorWhat happenedHow to recover
HTQL-5001The function was given the wrong number of arguments. The message names the function and the countsGive it the arguments listed under Parameters
HTQL-1004 Unsupported functionThe name is not a function this engine runsCheck the name and its spelling against this entry
HTQL-2005 Conversion errorThe argument is not a number, such as SIN("x")Pass a number
HTQL-2002ATANH was given a value outside -1 to 1Pass a value strictly between -1 and 1
HTQL-8002CSC(0) or a COT of a multiple of pi divides by zeroAvoid those angles
Limitations
  • Write an argument as a decimal, such as 0.5 or 0.0.
  • ACOS and ACOSH return a wrapped number that ROUND refuses: ROUND(ACOS(0.5), 4) answers HTQL-2001 "Expected a numeric value, ExcelValue(F64(1.0471975511965976))". Convert first with DEGREES(ACOS(0.5)), or return the value unrounded.
  • Keep ASIN and ACOS to values from -1 to 1 and ACOSH to 1 or more. The engine does not refuse a value outside the range in these three: ASIN(2.0) answers 0, and ACOS(2.0) and ACOSH(0.5) stop with the message called Option::unwrap() on a None value.
  • ATANH refuses a value that is not strictly between -1 and 1, and CSC(0) is refused as a division by zero.
  • COSH and ATAN2 are not available: the engine answers HTQL-1004 Unsupported 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.