DEV Community

Talha Munir 🇵🇸
Talha Munir 🇵🇸

Posted on • Updated on

Trigonometric functions in age part 1

In this post we will be discussing the trigonometric functions in age. Following descriptions represents the function name, it's description, syntax, what it possibly returns, and a sample query.

degrees:

Degrees convert radians into degrees.

Syntax:

degrees(a numeric expression)
A numeric function can be any number or an expression resulting into a number

Returns:

The function returns a agtype float.

Query:

SELECT *
FROM cypher('your_graph_name', $$
    RETURN degrees(3.14159)
$$) as (deg agtype);
Enter fullscreen mode Exit fullscreen mode

Above query will return the number of degrees something close to pi.

radians:

Radians convert radians into degrees.

Syntax:

radians(a numeric expression)
A numeric function can be any number or an expression resulting into a number

Returns:

The function returns a agtype float.

Query:

SELECT *
FROM cypher('your_graph_name', $$
    RETURN degrees(180)
$$) as (deg agtype);
Enter fullscreen mode Exit fullscreen mode

Above query will return the number of radians something close to pi i.e. 3.1415.

pi:

pi() returns the mathematical constant pi.

Syntax:

pi()

Returns:

The function returns a agtype float.

Query:

SELECT *
FROM cypher('your_graph_name', $$
    RETURN pi()
$$) as (p agtype);
Enter fullscreen mode Exit fullscreen mode

Above query will return pi which is 3.1415.

sin:

sin function returns the sine of a number.

Syntax:

sin(a numeric expression)

Returns:

The function returns a agtype float.

Query:

SELECT *
FROM cypher('your_graph_name', $$
    RETURN sin(0.5)
$$) as (s agtype);
Enter fullscreen mode Exit fullscreen mode

Above query will return sin of 0.5.

cos:

cos() returns the cosine of the number provided.

Syntax:

cos(a numeric expression)

Returns:

The function returns a floating point number.

Query:

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

Above query will return the cosine of 0.5.

tan:

tan() function returns the tangent of a number.

Syntax:

tan(a numeric expression)

Returns:

The function returns a floating point number.

Query:

SELECT *
FROM cypher('your_graph_name', $$
    RETURN tan(0.5)
$$) as (t agtype);
Enter fullscreen mode Exit fullscreen mode

Above query will return the tangent of 0.5.

You can also refer here to the part2

References:

You can view more on GitHub and documentation of Apache age by following these links:

  1. https://age.apache.org/age-manual/master/intro/overview.html
  2. https://github.com/apache/age
  3. https://dev.to/talhahahae/numeric-functions-in-apache-age-34ga
  4. https://dev.to/talhahahae/logarithmic-functions-1nbl

Top comments (0)