Скачиваний:
55
Добавлен:
15.06.2014
Размер:
90.25 Кб
Скачать

/*

Трацевский Никита Андреевич, группа 243302

Лабораторная работа №1

Тема: РЕШЕНИЕ СИСТЕМ ЛИНЕЙНЫХ АЛГЕБРАИЧЕСКИХ УРАВНЕНИЙ (СЛАУ)

Вариант 1

*/

Консольный режим.

Код программы:

#include <vcl.h>

#pragma hdrstop

#include <math.h>

#include <iostream.h>

#include <conio.h>

#include <iomanip.h>

#pragma argsused

double F(double x);

double F(double x)

{

return 4 * x - 7 * sin(x);

}

double F1(double x);

double F1(double x)

{

return 4 - 7 * cos(x);

}

double F2(double x);

double F2(double x)

{

return 7 * sin(x);

}

double D1F(double x, double hp);

double D1F(double x, double hp)

{

return (F(x + hp) - F(x - hp)) / (2 * hp) ;

}

double D2F(double x, double hp);

double D2F(double x, double hp)

{

return (F(x + hp) - 2*F(x) + F(x - hp)) / (hp * hp);

}

double integral(double a, double b, int m);

double integral(double a, double b, int m)

{

cout << "koli4estvo shagov dlya Integrala ";

cin >> m;

double x = a, h, Int = 0;

h = (b-a) / m;

for (int i = 0; i<m; i++)

{

Int += F((2*x + h)/2);

x +=h;

}

Int *=h;

return Int;

}

int main(int argc, char* argv[])

{

double x, a = -2, m, hp, b = 3, Int;

x= a;

int j, i;

cout << "Shag dlya d1,d2 = ";

cin >> hp;

for (j =0; j<21; j++)

{

x = a + j *(b - a)/20;

double y = F(x);

double d1 = D1F(x, hp);

double d2 = D2F(x, hp);

double d1t = F1(x);

double d2t = F2(x);

double del1 = fabs(d1t - d1);

double del2 = fabs(d2t - d2);

cout << "|_ d1t _|_ d1 _|_ del1 _|_ d2t _|_ d2 _|_ del2 _|";

printf("\n|_ %7.4f _|_ %5.4f _|_ %5.4f _|_ %5.4f _|_ %5.4f _|_ %5.4f _|\n",d1t, d1, del1, d2t, d2, del2);

cout << "_________________________________________________________________"<<endl;

}

Int = integral (a, b, m);

cout << "\nIntegral =" << Int;

getch();

}

Скриншот работоспособности программы:

Соседние файлы в папке Лаба 1-6 ОАИП, 2сем, 1 курс [Вариант 1]