Skip to content

Commit ad8a2f3

Browse files
authored
Math functions: Clarified value ranges and NaN (#476)
* divide, ln, log, mod: Clarified behavior for 0 input / infinity results * Trigonometric functions: Clarified that NaN is returned outside of their defined ranges and the output value range for some processes * Clarified for various mathematical functions the defined input and output ranges. Mention that `NaN` is returned outside of the defined input range where possible. * Remove NaN
1 parent ab2e6c2 commit ad8a2f3

20 files changed

+106
-68
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Fixed
1414

15+
- Clarified for various mathematical functions the defined input and output ranges. Mention that `NaN` is returned outside of the defined input range where possible.
16+
- `divide`: Clarified behavior for division by 0
1517
- `between`: Clarify that `null` is passed through.
1618
- `eq` and `neq`: Explicitly set the minimum value for the `delta` parameter.
1719
- `filter_bbox`, `load_collection`, `load_stac`: Clarified that the bounding box is reprojected to the CRS of the spatial data cube dimensions if required.
1820
- `filter_spatial`: Clarified that masking is applied using the given geometries. [#469](https://github.com/Open-EO/openeo-processes/issues/469)
21+
- `mod`: Clarified behavior for y = 0
1922
- `sqrt`: Clarified that NaN is returned for negative numbers.
2023

2124
## [2.0.0-rc.1] - 2023-05-25

absolute.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "absolute",
33
"summary": "Absolute value",
4-
"description": "Computes the absolute value of a real number `x`, which is the \"unsigned\" portion of x and often denoted as *|x|*.\n\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the absolute value of a real number `x`, which is the \"unsigned\" portion of `x` and often denoted as *|x|*.\n\nThe no-data value `null` is passed through and therefore gets propagated.",
55
"categories": [
66
"math"
77
],
@@ -95,4 +95,4 @@
9595
"result": true
9696
}
9797
}
98-
}
98+
}

arccos.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
{
22
"id": "arccos",
33
"summary": "Inverse cosine",
4-
"description": "Computes the arc cosine of `x`. The arc cosine is the inverse function of the cosine so that *`arccos(cos(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the arc cosine of `x`. The arc cosine is the inverse function of the cosine so that *`arccos(cos(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated. `NaN` is returned for values outside of the allowed range.",
55
"categories": [
66
"math > trigonometric"
77
],
88
"parameters": [
99
{
1010
"name": "x",
11-
"description": "A number.",
11+
"description": "A number in the range *[-1, 1]*.",
1212
"schema": {
1313
"type": [
1414
"number",
1515
"null"
16-
]
16+
],
17+
"minimum": -1,
18+
"maximum": 1
1719
}
1820
}
1921
],
2022
"returns": {
21-
"description": "The computed angle in radians.",
23+
"description": "The computed angle in radians in the range *[0, π]*.",
2224
"schema": {
2325
"type": [
2426
"number",
2527
"null"
26-
]
28+
],
29+
"minimum": 0
2730
}
2831
},
2932
"examples": [
@@ -41,4 +44,4 @@
4144
"title": "Inverse cosine explained by Wolfram MathWorld"
4245
}
4346
]
44-
}
47+
}

arcosh.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{
22
"id": "arcosh",
33
"summary": "Inverse hyperbolic cosine",
4-
"description": "Computes the inverse hyperbolic cosine of `x`. It is the inverse function of the hyperbolic cosine so that *`arcosh(cosh(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the inverse hyperbolic cosine of `x`. It is the inverse function of the hyperbolic cosine so that *`arcosh(cosh(x)) = x`*.\n\nThe no-data value `null` is passed through and therefore gets propagated. `NaN` is returned for values outside of the allowed range.",
55
"categories": [
66
"math > trigonometric"
77
],
88
"parameters": [
99
{
1010
"name": "x",
11-
"description": "A number.",
11+
"description": "A number in the range *[1, +∞)*.",
1212
"schema": {
1313
"type": [
1414
"number",
1515
"null"
1616
]
17-
}
17+
},
18+
"minimum": 1
1819
}
1920
],
2021
"returns": {
21-
"description": "The computed angle in radians.",
22+
"description": "The computed hyperbolic angle in radians in the range *[0, +∞)*.",
2223
"schema": {
2324
"type": [
2425
"number",
2526
"null"
26-
]
27+
],
28+
"minimum": 0
2729
}
2830
},
2931
"examples": [
@@ -41,4 +43,4 @@
4143
"title": "Inverse hyperbolic cosine explained by Wolfram MathWorld"
4244
}
4345
]
44-
}
46+
}

