From fdfaf6bee008b4b35c03ba1ce027e6eac8281f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Axel=20S=C3=B8gaard?= Date: Thu, 22 Nov 2012 01:10:29 +0100 Subject: [PATCH] Added von Mangoldt function --- .../math/private/number-theory/number-theory.rkt | 10 ++++++++++ collects/math/scribblings/math-number-theory.scrbl | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/collects/math/private/number-theory/number-theory.rkt b/collects/math/private/number-theory/number-theory.rkt index 292f2a25b8..ee0a1757cf 100644 --- a/collects/math/private/number-theory/number-theory.rkt +++ b/collects/math/private/number-theory/number-theory.rkt @@ -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 diff --git a/collects/math/scribblings/math-number-theory.scrbl b/collects/math/scribblings/math-number-theory.scrbl index 09ee2245aa..a0d6fdc03b 100644 --- a/collects/math/scribblings/math-number-theory.scrbl +++ b/collects/math/scribblings/math-number-theory.scrbl @@ -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}