First Problem
By the integral test, the difference between the sum of the infinite series and
the n-th partial sum is less than 1/(4*n^4). Therefore, for n=32 we see that
the difference is approximately 0.0000002. The partial sum in this case is
1.0369275 (by the program). Hence the sum must be between 1.0369275 and
1.0369277. Both numbers round off to 1.036928, so this is the correct result.
#include <stdio.h>
int main(){
int i, n;
double x, term, sum;
n=32;
for (i=1; i <=n; i=i+1){
x = 1/(double)i;
term = x*x*x*x*x;
sum = sum + term;
}
printf("The sum of %d terms is equal to %lf\n",n,sum);
}
Second Problem
By Leibniz test, the difference between the sum of the infinite series and
the n-th partial sum is less than the next term. Therefore, for n=18 we see that
the difference is approximately 0.0000004. The partial sum in this case is
0.9721195 (by the program). Hence the sum must be between 0.9721195 and
0.9721199. Both numbers round off to 0.972120, so this is the correct result.
This series converges faster as we can see form the above discussion (n^5 grows
faster than 4*n^4).
#include <stdio.h>
int main(){
int i, n;
double x, term, sum;
n=18;
for (i=1; i <=n; i=i+1){
x = 1/(double)i;
term = x*x*x*x*x;
if (i%2==1)
sum = sum + term;
else
sum = sum - term;
}
printf("The sum of %d terms is equal to %lf\n",n,sum);
}
Third Problem
#include <stdio.h>
#include <math.h>
#define Pi M_PI
int main(){
int i;
double x;
printf("Degree \t Sine \t \t Cosine \t Tangent \n");
printf("-------------------------------------------------\n");
for (i=0; i <= 90; i=i+1){
x = i/180.0*Pi;
printf("%d. \t %lf \t %lf \t %lf \n",i,sin(x), cos(x), tan(x));
}
}
Since Pi is irrational, it is represented by an approximate
rational number M_PI. Therefore, the conversion of 90 degrees into
radians is approximate. Since tan(x) tends to infinity as
x tends to Pi/2 we that the approximate value of
tangent at 90 degrees is a very large number.