witam
chciałbym zrobić program króry policzy tą całke. Jej wynik wynosi 0 a mój program niestety takiego nie zwraca.
Moglibyście mi pomóc znaleźć błąd?
#include <iostream>
using namespace std;
int main (void)
{
double a,b,x1,x2,f1,f2,dx,P=0;
int n=100;
cout<<"podaj a :";
cin>>a;
cout<<"podaj b :";
cin>>b;
dx=(b-a)/n;
x1=a;
x2=x1+dx;
f1=sin(x1);
f2=sin(x2);
for (int i=0; i<n; i++)
{
P=P+((f1+f2)*0.5*dx);
x1=x2;
x2=x1+dx;
f1=f2;
f2=sin(x2);
}
cout<<P;
system ("pause");
}