Added von Mangoldt function

This commit is contained in:
Jens Axel Søgaard 2012-11-22 01:10:29 +01:00
parent 11a5721b59
commit fdfaf6bee0
2 changed files with 23 additions and 0 deletions

View File

@ -44,6 +44,7 @@
totient
moebius-mu
divisor-sum
mangoldt-lambda
)
;;;
@ -322,6 +323,7 @@
; Factor a number n without prime factors below the prime p.
(define (small-prime-factors-over n p) ; p prime
(cond
[(<= p 0) (raise-argument-error 'small-prime-factors-over "Natural" p)]
[(< n p) '()]
[(= n p) (list (list p 1))]
[(prime? n) (list (list n 1))]
@ -689,6 +691,14 @@
ps es))
natural?))])))
(: mangoldt-lambda : Z -> Real)
(define (mangoldt-lambda n)
(cond
[(<= n 0) (raise-argument-error 'mangoldt-lambda "Natural" n)]
[else (define am (prime-power n))
(cond
[(cons? am) (log (car am))]
[else 0])]))
; These tests are for un-exported functions.
#;(begin

View File

@ -561,6 +561,19 @@ Note: The function @racket[prime-omega] is multiplicative.
(prime-omega (* 2 2 2 3 3 5))]
}
@margin-note{Wikipedia: @hyperlink["http://en.wikipedia.org/wiki/Von_Mangoldt_function"]{Von Mangoldt Function}}
@defproc[(mangoldt-lambda [n Natural]) Real]{
The von Mangoldt function.
If @racket[n=p^k] for a prime @racket[p] and an integer @racket[k>=1] then @racket[(log n)] is returned.
Otherwise 0 is returned.
@interaction[#:eval untyped-eval
(mangoldt-lambda (* 3 3))
(log 3)]
}
@; ----------------------------------------
@section[#:tag "number-sequences"]{Number Sequences}