[racket] Math library ready for testing

From: Pierpaolo Bernardi (olopierpa at gmail.com)
Date: Mon Dec 17 06:06:30 EST 2012

Some comments after scanning the manual.

====
flulp-error

"For non-rational arguments such as +nan.0, flulp-error returns 0.0 if
(eqv? x r); otherwise it returns +inf.0."

However one example is:

> (flulp-error +inf.0 +nan.0)
+nan.0

Which does not agree with the doc.

====
"2.3.2 Flonum Constants

-max.0 : Flonum
-min.0 : Flonum
+min.0 : Flonum
+max.0 : Flonum

The rational flonums with maximum and minimum magnitude.

Example:

> (list -max.0 -min.0 +min.0 +max.0)
'(-1.7976931348623157e+308
  -4.9406564584125e-324
  4.9406564584125e-324
  1.7976931348623157e+308)"

The minimum magnitude rational flonums are 0.0 and -0.0. Perhaps
"minimum non-zero magnitude"?

====
gamma-inc

"The following identities should hold:

• (gamma-inc k x) = 0"

I'm no expert, but this identity smells   8^)

====
pairwise-coprime?

"Returns #t if the integers a b ... are pairwise coprime, meaning that
each adjacent pair of integers is coprime."

Either are coprime pairwise or only adjacent pairs. (I cannot check
what the implementation does, at the moment. I guess the
implementation is correct and the doc is badly worded).

====
"4.5 Multiplicative Functions

The functions in this section are multiplicative. In number theory, a
multiplicative function is a function f such that (f a b) = (* (f a)
(f b)) for all coprime natural numbers a and b."

Probably should be: (f (* a b)) = (* (f a) (f b))  ?

====
moebius-mu

"Returns:
• 1 if n is a product of an even number of primes
• -1 if n is a product of an odd number of primes
• 0 if n has a multiple prime factor"

Doesn't look right.

(moebius-mu 4) ==> ??

should be 1 according to first rule.
should be 0 according to third rule.

OK. checking wikipedia:

"μ(n) is defined for all positive integers n and has its values in
{−1, 0, 1} depending on the factorization of n into prime factors. It
is defined as follows:
 μ(n) = 1 if n is a square-free positive integer with an even number
of prime factors.
 μ(n) = −1 if n is a square-free positive integer with an odd number
of prime factors.
 μ(n) = 0 if n is not square-free."

it's the square-free condition that's missing.

====
prime-omega

"Counting multiplicities the number of prime factors of n is returned."

Doesn't parse (maybe it's a bug in my English parser, though).

"Note: The function prime-omega is multiplicative."

Since it's in a section named Multiplicative Functions, the note
appears redundant.

====
farey-sequence

The examples show always an increasing sequence. If this is guaranted,
it is well worth to put it in the spec.
If it's not guaranted, then please ignore this comment.

====
multinomial

"(multinomial n ks) → Natural
   n : Integer
  ks : (Listof Integer)
...
> (multinomial 5 3 2)
10"

The example does not agree with the spec.

====
triangle-number?, triangle-number

I think it's customary to call these numbers 'triangular'.  Also for
consistency with the other polygonal number function names.

====
"4.11 The group Zn and Primitive Roots
...
A generator the group Un is called a primitive root modolo n. Note
that g is a primitive root if and only if order(g)=phi(n), where phi
is Eulers totient. A group with a generator is called cyclic."

Ehm... why not write simply order(g)=totient(n), since this function
has been calles 'totient' in this library.

(also: "modolo")

====
"(unit-group-orders n) → (Listf Positive-Integer)
   n : Integer"

Typo

====
Unless I missed it, there's no evaluator of polynomials?  seems a
useful and common operation, and surely there must be one or more
implementations somewhere in the internals of the lib?

====
The prefix for bigfloat operations sometimes is "bigfloat-", sometimes
"bf-", sometimes "bf", with no evident (to me) pattern.

My two neurons protest vehemently.

====
Unless I missed it, there's no discussion of the result precision of
mixed precision bf operations. Maybe it should be mentioned?

====
bflog2, bflog10, bfexp2, bfexp10

Unless I have missed them, there are no fl and generic equivalent of these.
These are commonly used functions.  Maybe should be provided?

====
bfagm

Wins the prize for the most fortranesque name.

====
Arrays

why math/arrays and not data/arrays ?

====
diagonal-array

"returns a square array..."

hmmm... is 'square' appropriate for more than 2-dimensional arrays?

====

Great work!
====

Cheers
P.


Posted on the users mailing list.