- Joined
- 1/13/11
- Messages
- 1,362
- Points
- 93
Hello again! I need a help in identifying the problem why I don't get the correct answer in the following algorithm. I have defined the Gauss Quadrature algorithm and I always get the integral between [0,1] interval whatever the function I use.
Here assume that the F function is not delegated but simply defined and invoked in the method.
Thank you
C++:
static double Iteration(double[] qsi, double[] w, double delta){
double[] qsi_5 = { 0, 0.5384693101056830910363144, 0.9061798459386639927976269 };
double[] w_5 = { 0.5688888888888888888888889,
0.4786286704993664680412915,
0.2369268850561890875142640 };
return Iteration(qsi_5, w_5, delta);
}
C++:
static double Iteration(double[] qsi, double[] w, double delta)
{
double S = 0;
int n = qsi.Length;
if (qsi[0] == 0)
{
for (int i = 1; i < n; i++)
{
S += w[i] * F(delta * qsi[i] + delta);
S += w[i] * F(-delta * qsi[i] + delta);
}
S += w[0] * F(delta);
S *= delta;
}
else
{
for (int i = 0; i < n; i++)
{
S += w[i] * F(delta * qsi[i] + delta);
S += w[i] * F(-delta * qsi[i] + delta);
}
S *= delta;
}
return S;
}
Here assume that the F function is not delegated but simply defined and invoked in the method.
Thank you