[racket] Math library ready for testing

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Dec 17 07:55:46 EST 2012

Thank you for reading the manual carefully.

2012/12/17 Pierpaolo Bernardi <olopierpa at gmail.com>:
> Some comments after scanning the manual.

> ====
> gamma-inc
>
> "The following identities should hold:
>
> • (gamma-inc k x) = 0"
>
> I'm no expert, but this identity smells   8^)

I think it should be (gamma-inc k x) >= 0 ?

>
> ====
> 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).

The word "adjacent" should be removed from the docs.
The implementation checks each pair.

> ====
> "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))  ?

Yes.

> ====
> 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.

Would it be enough to add "distinct" ?

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

Or is square-free easier to understand?

> ====
> 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).

I'll let a native speaker find a better wording.

> "Note: The function prime-omega is multiplicative."
>
> Since it's in a section named Multiplicative Functions, the note
> appears redundant.

True.

>
> ====
> 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.

It is guaranted.

> ====
> multinomial
>
> "(multinomial n ks) → Natural
>    n : Integer
>   ks : (Listof Integer)
> ...
>> (multinomial 5 3 2)
> 10"
>
> The example does not agree with the spec.

A proper formula would be easier.

    5! / ( 3! * 2! ) = 120 / ( 6*2 )  = 10

I read the spec to give this:

> (apply / (factorial 5) (map factorial (list 2 3)))
10


> ====
> triangle-number?, triangle-number
>
> I think it's customary to call these numbers 'triangular'.  Also for
> consistency with the other polygonal number function names.

I think both are used, but I am not attached to the name.

> ====
> "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.

Agree.

> (also: "modolo")


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



Thanks again for the careful proof reading.

/Jens Axel


Posted on the users mailing list.