Question 15. Of following picture how to write a program in c language for quest
ID: 3589738 • Letter: Q
Question
Question 15. Of following picture how to write a program in c language for question 15.
r = C(y/H) amount where amount is the initial amount in grams, C is expressed as e-0693 (e - 2.71828), y is the number of years elapsed, and H is the half-life of the isotope in years. 15. The value for can be determined by the series equation =4×11 3 5 79 11 13 Write a program to approximate the value of using the formula given includ- ing terms up through 1/99 16. In this chapter we studied the bisection method for finding a root of an equa- tion. Another method for finding a root, Newton's method, usually converges to a solution even faster than the bisection method, if it converges at all. Newton's method starts with an initial guess for a root, xo, and then generates successive approximate roots xi, x2, . .. , tj, x,.i, , using the iterative formula flx)Explanation / Answer
C code for calculating the series result for Fermat theorem:
#include<stdio.h>
#include<Math.h>
int main()
{
int numOfTerm=1,d;
double fermatSequence=1.0;
double piVal = 3.14159;
double piDerived;
double sig=-1.0;
printf("Fermat series calculation ");
for(d=3; d<200000; d+=2) {
fermatSequence=fermatSequence + sig*(1.0/(double)d);
piDerived = 4.0*fermatSequence;
numOfTerm++;
printf("piVal: %f ",piVal);
printf("piDerived:%f ",piDerived );
printf(" Terms:%d ",numOfTerm);
if( (piDerived <= (piVal-0.000005)) && (piDerived<= (piVal+0.000005)) ) {
printf("Number of terms need are: %d " + numOfTerm );
break;
}
sig=sig*-1.0;
}
}
Output:
Fermet series calculation
piVal:3.141590
piDerived:2.666667
Terms:2
number of terms need are: 2