Jump to content

Meissel–Mertens constant: Difference between revisions

Line 60:
*** last result: cpu time 1min, 18,085 ms, real time 1min, 18,094 ms.
?</pre>
===Analytic method===
The Analytic method requires high precision calculation of Riemann zeta function.
 
PARI/GP is well suited for that task.
<syntaxhighlight lang="parigp">{
Meissel_Mertens(d)=
default(realprecision, d);
my(prec = default(realprecision), z = 0, y = 0, q);
forprime(p = 2 , 7,
z += log(1.-1./p)+1./p
);
for(k = 2, prec,
q = 1;
forprime(p = 2, 7,
q *= 1.-p^-k
);
y += moebius(k)*log(zeta(k)*q)/k
);
Euler+z+y
};</syntaxhighlight>
{{out}}
1000 valid digits:
<pre>? Meissel_Mertens(1001)
%1 = 0.26149721284764278375542683860869585905156664826119920619206421392492451089736820971414263143424665105161772887648602199778339032427004442454348740197238640666194955709392581712774774211985258807266272064144464232590023543105177232173925663229980314763831623758149059290382284758265972363422015971458785446941586825460538918007031787714156680620570605257601785334398970354507934530971953511716888598019955346947142883673537117910619342522616975101911159537244599605203558051780574237201332999961769676911386909654186249097435916294862238555389898241954857937738258646582212506260380084370067541379219020626760709633535981989783010762417792511961619355361391684002933280522289185167238258837930443067100391254985761418536020400457460311825670423438456551983202200477824746954606715454777572171338072595463648319687279859427306787306509669454587505942593547068846408425666008833035029366514525328713339609172639368543886291288200447611698748441593459920236225093315001729474600911978170842383659092665509
? ##
*** last result: cpu time 283 ms, real time 284 ms.</pre>
 
=={{header|Phix}}==
40

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.