sqrt - Compute the square root of a value
sqrt
is a fundamental function in mathematics. It calculates the square root of a given value.
NOTE: It is the inverse of power(number, 2)
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
number | number | true | The number whose square root we seek |
Example - Computing "Rate of Return" over 2 years
Consider the following document:
The above document represents a trade that occurred in a financial service. We can use the sqrt
function to aid us in computing the rate of return:
This will result in the following document:
{
"buyer": "Chris",
"asset": "DataDog"
"bought_at_price": 100,
"sold_at_price": 10,
"ror": -0.683772233983162
}
Theme
Light