Kod: Zaznacz cały
double simson(double xp,double xk, int N,double e)
{double s,st,dx,x,c;
s = 0; st = 0;
do
{
c=s;
dx = (xk - xp) / N;
for(int i = 1; i <= N; i++)
{
x = xp + i * dx;
st += funkcja(x - dx / 2);
if(i < N) s += funkcja(x);
}
s = dx / 6 * (funkcja(xp) + funkcja(xk) + 2 * s + 4 * st);
N++;
cout<<s<<endl;
cout<<c<<endl;
Sleep(2000);
}while(abs(s-c)>e);
return s;
}