Moved links to margin. Added more links
This commit is contained in:
parent
f208d0dae8
commit
7e89adece4
|
@ -31,6 +31,7 @@
|
||||||
@; ----------------------------------------
|
@; ----------------------------------------
|
||||||
@section[#:tag "congruences"]{Congruences and Modular Arithmetic}
|
@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?]{
|
@defproc[(divides? [m Integer] [n Integer]) boolean?]{
|
||||||
Returns @racket[#t] if @racket[m] divides @racket[n],
|
Returns @racket[#t] if @racket[m] divides @racket[n],
|
||||||
@racket[#f] otherwise.
|
@racket[#f] otherwise.
|
||||||
|
@ -42,10 +43,9 @@
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(require math)
|
(require math)
|
||||||
(divides? 2 9)]
|
(divides? 2 9)]
|
||||||
|
|
||||||
@; http://en.wikipedia.org/wiki/Divisor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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)]{
|
@defproc[(bezout [a Integer] [b Integer] [c Integer] ...) (Listof Integer)]{
|
||||||
Given integers @racket[a], @racket[b], @racket[c] ...
|
Given integers @racket[a], @racket[b], @racket[c] ...
|
||||||
returns a list of integers @racket[u], @racket[v], @racket[q] ...
|
returns a list of integers @racket[u], @racket[v], @racket[q] ...
|
||||||
|
@ -56,9 +56,9 @@
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(bezout 6 15)
|
(bezout 6 15)
|
||||||
(+ (* -2 6) (* 1 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?]{
|
@defproc[(coprime? [a Integer] [b Integer] ...) boolean?]{
|
||||||
Returns @racket[#t] if the integers @racket[a],@racket[b],... are coprime.
|
Returns @racket[#t] if the integers @racket[a],@racket[b],... are coprime.
|
||||||
|
|
||||||
|
@ -68,19 +68,19 @@
|
||||||
The numbers 2, 6, and, 15 are coprime.
|
The numbers 2, 6, and, 15 are coprime.
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(coprime? 2 6 15)]
|
(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?]{
|
@defproc[(pairwise-coprime? [a Integer] [b Integer] ...) boolean?]{
|
||||||
Returns @racket[#t] if the integers @racket[a],@racket[b],... are pairwise coprime.
|
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.
|
The numbers 2, 6, and, 15 are not pairwise coprime, since 2 and 6 share the factor 3.
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(pairwise-coprime? 2 6 15)]
|
(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?]{
|
@defproc[(modular-inverse [a Integer] [n Integer]) natural?]{
|
||||||
Returns the inverse of @racket[a] module @racket[n],
|
Returns the inverse of @racket[a] module @racket[n],
|
||||||
if @racket[a] and @racket[n] are coprime,
|
if @racket[a] and @racket[n] are coprime,
|
||||||
|
@ -97,12 +97,12 @@
|
||||||
The number 0 has no inverse modulo 5.
|
The number 0 has no inverse modulo 5.
|
||||||
@interaction[(require math)
|
@interaction[(require math)
|
||||||
(modular-inverse 0 5)]
|
(modular-inverse 0 5)]
|
||||||
@; http://en.wikipedia.org/wiki/Modular_multiplicative_inverse
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@defproc[(solve-chinese [as (Listof Integer)] [bs (Listof Integer)]) natural?]{
|
@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]
|
Given a list of integers @racket[as] and a list of coprime moduli @racket[ns]
|
||||||
the function @racket[solve-chinese] will return
|
the function @racket[solve-chinese] will return
|
||||||
the single natural solution @racket[x] in @racket[{0,...,n-1}]
|
the single natural solution @racket[x] in @racket[{0,...,n-1}]
|
||||||
|
@ -120,8 +120,6 @@
|
||||||
when divided by 7 leaves a remainder of 2?
|
when divided by 7 leaves a remainder of 2?
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(solve-chinese '(2 3 2) '(3 5 7))]
|
(solve-chinese '(2 3 2) '(3 5 7))]
|
||||||
|
|
||||||
@; http://en.wikipedia.org/wiki/Chinese_remainder_theorem
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(quadratic-residue? [a natural?] [n natural?]) boolean?]{
|
@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,
|
The functions @racket[totient], @racket[moebius-mu], and,
|
||||||
@racket[divisor-sum] are multiplicative.
|
@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?]{
|
@defproc[(totient [n Natural]) natural?]{
|
||||||
Returns the number of integers from 1 to @racket[n]
|
Returns the number of integers from 1 to @racket[n]
|
||||||
that are coprime with @racket[n].
|
that are coprime with @racket[n].
|
||||||
|
@ -412,12 +411,13 @@ Note: The function @racket[totient] is multiplicative.
|
||||||
(require racket/function) ; for curry
|
(require racket/function) ; for curry
|
||||||
(totient 9)
|
(totient 9)
|
||||||
(length (filter (curry coprime? 9) (range 10)))]
|
(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)]{
|
@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:
|
Returns:
|
||||||
|
|
||||||
@racket[1] if @racket[n] is a product of an even number of primes
|
@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))
|
||||||
(moebius-mu (* 2 3 5 7))
|
(moebius-mu (* 2 3 5 7))
|
||||||
(moebius-mu (* 2 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?]{
|
@defproc[(divisor-sum [n Natural] [k Natural]) natural?]{
|
||||||
Returns sum of the @racket[k]th powers of
|
Returns sum of the @racket[k]th powers of
|
||||||
all divisors of @racket[n].
|
all divisors of @racket[n].
|
||||||
|
@ -446,37 +445,32 @@ Note: The function @racket[divisor-sum] is multiplicative.
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(divisor-sum 12 2)
|
(divisor-sum 12 2)
|
||||||
(apply + (map sqr (divisors 12)))]
|
(apply + (map sqr (divisors 12)))]
|
||||||
|
|
||||||
@; http://en.wikipedia.org/wiki/Divisor_function
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@; ----------------------------------------
|
@; ----------------------------------------
|
||||||
@section[#:tag "number-sequences"]{Number Sequences}
|
@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?]{
|
@defproc[(bernoulli [n Natural]) exact-rational?]{
|
||||||
Returns the @racket[n]th Bernoulli number.
|
Returns the @racket[n]th Bernoulli number.
|
||||||
Definition:
|
|
||||||
@url{http://en.wikipedia.org/wiki/Bernoulli_number}.
|
|
||||||
|
|
||||||
@interaction[#:eval untyped-eval
|
@interaction[#:eval untyped-eval
|
||||||
(map bernoulli (range 9))]
|
(map bernoulli (range 9))]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@margin-note{MathWorld: @hyperlink["http://mathworld.wolfram.com/EulerianNumber.html"]{Eulerian Number}}
|
||||||
@defproc[(eulerian-number [n Natural] [k Natural]) natural?]{
|
@defproc[(eulerian-number [n Natural] [k Natural]) natural?]{
|
||||||
Returns the Eulerian number @math-style{<n,k>}.
|
Returns the Eulerian number @math-style{<n,k>}.
|
||||||
Definition:
|
|
||||||
@url{http://mathworld.wolfram.com/EulerianNumber.html}.
|
|
||||||
|
|
||||||
@interaction[(require math racket)
|
@interaction[(require math racket)
|
||||||
(eulerian-number 5 2)]
|
(eulerian-number 5 2)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Fibonacci_number"]{Fibonacci Number}}
|
||||||
@defproc[(fibonacci [n Natural]) natural?]{
|
@defproc[(fibonacci [n Natural]) natural?]{
|
||||||
Returns the @racket[n]th Fibonacci number.
|
Returns the @racket[n]th Fibonacci number.
|
||||||
See
|
|
||||||
@url{http://en.wikipedia.org/wiki/Fibonacci_number}
|
|
||||||
for a definition.
|
|
||||||
|
|
||||||
The ten first Fibonacci numbers.
|
The ten first Fibonacci numbers.
|
||||||
@interaction[(require math racket)
|
@interaction[(require math racket)
|
||||||
|
@ -502,9 +496,10 @@ are less than or equal to @racket[n].
|
||||||
(farey 3)]
|
(farey 3)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@margin-note{MathWorld: @hyperlink["http://mathworld.wolfram.com/TangentNumber.html"]{Tangent Number}}
|
||||||
@defproc[(tangent-number [n integer?]) integer?]{
|
@defproc[(tangent-number [n integer?]) integer?]{
|
||||||
Returns the @racket[n]th tangent number.
|
Returns the @racket[n]th tangent number.
|
||||||
See @url{http://mathworld.wolfram.com/TangentNumber.html} for a definition.
|
|
||||||
@interaction[(require math)
|
@interaction[(require math)
|
||||||
(tangent-number 1)
|
(tangent-number 1)
|
||||||
(tangent-number 2)
|
(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?]{
|
@defproc[(partition-count [n Natural]) natural?]{
|
||||||
Returns the number of partitions of @racket[n].
|
Returns the number of partitions of @racket[n].
|
||||||
A partition of a positive integer @racket[n] is a way
|
A partition of a positive integer @racket[n] is a way
|
||||||
of writing @racket[n] as a sum of positive integers.
|
of writing @racket[n] as a sum of positive integers.
|
||||||
The number 3 has the partitions @math-style{1+1+1, 1+2, 3}.
|
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)
|
@interaction[(require math racket)
|
||||||
(partition-count 3)
|
(partition-count 3)
|
||||||
(partition-count 4)]
|
(partition-count 4)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user