Trigonometric Functions

degrees()

degrees() converts an angle measured in radians to degrees.

Syntax: degrees(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in radians.

Notes:

  • degrees(null) returns null.

Query:

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

Returns the degree equivalent of a radian value close to π.

Result:

deg
179.99984796050427
1 row

radians()

radians() converts an angle measured in degrees to radians.

Syntax: radians(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in degrees.

Notes:

  • radians(null) returns null.

Query:

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

Returns a radian value close to π.

Result:

rad
3.14159265358979
1 row

pi()

pi() returns the mathematical constant π.

Syntax: pi()

Returns:

An agtype floating-point number.

Query:

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

Returns the constant π.

Result:

p
3.141592653589793
1 row

sin()

sin() returns the sine of a number.

Syntax: sin(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in radians.

Notes:

  • sin(null) returns null.

Query:

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

Returns the sine of 0.5.

Result:

s
0.479425538604203
1 row

cos()

cos() returns the cosine of a number.

Syntax: cos(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in radians.

Notes:

  • cos(null) returns null.

Query:

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

Returns the cosine of 0.5.

Result:

c
0.8775825618903728
1 row

tan()

tan() returns the tangent of a number.

Syntax: tan(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in radians.

Notes:

  • tan(null) returns null.

Query:

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

Returns the tangent of 0.5.

Result:

t
0.5463024898437905
1 row

cot()

cot() returns the cotangent of a number.

Syntax: cot(expression)

Returns:

A floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in radians.

Notes:

  • cot(null) returns null.

Query:

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

Returns the cotangent of 0.5.

Result:

t
1.830487721712452
1 row

asin()

asin() returns the arcsine (inverse sine) of a number.

Syntax: asin(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression.

Notes:

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

Query:

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

Returns the arcsine of 0.5.

Result:

arc_s
0.523598775598299
1 row

acos()

acos() returns the arccosine (inverse cosine) of a number.

Syntax: acos(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression.

Notes:

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

Query:

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

Returns the arccosine of 0.5.

Result:

arc_c
1.0471975511965979
1 row

atan()

atan() returns the arctangent (inverse tangent) of a number.

Syntax: atan(expression)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression An agtype numeric expression representing an angle in radians.

Notes:

  • atan(null) returns null.

Query:

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

Returns the arctangent of 0.5.

Result:

arc_t
0.463647609000806
1 row

atan2()

atan2() returns the arctangent of the quotient of two numbers — i.e., the angle in radians between the positive x-axis and the ray from the origin to the point (x, y).

Syntax: atan2(expression1, expression2)

Returns:

An agtype floating-point number.

Parameters:

Name Description
expression1 An agtype numeric expression representing the y-coordinate.
expression2 An agtype numeric expression representing the x-coordinate.

Notes:

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

Query:

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

Returns the arctangent of 0.5 and 0.6.

Result:

arc_t2
0.694738276196703
1 row