﻿ estimate signs
```/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                             C
C  COMPUTE UPPER BOUND MINUS LOWER BOUND (AND ESTIMATED VALUES) 	      C
C  06/03/14 (DKC)							      C
C                                                                             C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/
#include <stdio.h>
#include <math.h>
unsigned int euler(unsigned int a);
double mertens(unsigned int, unsigned int *count, double *sum);
//
unsigned int out=2;  // sum, estimated sum, exceptions
double inc=0.0;      // esum+increment
//
void main() {
unsigned int N,MAXN;
unsigned int i,j,temp,clsave,crsave,count[2],histop[100],histopn[100];
unsigned int histon[100],histonn[100],histox,histoxn;
double sum,sum1,msum,mlsave,mrsave,lratio,rratio,tsum[2],esum,tmpsum;
FILE *Outfp;
Outfp = fopen("out1b5.dat","w");
for (i=0; i<100; i++) {
histop[i]=0;
histopn[i]=0;
histon[i]=0;
histonn[i]=0;
}
histox=0;
histoxn=0;
MAXN=900;
for (N=2; N<=MAXN; N++) {
sum=0.0;
sum1=0.0;
for (i=1; i<=N; i++) {
msum=mertens(N/i, count, tsum);
if (i==1) {
mlsave=tsum[0];
mrsave=tsum[1];
clsave=count[0];
crsave=count[1];
esum=msum;
//	 printf(" %d %d %e %e \n",clsave,crsave,mlsave,mrsave);
}
//
// compute sums
//
temp=euler(i);
if ((temp/4)*4!=temp) {
sum=sum+msum*(double)i/(double)temp;
sum1=sum1+esum*(double)i/(double)temp;
}
//    printf(" %d %d %d %e %e \n",i,count[0],N/i,sum,msum);
if (i!=1) {
if (clsave!=0)
lratio=(double)count[0]/(double)clsave;
else
lratio=1.0;
if (crsave!=0)
rratio=(double)count[1]/(double)crsave;
else
rratio=1.0;
esum=mlsave*lratio+mrsave*rratio;
esum=esum*2.0;
//	 fprintf(Outfp," i=%d %d %d %e %e %e %e %e %e \n",i,count[0],count[1],tsum[0],tsum[1],
//		  lratio,rratio,msum,esum);
//
// histogram (for msum>0)
//
if ((msum>0.0)&&(i<=(N/2))) {
j=(unsigned int)(msum+0.0001);
if ((j<100)&&(j!=0)) {
histop[j]=histop[j]+1;
if (esum+inc>0.0)
histopn[j]=histopn[j]+1;
}
printf("N=%d, i=%d, N/i=%d, msum=%e, esum=%e \n",N,i,N/i,msum,esum);
fprintf(Outfp,"N=%d, i=%d, N/i=%d, msum=%e, esum=%e \n",N,i,N/i,msum,esum);
}
//
// histogram (for msum<0)
//
if (msum<0.0) {
tmpsum=-msum;
j=(unsigned int)(tmpsum+0.0001);
if ((j<100)&&(j!=0)) {
histon[j]=histon[j]+1;
if (esum-inc<0.0)
histonn[j]=histonn[j]+1;
}
}
//
// histogram (for msum==0)
//
if (msum<0.0)
tmpsum=-msum;
else
tmpsum=msum;
j=(unsigned int)(tmpsum+0.0001);
if ((j==0)&&(i<=(N/3))) {
histox=histox+1;
if (esum<0.0)
tmpsum=-esum;
else
tmpsum=esum;
j=(unsigned int)(tmpsum+0.1);
if (j==0)
histoxn=histoxn+1;
}
}
}
if (sum<0.0)
sum=-sum;
if (sum1<0.0)
sum1=-sum1;
if (out==0)
fprintf(Outfp," %e\n",sum);
else {
if (out==1)
fprintf(Outfp," %e\n",sum1);
}
}
fprintf(Outfp,"\n");
printf("  %d, %d, %d \n",0,histox,histoxn);
fprintf(Outfp,"  %d, %d, %d \n",0,histox,histoxn);
for (i=1; i<20; i++) {
printf("  %d, %d %d %d %d \n",i,histop[i],histopn[i],histon[i],histonn[i]);
fprintf(Outfp,"  %d, %d %d %d %d \n",i,histop[i],histopn[i],histon[i],histonn[i]);
}
fclose(Outfp);
return;
}
```