The power series for it is shown below Write a Matlab script
     The power series for it is shown below. Write a Matlab script that applies this series until the last term divided by the current estimate of pi is less than 10^-8 using a for loop.  Pi = squareroot 12 sigma^infinity_k = 0 (-3)^-k/(2k + 1) 
  
  Solution
#include <iostream>
 #include<cmath>
 using namespace std;
 int main()
 {
 double sq = sqrt(12.0);
 double pi = sqrt(12.0);;
 double term,sum=0;
 for(int i=0;;i++)
 {
 term = double(pow(double(-3.0),-i))/double(2.0*i+1);
 if(abs(term/pi) < 0.00000001)
 {
 break;
 }
 sum += term;
 pi = sq * sum;
 }
 cout<<\"\ Pi value is\"<<pi<<endl;
 }

