Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const float precision_d = 0.0001;
- // the closer precision_d will be to 0, the more zeta
- // should theoretically be accurate in the negatives !
- // although, there are precision errors practically,
- // but i'll go further in depth in the code. ^^
- double zeta (double x, double z[5000], bool osef = false) {
- double e_x = 2*int(x/2);
- if (x >= 0 and x < 2) { z[0] = -0.5; }
- else if (x >= 2 and x < 4) { z[2] = 1.644934066848226436472415166646; }
- else if (x >= 4) {
- double ret = 0;
- double e_i;
- for (int i = 1; i <= e_x/2-1; i++) {
- e_i = 2*i;
- ret += z[int(e_i)]*z[int(e_x-e_i)];
- }
- ret *= 2/(e_x+1);
- z[int(e_x)] = ret;
- }
- if (osef) return z[int(e_x)];
- else {
- if (x >= 0) return ((e_x-1)*(e_x-x+2)*z[int(e_x)]+(x-e_x)*(e_x+1)*zeta(x+2,z,true))*0.5/(x-1);
- // c++ is kinda shit doe precisionwise so it'll basically be 0 far enough
- // in the negatives bcs he thinks it's 1 far enough in the positives... :/
- else if (x < 0) {
- double gamma = 0;
- for (float d = precision_d; d < 1; d += precision_d) {
- gamma += precision_d/pow(log(1/d),x);
- }
- return pow(2,x)*pow(3.1415926535897932384626433832795,x-1)*sin(3.1415926535897932384626433832795*x/2)*gamma*zeta(1-x,z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement