bqn add tag
Marshall Lochbaum
The system namespace `•math` is the obvious place to put a lot of mathematical functionality APL and J have that I left out of BQN. This post is for suggesting and discussing the kind of functions it could have.
Top Answer
Marshall Lochbaum
### Combinatorics

Standard math functions are factorial and combinations (APL's `!`) and permutations (`÷˜○Fact` using `Fact` for factorial). They should accept real numbers like APL and use the gamma function---the off-by-one in the standard gamma function is almost never wanted so these would be preferred. And there are other possibilities like double factorial, but as that's easy to write in BQN I don't know if making it system-provided is that good. A built-in combinations function is good because writing a version that avoids overflow can be tricky, and performance could be important.

`Fact`, `Comb`, and `Perm` as names? Matches many other math functions like `Cos`.

Also a some useful functions dealing with specific combinations in the [fifty functions](https://github.com/mlochbaum/BQN/blob/master/examples/fifty.bqn) file. Get all permutations or combinations, or convert between a lexicographic combination index and the combination as a list of indices.
Answer #2
Marshall Lochbaum
### C-style math.h

[This one](https://en.wikipedia.org/wiki/C_mathematical_functions). These are used across many programming languages and were the main purpose of `•math` initially, with the most important being the trigonometry functions. They're almost all functions that take one number and return one number, so they're made pervasive in BQN.

Here's [Python's version](https://docs.python.org/3/library/math.html), which fits our use case a little better and adds some useful functions.

JS and CBQN only have subsets of these functions now (Javascript's `Math` doesn't include all of them).
Answer #3
Marshall Lochbaum
### Prime numbers

J has a selection of [prime number functions](https://code.jsoftware.com/wiki/Vocabulary/pco) provided by `p:`, as well as factoring (either as a list of primes or unique primes with exponents) in `q:`. And the dfns library even has some [APL implementations](https://dfns.dyalog.com/c_pco.htm) of these. The left argument numbers are unhelpful; we get to use names. However it might make sense to put these in a `•math.primes` sub-namespace.
Answer #4
Marshall Lochbaum
### APL math primitives

GCD, LCM, base, and antibase for sure. For `!` see "combinatorics". Maybe matrix multiply and inverse, although these are probably better suited for a separate system namespace for linear algebra.

Random number generation `?` is already handled by `•MakeRand`.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.