These functions all operate on numerical expressions only, and will return an error if used on any other values.
See also Section 8.4.1, “Mathematical operators”.
ABS returns the absolute value of a number.
Syntax: ABS( expression )
Arguments:
Query.
MATCH (a),(e) WHERE a.name = 'Alice' AND e.name = 'Eskil' RETURN a.age, e.age, abs(a.age - e.age)
The absolute value of the age difference is returned.
ACOS returns the arccosine of the expression, in radians.
Syntax: ACOS( expression )
Arguments:
Query.
RETURN acos(0.5)
The arccosine of 0.5.
ASIN returns the arcsine of the expression, in radians.
Syntax: ASIN( expression )
Arguments:
Query.
RETURN asin(0.5)
The arcsine of 0.5.
ATAN returns the arctangent of the expression, in radians.
Syntax: ATAN( expression )
Arguments:
Query.
RETURN atan(0.5)
The arctangent of 0.5.
ATAN2 returns the arctangent2 of a set of coordinates, in radians.
Syntax: ATAN2( expression , expression)
Arguments:
Query.
RETURN atan2(0.5, 0.6)
The arctangent2 of 0.5, 0.6.
COS returns the cosine of the expression.
Syntax: COS( expression )
Arguments:
Query.
RETURN cos(0.5)
The cosine of 0.5 is returned.
COT returns the cotangent of the expression.
Syntax: COT( expression )
Arguments:
Query.
RETURN cot(0.5)
The cotangent of 0.5 is returned.
DEGREES converts radians to degrees.
Syntax: DEGREES( expression )
Arguments:
Query.
RETURN degrees(3.14159)
The number of degrees in something close to pi.
E returns the constant, e.
Syntax: E()
Arguments:
Query.
RETURN e()
The constant e is returned (the base of natural log).
EXP returns the value e raised to the power of the expression.
Syntax: EXP( expression )
Arguments:
Query.
RETURN exp(2)
The exp of 2 is returned: e2.
FLOOR returns the greatest integer less than or equal to the expression.
Syntax: FLOOR( expression )
Arguments:
Query.
RETURN floor(0.9)
The floor of 0.9 is returned.
HAVERSIN returns the half versine of the expression.
Syntax: HAVERSIN( expression )
Arguments:
Query.
RETURN haversin(0.5)
The haversine of 0.5 is returned.
The haversin function may be used to compute the distance on the surface of a sphere between two points (each given by their latitude and longitude). In this example the spherical distance (in km) between Berlin in Germany (at lat 52.5, lon 13.4) and San Mateo in California (at lat 37.5, lon -122.3) is calculated using an average earth radius of 6371 km.
Query.
CREATE (ber:City { lat: 52.5, lon: 13.4 }),(sm:City { lat: 37.5, lon: -122.3 })
RETURN 2 * 6371 * asin(sqrt(haversin(radians(sm.lat - ber.lat))+ cos(radians(sm.lat))*
cos(radians(ber.lat))* haversin(radians(sm.lon - ber.lon)))) AS dist
The distance between Berlin and San Mateo is returned (about 9129 km).
LOG returns the natural logarithm of the expression.
Syntax: LOG( expression )
Arguments:
Query.
RETURN log(27)
The log of 27 is returned.
LOG10 returns the base 10 logarithm of the expression.
Syntax: LOG10( expression )
Arguments:
Query.
RETURN log10(27)
The log10 of 27 is returned.
PI returns the mathmatical constant pi.
Syntax: PI()
Arguments:
Query.
RETURN pi()
The constant pi is returned.
RADIANS converts degrees to radians.
Syntax: RADIANS( expression )
Arguments:
Query.
RETURN radians(180)
The number of radians in 180 is returned (pi).
RAND returns a random double between 0 and 1.0.
Syntax: RAND( expression )
Arguments:
Query.
RETURN rand() AS x1
A random number is returned.
ROUND returns the numerical expression, rounded to the nearest integer.
Syntax: ROUND( expression )
Arguments:
Query.
RETURN round(3.141592)
SIGN returns the signum of a number — zero if the expression is zero, -1 for any negative number, and 1 for any positive number.
Syntax: SIGN( expression )
Arguments:
Query.
RETURN sign(-17), sign(0.1)
SIN returns the sine of the expression.
Syntax: SIN( expression )
Arguments:
Query.
RETURN sin(0.5)
The sine of 0.5 is returned.
SQRT returns the square root of a number.
Syntax: SQRT( expression )
Arguments:
Query.
RETURN sqrt(256)
Copyright © 2014 Neo Technology