computing pi

Hello, i recently posted a question about this but my professor is at it again. this time he wants me to calculate pi using functions. i have to use a that calculates pi by calling on a function that calculates arctan by calling on a function that calculates x**n. i am so confused and he is of little help.
here is what i have so far:

// program to compute and print the value of pi
// using functions
//pi = 16*arctan(1/5) - 4*arctan(1/239)
//arctan(x) = x-x**3/3+x**5/5-x**7/7...
//date: 3/2/12

#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double pi();
double arctan(double x);
double tothepower(double x, int n); //computes x to the n

int main()
{
cout <<setprecision(15);
cout << "pi = " <<pi()<<endl;
return 0;
}

//computes pi using the arctan formula
//pi = 16*arctan(1/5) - 4*arctan(1/239)
double pi()
{
return 16*arctan(1.0/5.0) - 4*arctan(1.0/239.0);
}

//computes arctan of x using the formula
//arctan(x) = x - x**3/3 + x**5/5 - ...
//sums series til the answer doesnt change
//when i add the next term
double arctan(double x)
{
return 1; //stubbed out
}

// compute x raised to the n
//by repeated multiplication
double tothepower(double x, int n)
{

return x; //stubbed out
}
Topic archived. No new replies allowed.