Created
October 26, 2017 05:28
-
-
Save celestialphineas/09a5b2a026af987d2051fe06e3c4467a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void Series_Sum(double sum[]); | |
int main(void) | |
{ | |
int i; | |
double x, sum[3001]; | |
Series_Sum(sum); | |
x = 0.0; | |
for(i = 0; i < 3001; i++) | |
{ | |
printf("%6.2f %16.12f\n", x + (double)i * 0.10, sum[i]); | |
} | |
return 0; | |
} | |
void Series_Sum(double sum[]) | |
{ | |
// Calculating the integer x | |
sum[0] = 3.14159265358979*3.14159265358979/6; | |
for(int x = 1; x <= 300; x++) | |
{ | |
double result = 0.; | |
for(int i = 1; i <= x; i++) | |
{ | |
result += 1./i; | |
} | |
result /= x; | |
sum[10*x] = result; | |
} | |
sum[1] = 1.5346072449042678; | |
sum[2] = 1.4408788415461881; | |
sum[3] = 1.3600825867817216; | |
sum[4] = 1.2895778007901921; | |
sum[5] = 1.2274112777593080; | |
sum[6] = 1.1721051961241164; | |
sum[7] = 1.1225193425349446; | |
sum[8] = 1.0777588727436109; | |
sum[9] = 1.0371109178502935; | |
for(int i = 11; i <= 3000; i++) | |
{ | |
if(!(i%10)) continue; | |
sum[i] = (i-10)*sum[i-10]/i + 100./(i*i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version 3 of “Numerical Summation of a Series”