arcsin.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
{
22
"id": "arcsin",
33
"summary": "Inverse sine",
4-
"description": "Computes the arc sine of `x`. The arc sine is the inverse function of the sine so that *`arcsin(sin(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the arc sine of `x`. The arc sine is the inverse function of the sine so that *`arcsin(sin(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated. `NaN` is returned for values < -1 and > 1.",
55
"categories": [
66
"math > trigonometric"
77
],
88
"parameters": [
99
{
1010
"name": "x",
11-
"description": "A number.",
11+
"description": "A number in the range *[-1, 1]*.",
1212
"schema": {
1313
"type": [
1414
"number",
1515
"null"
16-
]
16+
],
17+
"minimum": -1,
18+
"maximum": 1
1719
}
1820
}
1921
],
2022
"returns": {
21-
"description": "The computed angle in radians.",
23+
"description": "The computed angle in radians in the range *[-π/2, π/2]*.",
2224
"schema": {
2325
"type": [
2426
"number",
@@ -41,4 +43,4 @@
4143
"title": "Inverse sine explained by Wolfram MathWorld"
4244
}
4345
]
44-
}
46+
}

arctan.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"returns": {
21-
"description": "The computed angle in radians.",
21+
"description": "The computed angle in radians in the range *(−π/2, π/2)*.",
2222
"schema": {
2323
"type": [
2424
"number",
@@ -41,4 +41,4 @@
4141
"title": "Inverse tangent explained by Wolfram MathWorld"
4242
}
4343
]
44-
}
44+
}

arsinh.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "arsinh",
33
"summary": "Inverse hyperbolic sine",
4-
"description": "Computes the inverse hyperbolic sine of `x`. It is the inverse function of the hyperbolic sine so that *`arsinh(sinh(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the inverse hyperbolic sine of `x`. It is the inverse function of the hyperbolic sine so that *`arsinh(sinh(x)) = x`*.\n\nThe no-data value `null` is passed through and therefore gets propagated.",
55
"categories": [
66
"math > trigonometric"
77
],
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"returns": {
21-
"description": "The computed angle in radians.",
21+
"description": "The computed hyperbolic angle in radians.",
2222
"schema": {
2323
"type": [
2424
"number",
@@ -41,4 +41,4 @@
4141
"title": "Inverse hyperbolic sine explained by Wolfram MathWorld"
4242
}
4343
]
44-
}
44+
}

artanh.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
{
22
"id": "artanh",
33
"summary": "Inverse hyperbolic tangent",
4-
"description": "Computes the inverse hyperbolic tangent of `x`. It is the inverse function of the hyperbolic tangent so that *`artanh(tanh(x)) = x`*.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the inverse hyperbolic tangent of `x`. It is the inverse function of the hyperbolic tangent so that *`artanh(tanh(x)) = x`*.\n\nThe no-data value `null` is passed through and therefore gets propagated. `NaN` is returned for values outside of the allowed range. The computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. Therefore, `x` = 1 results in +infinity and `x` = 0 results in -infinity. Otherwise, an exception is thrown.",
55
"categories": [
66
"math > trigonometric"
77
],
88
"parameters": [
99
{
1010
"name": "x",
11-
"description": "A number.",
11+
"description": "A number in the range *(-1, 1)*.",
1212
"schema": {
1313
"type": [
1414
"number",
1515
"null"
16-
]
16+
],
17+
"minimumExclusive": -1,
18+
"maximumExclusive": 1
1719
}
1820
}
1921
],
2022
"returns": {
21-
"description": "The computed angle in radians.",
23+
"description": "The computed hyperbolic angle in radians.",
2224
"schema": {
2325
"type": [
2426
"number",
@@ -39,6 +41,11 @@
3941
"rel": "about",
4042
"href": "http://mathworld.wolfram.com/InverseHyperbolicTangent.html",
4143
"title": "Inverse hyperbolic tangent explained by Wolfram MathWorld"
44+
},
45+
{
46+
"rel": "about",
47+
"href": "https://ieeexplore.ieee.org/document/4610935",
48+
"title": "IEEE Standard 754-2008 for Floating-Point Arithmetic"
4249
}
4350
]
44-
}
51+
}

