math
Enables scientific calculator functionality.
Synopsis
math('math\_function')
Description
The math()
step enables scientific calculator functionality.
The basic operations ( +, -, *, /, ^, and %) are available, as well as:
Function | Description |
---|---|
abs |
absolute value |
acos |
arc cosine |
asin |
arc sine |
atan |
arc tangent |
cbrt |
cubic root |
ceil |
nearest upper integer |
cos |
cosine |
cosh |
hyperbolic cosine |
exp |
Euler’s number raised to the power e^x |
floor |
nearest lower integer |
log |
natural logarithm (base e) |
log10 |
logarithm (base 10) |
log2 |
logarithm (base 2) |
sin |
sine |
sinh |
hyperbolic sine |
sqrt |
square root |
tan |
tangent |
tanh |
hyperbolic tangent |
signum |
signum function |
Examples
Find the calories per meal item, then multiply by the number of servings for a meal:
g.V().hasLabel('meal_item').as('a'). inE('includes').as('b'). math('a*b'). by('calories'). by('numServ')
Note that two by()
statements are used to retrieve a particular property for each math variable used, calories for a and numServ for b.