Dasturi:
Dastur tuzishda yuqoridagidek konsol ilovadan foydalanamiz. Dastur matni quyidagicha bo‘ladi:
#include
#include
using namespace std;
float f(float t)
{
return 1/sqrt(abs(cos(t)-pow(t,2)));
}
int main ()
{
float S,a,b,h,x; int n,i;
cin>>a>>b>>n;
h=(b-a)/(2*n);
S=f(a)+f(b);
for (i=1;i<2*n;i++)
{
x=a+i*h;
if (i%2==0) S=S+2*f(x); else S=S+4*f(x);
}
S=S*h/3;
cout< return 0;
}
Bu dasturlarda natijaning aniqligini oshirish uchun bo‘laklashlar sonini yetarli darajada oshirish lozim.
Masalan, n=500 da natija quyidagidek bo‘ladi:
Natija n=50000 da quyidagidek bo‘ladi:
Bu aniq integralni MathCAD dasturida ham hisoblaymiz:
Quyidagi integrallar taqribiy hisoblansin,
1) 11)
2) . 12)
3) . 13)
4) . 14)
5) 15)
6) 16)
7) 17)
8) 18)
9) 19)
10) 20)
Foydalanilgan adabiyot
J.B. Dixit. Fundamentals of computer programming and Information texnology. India. 2009.
№13
|
|
№14
|
|
№15
|
|
№16
|
|
№17
|
|
№18
|
|
№19
|
|
№20
|
|
Do'stlaringiz bilan baham: |