Скачиваний:
25
Добавлен:
02.05.2014
Размер:
678 б
Скачать
//Lab 2_2_2
//Integral po formule Simpsona
#include <STDIO.h>
#include <MATH.h>
#include <CONIO.h>
#define n 100
int i;
float a, b, h, x, s, s1, s2, f[n];
main()
{
clrscr ();
a=0.2; b=10;
h=(b-a)/n;
f[1]=sqrt(pow((2+a), 3))/(a*a);
f[100]=sqrt(pow((2+b), 3))/(b*b);
for(i=1; i<n-1; i++)
         {
         x=(a+i*h);
         if (i%2==0)
            {
            f[i]=sqrt(pow((2+x),3))/(x*x);
            s1+=f[i];
            }
         else
            {
            f[i]=sqrt(pow((2+x), 3))/(x*x);
            s2+=f[i];
            }

         }

s=(h/3)*(f[1]+f[100]+(2*s1)+(4*s2));
printf ("\nZnachenie integrala s=%f", s);
getch ();
}
Соседние файлы в папке Лабораторная работа 2