From 7e89adece4e6c36ac10e09300eb59ffd251d82f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Axel=20S=C3=B8gaard?= Date: Sat, 17 Nov 2012 21:17:32 +0100 Subject: [PATCH] Moved links to margin. Added more links --- .../math/scribblings/math-number-theory.scrbl | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/collects/math/scribblings/math-number-theory.scrbl b/collects/math/scribblings/math-number-theory.scrbl index 1ceb38677c..ed65ada4ea 100644 --- a/collects/math/scribblings/math-number-theory.scrbl +++ b/collects/math/scribblings/math-number-theory.scrbl @@ -31,6 +31,7 @@ @; ---------------------------------------- @section[#:tag "congruences"]{Congruences and Modular Arithmetic} +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Divisor"]{Divisor}} @defproc[(divides? [m Integer] [n Integer]) boolean?]{ Returns @racket[#t] if @racket[m] divides @racket[n], @racket[#f] otherwise. @@ -41,11 +42,10 @@ Test whether 2 divides 9: @interaction[#:eval untyped-eval (require math) - (divides? 2 9)] - - @; http://en.wikipedia.org/wiki/Divisor + (divides? 2 9)] } +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/B%C3%A9zout's_identity"]{Bezout's Identity}} @defproc[(bezout [a Integer] [b Integer] [c Integer] ...) (Listof Integer)]{ Given integers @racket[a], @racket[b], @racket[c] ... returns a list of integers @racket[u], @racket[v], @racket[q] ... @@ -56,9 +56,9 @@ @interaction[#:eval untyped-eval (bezout 6 15) (+ (* -2 6) (* 1 15))] - @; http://en.wikipedia.org/wiki/B%C3%A9zout's_identity } +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Coprime"]{Coprime}} @defproc[(coprime? [a Integer] [b Integer] ...) boolean?]{ Returns @racket[#t] if the integers @racket[a],@racket[b],... are coprime. @@ -68,19 +68,19 @@ The numbers 2, 6, and, 15 are coprime. @interaction[#:eval untyped-eval (coprime? 2 6 15)] - @; http://en.wikipedia.org/wiki/Coprime } +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Pairwise_coprime"]{Pairwise Coprime}} @defproc[(pairwise-coprime? [a Integer] [b Integer] ...) boolean?]{ Returns @racket[#t] if the integers @racket[a],@racket[b],... are pairwise coprime. The numbers 2, 6, and, 15 are not pairwise coprime, since 2 and 6 share the factor 3. @interaction[#:eval untyped-eval (pairwise-coprime? 2 6 15)] - @; http://en.wikipedia.org/wiki/Pairwise_coprime } +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Modular_multiplicative_inverse"]{Multiplicative Inverse}} @defproc[(modular-inverse [a Integer] [n Integer]) natural?]{ Returns the inverse of @racket[a] module @racket[n], if @racket[a] and @racket[n] are coprime, @@ -97,12 +97,12 @@ The number 0 has no inverse modulo 5. @interaction[(require math) (modular-inverse 0 5)] - @; http://en.wikipedia.org/wiki/Modular_multiplicative_inverse } @defproc[(solve-chinese [as (Listof Integer)] [bs (Listof Integer)]) natural?]{ + @margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Chinese_remainder_theorem"]{Chinese Remainder Theorem}} Given a list of integers @racket[as] and a list of coprime moduli @racket[ns] the function @racket[solve-chinese] will return the single natural solution @racket[x] in @racket[{0,...,n-1}] @@ -119,9 +119,7 @@ a remainder of 2, when divided by 5 leaves a remainder of 3, and when divided by 7 leaves a remainder of 2? @interaction[#:eval untyped-eval - (solve-chinese '(2 3 2) '(3 5 7))] - - @; http://en.wikipedia.org/wiki/Chinese_remainder_theorem + (solve-chinese '(2 3 2) '(3 5 7))] } @defproc[(quadratic-residue? [a natural?] [n natural?]) boolean?]{ @@ -400,6 +398,7 @@ for all coprime natural numbers @racket[a] and @racket[b]. The functions @racket[totient], @racket[moebius-mu], and, @racket[divisor-sum] are multiplicative. +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Euler%27s_totient_function"]{Euler's Totient}} @defproc[(totient [n Natural]) natural?]{ Returns the number of integers from 1 to @racket[n] that are coprime with @racket[n]. @@ -412,12 +411,13 @@ Note: The function @racket[totient] is multiplicative. (require racket/function) ; for curry (totient 9) (length (filter (curry coprime? 9) (range 10)))] - -@; http://en.wikipedia.org/wiki/Euler%27s_totient_function } + + @defproc[(moebius-mu [n Natural]) (Union -1 0 1)]{ +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/M%C3%B6bius_function"]{Moebius Function}} Returns: @racket[1] if @racket[n] is a product of an even number of primes @@ -432,11 +432,10 @@ Note: The function @racket[moebius-mu] is multiplicative. (moebius-mu (* 2 3 5)) (moebius-mu (* 2 3 5 7)) (moebius-mu (* 2 2 3 5 7))] - -@; http://en.wikipedia.org/wiki/M%C3%B6bius_function } +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Divisor_function"]{Divisor Function}} @defproc[(divisor-sum [n Natural] [k Natural]) natural?]{ Returns sum of the @racket[k]th powers of all divisors of @racket[n]. @@ -446,37 +445,32 @@ Note: The function @racket[divisor-sum] is multiplicative. @interaction[#:eval untyped-eval (divisor-sum 12 2) (apply + (map sqr (divisors 12)))] - -@; http://en.wikipedia.org/wiki/Divisor_function } @; ---------------------------------------- @section[#:tag "number-sequences"]{Number Sequences} +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Bernoulli_number"]{Bernoulli Number}} @defproc[(bernoulli [n Natural]) exact-rational?]{ Returns the @racket[n]th Bernoulli number. - Definition: - @url{http://en.wikipedia.org/wiki/Bernoulli_number}. + @interaction[#:eval untyped-eval (map bernoulli (range 9))] } +@margin-note{MathWorld: @hyperlink["http://mathworld.wolfram.com/EulerianNumber.html"]{Eulerian Number}} @defproc[(eulerian-number [n Natural] [k Natural]) natural?]{ Returns the Eulerian number @math-style{}. - Definition: - @url{http://mathworld.wolfram.com/EulerianNumber.html}. @interaction[(require math racket) (eulerian-number 5 2)] } +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Fibonacci_number"]{Fibonacci Number}} @defproc[(fibonacci [n Natural]) natural?]{ Returns the @racket[n]th Fibonacci number. - See - @url{http://en.wikipedia.org/wiki/Fibonacci_number} - for a definition. The ten first Fibonacci numbers. @interaction[(require math racket) @@ -502,9 +496,10 @@ are less than or equal to @racket[n]. (farey 3)] } +@margin-note{MathWorld: @hyperlink["http://mathworld.wolfram.com/TangentNumber.html"]{Tangent Number}} @defproc[(tangent-number [n integer?]) integer?]{ Returns the @racket[n]th tangent number. -See @url{http://mathworld.wolfram.com/TangentNumber.html} for a definition. + @interaction[(require math) (tangent-number 1) (tangent-number 2) @@ -552,12 +547,12 @@ See @url{http://mathworld.wolfram.com/TangentNumber.html} for a definition. +@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Partition_(number_theory)"]{Partition}} @defproc[(partition-count [n Natural]) natural?]{ Returns the number of partitions of @racket[n]. A partition of a positive integer @racket[n] is a way of writing @racket[n] as a sum of positive integers. The number 3 has the partitions @math-style{1+1+1, 1+2, 3}. - See @url{http://en.wikipedia.org/wiki/Partition_(number_theory)}. @interaction[(require math racket) (partition-count 3) (partition-count 4)]