Logarithmic functions

Logarithmic mathematical functions operate on numeric expressions only, and will return an error if used on any other values. See also Mathematical operators.

e()

Details

Syntax

e()

Description

Returns the base of the natural logarithm, e.

Returns

FLOAT

Example 1. e()
Query
RETURN e()

The base of the natural logarithm, e, is returned.

Result
e()

2.718281828459045

Rows: 1

exp()

Details

Syntax

exp(input)

Description

Returns e^n, where e is the base of the natural logarithm, and n is the value of the argument expression.

Arguments

Name

Type

Description

input

FLOAT

A value to which the base of the natural logarithm, e, will be raised.

Returns

FLOAT

Considerations

exp(null) returns null.

exp() returns Infinity when the return value is greater than the largest FLOAT value (Java Double.MAX_VALUE).

Example 2. exp()
Query
RETURN exp(2)

e to the power of 2 is returned.

Result
exp(2)

7.38905609893065

Rows: 1

log()

Details

Syntax

log(input)

Description

Returns the natural logarithm of a FLOAT.

Arguments

Name

Type

Description

input

FLOAT

A value for which the natural logarithm will be returned.

Returns

FLOAT

Considerations

log(null) returns null.

log(0) returns -Infinity.

If (input < 0), then (log(input)) returns NaN.

Example 3. log()
Query
RETURN log(27)

The natural logarithm of 27 is returned.

Result
log(27)

3.295836866004329

Rows: 1

ln()

Details

Syntax

ln(input)

Description

Returns the natural logarithm of a FLOAT.

Arguments

Name

Type

Description

input

FLOAT

A value for which the natural logarithm will be returned.

Returns

FLOAT

This function is an alias to the log() function, and it was introduced as part of Cypher®'s GQL conformance.

Differences from GQL

In GQL, the natural logarithm function must raise an exception when the input is zero or negative. In Cypher®, ln(0) returns -Infinity and ln(negative) returns NaN. Changing Cypher® to raise an error for these inputs would be a breaking change, so the difference is documented here and in the GQL conformance section.

Considerations

ln(null) returns null.

ln(0) returns -Infinity.

If (input < 0), then (ln(input)) returns NaN.

Example 4. ln()
Query
RETURN ln(27)

The natural logarithm of 27 is returned.

Result
ln(27)

3.295836866004329

Rows: 1

log10()

Details

Syntax

log10(input)

Description

Returns the common logarithm (base 10) of a FLOAT.

Arguments

Name

Type

Description

input

FLOAT

A value for which the common logarithm (base 10) will be returned.

Returns

FLOAT

Considerations

log10(null) returns null.

log10(0) returns -Infinity.

If (input < 0), then (log10(input)) returns NaN.

Example 5. log10()
Query
RETURN log10(27)

The common logarithm of 27 is returned.

Result
log10(27)

1.4313637641589874

Rows: 1

sqrt()

Details

Syntax

sqrt(input)

Description

Returns the square root of a FLOAT.

Arguments

Name

Type

Description

input

FLOAT

The value to calculate the square root of.

Returns

FLOAT

Considerations

sqrt(null) returns null.

If (input < 0), then (sqrt(input)) returns NaN.

Example 6. sqrt()
Query
RETURN sqrt(256)

The square root of 256 is returned.

Result
sqrt(256)

16.0

Rows: 1