All Products
Search
Document Center

PolarDB:Trigonometric functions

Last Updated:Mar 28, 2026

AGE provides the following trigonometric functions for use in Cypher queries. All functions accept agtype numeric expressions and return an agtype floating-point number.

Function overview

FunctionSignatureDescription
degreesdegrees(expression)Converts an angle from radians to degrees.
radiansradians(expression)Converts an angle from degrees to radians.
pipi()Returns the mathematical constant π (approximately 3.14159265358979).
sinsin(expression)Returns the sine of an angle in radians.
coscos(expression)Returns the cosine of an angle in radians.
tantan(expression)Returns the tangent of an angle in radians.
cotcot(expression)Returns the cotangent of an angle in radians.
asinasin(expression)Returns the arcsine of a value in [-1, 1], in radians.
acosacos(expression)Returns the arccosine of a value in [-1, 1], in radians.
atanatan(expression)Returns the arctangent of a number, in radians.
atan2atan2(expression1, expression2)Returns the arctangent of the point (x, y), in radians.

degrees

Converts an angle from radians to degrees.

Syntax

degrees(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in radians.

Returns

agtype floating-point number.

Usage notes

degrees(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN degrees(3.14159)
$$) as (deg agtype);

The angle close to π radians is converted to degrees:

       deg
------------------
 179.999847960504
(1 row)

radians

Converts an angle from degrees to radians.

Syntax

radians(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in degrees.

Returns

agtype floating-point number.

Usage notes

radians(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN radians(180)
$$) as (rad agtype);

180 degrees is converted to the radian value of π:

       rad
------------------
 3.14159265358979
(1 row)

pi

Returns the mathematical constant π.

Syntax

pi()

Parameters

None.

Returns

agtype floating-point number.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN pi()
$$) as (p agtype);
        p
------------------
 3.14159265358979
(1 row)

sin

Returns the sine of an angle.

Syntax

sin(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in radians.

Returns

agtype floating-point number.

Usage notes

sin(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN sin(0.5)
$$) as (s agtype);
         s
-------------------
 0.479425538604203
(1 row)

cos

Returns the cosine of an angle.

Syntax

cos(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in radians.

Returns

agtype floating-point number.

Usage notes

cos(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN cos(0.5)
$$) as (c agtype);
         c
-------------------
 0.877582561890373
(1 row)

tan

Returns the tangent of an angle.

Syntax

tan(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in radians.

Returns

agtype floating-point number.

Usage notes

tan(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN tan(0.5)
$$) as (t agtype);
        t
------------------
 0.54630248984379
(1 row)

cot

Returns the cotangent of an angle.

Syntax

cot(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in radians.

Returns

agtype floating-point number.

Usage notes

cot(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN cot(0.5)
$$) as (t agtype);
        t
------------------
 1.83048772171245
(1 row)

asin

Returns the arcsine of a number. The input must be in the range [-1, 1].

Syntax

asin(expression)

Parameters

ParameterTypeDescription
expressionagtype numberAn agtype number expression that represents the angle in radians.

Returns

agtype floating-point number.

Usage notes

  • asin(null) returns null.

  • If expression < -1 or expression > 1, asin(expression) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN asin(0.5)
$$) as (arc_s agtype);
       arc_s
-------------------
 0.523598775598299
(1 row)

acos

Returns the arccosine of a number. The input must be in the range [-1, 1].

Syntax

acos(expression)

Parameters

ParameterTypeDescription
expressionagtype numberAn agtype number expression that represents the angle in radians.

Returns

agtype floating-point number.

Usage notes

  • acos(null) returns null.

  • If expression < -1 or expression > 1, acos(expression) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN acos(0.5)
$$) as (arc_c agtype);
      arc_c
-----------------
 1.0471975511966
(1 row)

atan

Returns the arctangent of a number.

Syntax

atan(expression)

Parameters

ParameterTypeDescription
expressionagtype numberThe angle in radians.

Returns

agtype floating-point number.

Usage notes

atan(null) returns null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN atan(0.5)
$$) as (arc_t agtype);
       arc_t
-------------------
 0.463647609000806
(1 row)

atan2

Returns the arctangent of the point (x, y) in radians. Unlike atan, this function takes two arguments to determine the correct quadrant of the result.

Syntax

atan2(expression1, expression2)

Parameters

ParameterTypeDescription
expression1agtype numberAn agtype number expression for y that represents the angle in radians.
expression2agtype numberAn agtype number expression for x that represents the angle in radians.

Returns

agtype floating-point number.

Usage notes

atan2(null, null), atan2(null, expression2), and atan2(expression1, null) return null.

Example

SELECT *
FROM cypher('graph_name', $$
    RETURN atan2(0.5, 0.6)
$$) as (arc_t2 agtype);
      arc_t2
-------------------
 0.694738276196703
(1 row)