aboutsummaryrefslogtreecommitdiff
path: root/doc/arithmetic.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/arithmetic.md')
-rw-r--r--doc/arithmetic.md30
1 files changed, 15 insertions, 15 deletions
diff --git a/doc/arithmetic.md b/doc/arithmetic.md
index c3e17bf8..e51fc53e 100644
--- a/doc/arithmetic.md
+++ b/doc/arithmetic.md
@@ -16,16 +16,16 @@ Summary of other differences from APL:
BQN of course supports the elementary functions taught in schools everywhere:
-Symbol | Dyad | Monad
--------|----------|-------
-`+` | Add | *(Conjugate)*
-`-` | Subtract | Negate
-`Γ—` | Multiply | Sign
-`Γ·` | Divide | Reciprocal
-`⋆` | Power | Exponential
-`√` | Root | Square root
+Symbol | Dyad | Monad | default `𝕨`
+-------|----------|---------------|:----------:
+`+` | Add | *(Conjugate)* | –
+`-` | Subtract | Negate | 0
+`Γ—` | Multiply | Sign | –
+`Γ·` | Divide | Reciprocal | 1
+`⋆` | Power | Exponential | *e*
+`√` | Root | Square root | 2
-The dyadic functions should all be familiar operations, and most likely you are familiar with the symbols `+-Γ—Γ·βˆš`. In fact the large `Γ—` and `Γ·` might strike you as a regression to early school years, before division was written vertically and multiplication with a simple dot or no symbol at all (BQN reserves the distinction of having no symbol for application and composition). Like these, raising to a power or exponentiation is made regular by giving it the symbol `⋆`β€”a true Unicode star and *not* an asterisk. The Root function `√` is also modified to be a binary function, which raises `𝕩` to the power `÷𝕨`. In ASCII programming languages `Γ—`, `Γ·`, and `⋆` are often written `*`, `/`, and `^` or `**`.
+The dyadic (two-argument) functions should all be familiar operations, and most likely you know the symbols `+-Γ—Γ·βˆš`. In fact the large `Γ—` and `Γ·` might strike you as a regression to early school years, before division was written vertically and multiplication with a simple dot or no symbol at all. Like these, raising to a power or exponentiation is made regular by giving it the symbol `⋆`β€”a true Unicode star and *not* an asterisk. The Root function `√` is also modified to be a binary function, which raises `𝕩` to the power `÷𝕨`. In ASCII programming languages `Γ—`, `Γ·`, and `⋆` are often written `*`, `/`, and `^` or `**`.
2 + 3β€Ώ1β€Ώ0β€Ώ5
@@ -39,7 +39,7 @@ The dyadic functions should all be familiar operations, and most likely you are
4 √ 81
-Each of these functions also has a meaning with only one argument, although in mathematics only `-` does. The relationship of negation to addition is extended to division (relative to multiplication) as well, so that `÷𝕩` gives the reciprocal `1÷𝕩` of its argument. Power (`⋆`) is also extended with a default left argument of [Euler's number](https://en.wikipedia.org/wiki/E_(mathematical_constant)) *e*. The default left argument for Root is 2, giving the well-known Square Root.
+Each of these functions also has a meaning with only one argument, although mathematics only defines `-` in this way. The relationship of negation to addition is extended to division (relative to multiplication) as well, so that `÷𝕩` gives the reciprocal `1÷𝕩` of its argument. Power (`⋆`) is also extended with a default left argument of [Euler's number](https://en.wikipedia.org/wiki/E_(mathematical_constant)) *e*. The default left argument for Root is 2, giving the well-known Square Root.
- 6
@@ -51,7 +51,7 @@ Each of these functions also has a meaning with only one argument, although in m
Take note of the difference between the function `-`, and the "high minus" character `¯`, which is a part of [numeric notation](syntax.md#constants). Also shown is the number `∞`, which BQN supports along with `¯∞` (but depending on implementation BQN may or may not keep track of `¯0`. Integer optimization loses the distinction so it's best not to rely on it).
-The logarithm is written with Undo: `⋆⁼`. As with Power, the default base is *e*, giving a natural logarithm.
+The logarithm is written with [Undo](undo.md): `⋆⁼`. As with Power, the default base is *e*, giving a natural logarithm.
⋆⁼ 10
@@ -122,7 +122,7 @@ Now the monadic function symbols resemble those used in mathematics. In the case
| Β―βˆžβ€ΏΒ―6β€Ώ0β€Ώ2
-Floor (`⌊`) returns the largest integer less than or equal to the argument, and Ceiling (`⌈`) returns the smallest one greater than or equal to it. For this purpose `¯∞` and `∞` are treated as integers, so that the floor or ceiling of an infinity is itself. Absolute value removes the argument's sign by negating it if it is less than 0, so that its result is always non-negative.
+Floor (`⌊`) returns the largest integer less than or equal to the argument, and Ceiling (`⌈`) returns the smallest one greater than or equal to it. For this purpose `¯∞` and `∞` are treated as integers, so that the floor or ceiling of an infinity is itself. Absolute value removes the sign of `𝕩` by negating it if it's less than 0, so that its result is always non-negative.
Minimum (`⌊`) returns the smaller of its two arguments, and Maximum (`⌈`) returns the larger. These functions are loosely related to Floor and Ceiling in their use of comparison, and can be defined similarly: for example, the minimum of two numbers is the largest number less than or equal to both of them. To take the minimum or maximum of an entire list, use a [fold](fold.md).
@@ -130,7 +130,7 @@ Minimum (`⌊`) returns the smaller of its two arguments, and Maximum (`⌈`) re
⌽⊸⌈ ↕8
-Modulus (`|`) is similar to the modular division operation written `%` in C-like languages, but it takes the arguments in the opposite order, and differs in its handling of negative arguments. It's defined to be `{𝕩-π•¨Γ—βŒŠπ•©Γ·π•¨}`, except that the multiplication should always return 0 if its right argument is 0, even if `𝕨` is infinite.
+Modulus (`|`) is similar to the modular division operation written `%` in C-like languages, but it takes the arguments in the opposite order, and differs in its handling of negative arguments. It's the same computation as `{𝕩-π•¨Γ—βŒŠπ•©Γ·π•¨}` but probably has better precision.
3 | ↕8
@@ -171,11 +171,11 @@ Arithmetic primitives act as though they are given [depth](depth.md#the-depth-mo
Γ— β‰Λ˜βŸ¨Β―8,Β―9βŸ©β€ΏβŸ¨βŸ¨2,0⟩,4,5⟩
-With two arguments many combinations are possible. Arrays of equal shape are matched element-wise, and an atom is matched to every element of an array.
+With two arguments, many combinations are possible. Arrays of equal shape are matched element-wise, and an atom is matched to every element of an array.
10β€Ώ20β€Ώ30 + 5β€Ώ6β€Ώ7
- 10 Γ— 4β€Ώ3β€Ώ2≍6β€Ώ7β€Ώ8
+ 10 Γ— [4β€Ώ3β€Ώ2,6β€Ώ7β€Ώ8]
Arrays with different ranks can also be paired: they are matched by [leading axis agreement](leading.md#leading-axis-agreement). This means that one shape must be a prefix of the other, and elements of the lower-rank array are repeated to match up with cells of the higher-rank one.