Skip to content

Commit

Permalink
Clarified for various mathematical functions the defined input and ou…
Browse files Browse the repository at this point in the history
…tput ranges. Mention that `NaN` is returned outside of the defined input range where possible.
  • Loading branch information
m-mohr committed Oct 26, 2023
1 parent eb9cc92 commit ccf2109
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Trigonometric functions: Clarified that NaN is returned outside of their defined input range and defined output ranges where possible.
- Clarified for various mathematical functions the defined input and output ranges. Mention that `NaN` is returned outside of the defined input range where possible.

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

Expand Down
4 changes: 2 additions & 2 deletions absolute.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "absolute",
"summary": "Absolute value",
"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.",
"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.",
"categories": [
"math"
],
Expand Down Expand Up @@ -95,4 +95,4 @@
"result": true
}
}
}
}
10 changes: 6 additions & 4 deletions arccos.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{
"id": "arccos",
"summary": "Inverse cosine",
"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 < -1 and > 1.",
"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.",
"categories": [
"math > trigonometric"
],
"parameters": [
{
"name": "x",
"description": "A number.",
"description": "A number in the range *[-1, 1]*.",
"schema": {
"type": [
"number",
"null"
]
],
"minimum": -1,
"maximum": 1
}
}
],
"returns": {
"description": "The computed angle in radians.",
"description": "The computed angle in radians in the range *[0, π]*.",
"schema": {
"type": [
"number",
Expand Down
9 changes: 5 additions & 4 deletions arcosh.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"id": "arcosh",
"summary": "Inverse hyperbolic cosine",
"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. `NaN` is returned for values < 1.",
"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. `NaN` is returned for values outside of the allowed range.",
"categories": [
"math > trigonometric"
],
"parameters": [
{
"name": "x",
"description": "A number.",
"description": "A number in the range *[1, +∞)*.",
"schema": {
"type": [
"number",
"null"
]
}
},
"minimum": 1
}
],
"returns": {
"description": "The computed angle in radians.",
"description": "The computed angle in radians in the range *[0, +∞)*.",
"schema": {
"type": [
"number",
Expand Down
8 changes: 5 additions & 3 deletions arcsin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
"parameters": [
{
"name": "x",
"description": "A number.",
"description": "A number in the range *[-1, 1]*.",
"schema": {
"type": [
"number",
"null"
]
],
"minimum": -1,
"maximum": 1
}
}
],
"returns": {
"description": "The computed angle in radians.",
"description": "The computed angle in radians in the range *[-π/2, π/2]*.",
"schema": {
"type": [
"number",
Expand Down
4 changes: 2 additions & 2 deletions arctan.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"returns": {
"description": "The computed angle in radians.",
"description": "The computed angle in radians in the range *(−π/2, π/2)*.",
"schema": {
"type": [
"number",
Expand All @@ -41,4 +41,4 @@
"title": "Inverse tangent explained by Wolfram MathWorld"
}
]
}
}
4 changes: 2 additions & 2 deletions artanh.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"id": "artanh",
"summary": "Inverse hyperbolic tangent",
"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. `NaN` is returned for values <= -1 and >= 1.",
"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. `NaN` is returned for values outside of the allowed range.",
"categories": [
"math > trigonometric"
],
"parameters": [
{
"name": "x",
"description": "A number.",
"description": "A number in the range *(-1, 1)*.",
"schema": {
"type": [
"number",
Expand Down
2 changes: 1 addition & 1 deletion cos.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"returns": {
"description": "The computed cosine of `x`.",
"description": "The computed cosine in the range *[-1, 1]*.",
"schema": {
"type": [
"number",
Expand Down
2 changes: 1 addition & 1 deletion cosh.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"returns": {
"description": "The computed hyperbolic cosine of `x`.",
"description": "The computed hyperbolic cosine in the ramge *[1, +∞)*.",
"schema": {
"type": [
"number",
Expand Down
7 changes: 4 additions & 3 deletions exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
}
],
"returns": {
"description": "The computed value for *e* raised to the power of `p`.",
"description": "The computed value for *e* raised to the power of `p`. Value is in the range of *(0, +∞)*",
"schema": {
"type": [
"number",
"null"
]
],
"minimumExclusive": 0
}
},
"examples": [
Expand Down Expand Up @@ -65,4 +66,4 @@
"result": true
}
}
}
}
9 changes: 5 additions & 4 deletions ln.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"id": "ln",
"summary": "Natural logarithm",
"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.",
"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.",
"categories": [
"math > exponential & logarithmic"
],
"parameters": [
{
"name": "x",
"description": "A number to compute the natural logarithm for.",
"description": "A number to compute the natural logarithm for in the range *[0, +∞)*.",
"schema": {
"type": [
"number",
"null"
]
],
"minimum": 0
}
}
],
Expand Down Expand Up @@ -64,4 +65,4 @@
"result": true
}
}
}
}
9 changes: 5 additions & 4 deletions log.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"id": "log",
"summary": "Logarithm to a base",
"description": "Logarithm to the base `base` of the number `x` is defined to be the inverse function of taking b to the power of x.\n\nThe no-data value `null` is passed through and therefore gets propagated if any of the arguments is `null`.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. Therefore, `log(0, 2)` results in ±infinity if the processing environment supports it or otherwise an exception is thrown.",
"description": "Logarithm to the base `base` of the number `x` is defined to be the inverse function of taking b to the power of x.\n\nThe no-data value `null` is passed through and therefore gets propagated if any of the arguments is `null`.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it. Therefore, `log(0, 2)` 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.",
"categories": [
"math > exponential & logarithmic"
],
"parameters": [
{
"name": "x",
"description": "A number to compute the logarithm for.",
"description": "A number to compute the logarithm for in the range *[0, +∞)*.",
"schema": {
"type": [
"number",
"null"
]
],
"minimum": 0
}
},
{
Expand Down Expand Up @@ -78,4 +79,4 @@
"title": "IEEE Standard 754-2019 for Floating-Point Arithmetic"
}
]
}
}
8 changes: 7 additions & 1 deletion sgn.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"type": [
"number",
"null"
],
"enum": [
-1,
0,
1,
null
]
}
},
Expand Down Expand Up @@ -104,4 +110,4 @@
"result": true
}
}
}
}
2 changes: 1 addition & 1 deletion sin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"returns": {
"description": "The computed sine of `x`.",
"description": "The computed sine in the range *[-1, 1]*.",
"schema": {
"type": [
"number",
Expand Down
4 changes: 2 additions & 2 deletions sinh.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"returns": {
"description": "The computed hyperbolic sine of `x`.",
"description": "The computed hyperbolic sine.",
"schema": {
"type": [
"number",
Expand All @@ -41,4 +41,4 @@
"title": "Hyperbolic sine explained by Wolfram MathWorld"
}
]
}
}
2 changes: 1 addition & 1 deletion tan.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"returns": {
"description": "The computed tangent of `x`.",
"description": "The computed tangent.",
"schema": {
"type": [
"number",
Expand Down
6 changes: 3 additions & 3 deletions tanh.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
],
"returns": {
"description": "The computed hyperbolic tangent of `x`.",
"description": "The computed hyperbolic tangent in the range *(-1, 1)*.",
"schema": {
"type": [
"number",
"null"
],
"minimum": -1,
"maximum": 1
"minimumExclusive": -1,
"maximumExclusive": 1
}
},
"examples": [
Expand Down

0 comments on commit ccf2109

Please sign in to comment.