cos.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
}
1919
],
2020
"returns": {
21-
"description": "The computed cosine of `x`.",
21+
"description": "The computed cosine in the range *[-1, 1]*.",
2222
"schema": {
2323
"type": [
2424
"number",
2525
"null"
26-
]
26+
],
27+
"minimum": -1,
28+
"maximum": 1
2729
}
2830
},
2931
"examples": [
@@ -41,4 +43,4 @@
4143
"title": "Cosine explained by Wolfram MathWorld"
4244
}
4345
]
44-
}
46+
}

cosh.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"id": "cosh",
33
"summary": "Hyperbolic cosine",
4-
"description": "Computes the hyperbolic cosine of `x`.\n\nWorks on radians only.\nThe no-data value `null` is passed through and therefore gets propagated.",
4+
"description": "Computes the hyperbolic cosine of `x`.\n\nThe no-data value `null` is passed through and therefore gets propagated.",
55
"categories": [
66
"math > trigonometric"
77
],
88
"parameters": [
99
{
1010
"name": "x",
11-
"description": "An angle in radians.",
11+
"description": "An hyperbolic angle in radians.",
1212
"schema": {
1313
"type": [
1414
"number",
@@ -18,12 +18,13 @@
1818
}
1919
],
2020
"returns": {
21-
"description": "The computed hyperbolic cosine of `x`.",
21+
"description": "The computed hyperbolic cosine in the range *[1, +∞)*.",
2222
"schema": {
2323
"type": [
2424
"number",
2525
"null"
26-
]
26+
],
27+
"minimum": 1
2728
}
2829
},
2930
"examples": [
@@ -41,4 +42,4 @@
4142
"title": "Hyperbolic cosine explained by Wolfram MathWorld"
4243
}
4344
]
44-
}
45+
}

divide.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "divide",
33
"summary": "Division of two numbers",
4-
"description": "Divides argument `x` by the argument `y` (*`x / y`*) and returns the computed result.\n\nNo-data values are taken into account so that `null` is returned if any element is such a value.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. Therefore, a division by zero results in ±infinity if the processing environment supports it. Otherwise, a `DivisionByZero` exception must the thrown.",
4+
"description": "Divides argument `x` by the argument `y` (*`x / y`*) and returns the computed result.\n\nNo-data values are taken into account so that `null` is returned if any element is such a value.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. A division by zero results in:\n\n- +infinity for `x` > 0,\n- -infinity for `x` < 0,\n- `NaN` for `x` = 0,\n- or otherwise, throws a `DivisionByZero` exception if the other options are not supported by the processing environment.",
55
"categories": [
66
"math"
77
],
@@ -76,4 +76,4 @@
7676
"title": "IEEE Standard 754-2019 for Floating-Point Arithmetic"
7777
}
7878
]
79-
}
79+
}

exp.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
}
1919
],
2020
"returns": {
21-
"description": "The computed value for *e* raised to the power of `p`.",
21+
"description": "The computed value for *e* raised to the power of `p`. Value is in the range of *(0, +∞)*",
2222
"schema": {
2323
"type": [
2424
"number",
2525
"null"
26-
]
26+
],
27+
"minimumExclusive": 0
2728
}
2829
},
2930
"examples": [
@@ -65,4 +66,4 @@
6566
"result": true
6667
}
6768
}
68-
}
69+
}

ln.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
{
22
"id": "ln",
33
"summary": "Natural logarithm",
4-
"description": "The natural logarithm is the logarithm to the base *e* of the number `x`, which equals to using the *log* process with the base set to *e*. The natural logarithm is the inverse function of taking *e* to the power x.\n\nThe no-data value `null` is passed through.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. Therefore, *`ln(0)`* results in ±infinity if the processing environment supports it or otherwise an exception is thrown.",
4+
"description": "The natural logarithm is the logarithm to the base *e* of the number `x`, which equals to using the *log* process with the base set to *e*. The natural logarithm is the inverse function of taking *e* to the power x.\n\nThe no-data value `null` is passed through.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. Therefore, *`ln(0)`* results in -infinity if the processing environment supports it or otherwise an exception is thrown. `NaN` is returned for values outside of the allowed range.",
55
"categories": [
66
"math > exponential & logarithmic"
77
],
88
"parameters": [
99
{
1010
"name": "x",
11-
"description": "A number to compute the natural logarithm for.",
11+
"description": "A number to compute the natural logarithm for in the range *[0, +∞)*.",
1212
"schema": {
1313
"type": [
1414
"number",
1515
"null"
16-
]
16+
],
17+
"minimum": 0
1718
}
1819
}
1920
],
@@ -64,4 +65,4 @@
6465
"result": true
6566
}
6667
}
67-
}
68+
}

0 commit comments

Comments
 (0)