Why won't the following program work?
#include <iostream>
#include <cmath>
double GetDerivative(double (*F)(double x), double x, double y)
{
double dFdx = (F(x+y)-F(x-y))/(2*y); }
void Integrate (double (*Fcn)(double x), double arrX[], double arrY[],double dblXmin, double dblXmax, int intDivisions)
{
double dx = (dblXmax - dblXmin)/intDivisions;
double x, y = 0.0, dblArea;
arrX[0] = dblXmin;
arrY[0] = 0;
for (int i = 1; i<= intDivisions; ++i)
{
x = dblXmin + (double) i*dx;
dblArea = (Fcn(x-dx) + Fcn(x))/2.0 *dx;
y += dblArea;
arrX = x;
arrY = y;
}
int main (int argc, char* argv[])
{
double xmin, ymax, arrx, arry, x, y, arrX, arrY;
int intDivisions, i;
int division1, division2, division3, division4;
cout<<"please enter the lower bound (0) and enter a space, the upper bound (100)and hit enter.\n";
cin>>xmin>>ymax;
double dblXmin = xmin;
double dblXmax = ymax;
cout<<"please enter one of the following subdivisions followed by the space bar, 10, 100, 1000, 10000
hit enter.\n";
cin>>intDivisions;
cout<<"you entered, "<<intDivisions<<endl;
//intDivisions = division1;
i = intDivisions;
x = new arrx;
y = new arry;
cout<<Integrate(GetDerivative, x, y, double xmin, double ymax, i)<<endl;
delete []x;
delete []y;
}
#include <iostream>
#include <cmath>
double GetDerivative(double (*F)(double x), double x, double y)
{
double dFdx = (F(x+y)-F(x-y))/(2*y); }
void Integrate (double (*Fcn)(double x), double arrX[], double arrY[],double dblXmin, double dblXmax, int intDivisions)
{
double dx = (dblXmax - dblXmin)/intDivisions;
double x, y = 0.0, dblArea;
arrX[0] = dblXmin;
arrY[0] = 0;
for (int i = 1; i<= intDivisions; ++i)
{
x = dblXmin + (double) i*dx;
dblArea = (Fcn(x-dx) + Fcn(x))/2.0 *dx;
y += dblArea;
arrX = x;
arrY = y;
}
int main (int argc, char* argv[])
{
double xmin, ymax, arrx, arry, x, y, arrX, arrY;
int intDivisions, i;
int division1, division2, division3, division4;
cout<<"please enter the lower bound (0) and enter a space, the upper bound (100)and hit enter.\n";
cin>>xmin>>ymax;
double dblXmin = xmin;
double dblXmax = ymax;
cout<<"please enter one of the following subdivisions followed by the space bar, 10, 100, 1000, 10000
hit enter.\n";
cin>>intDivisions;
cout<<"you entered, "<<intDivisions<<endl;
//intDivisions = division1;
i = intDivisions;
x = new arrx;
y = new arry;
cout<<Integrate(GetDerivative, x, y, double xmin, double ymax, i)<<endl;
delete []x;
delete []y;
}