Ki fakulteti ats 12 21 guruh talabasi


Download 23.31 Kb.
Sana17.06.2023
Hajmi23.31 Kb.
#1541383
Bog'liq
SMal4




MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
QARSHI FILIALI



KI FAKULTETI
ATS 12_21 GURUH TALABASI
Sattorov Xurshidning

Ma’lumotlar tuzilmasi va
algoritmlar
FANIDAN

4 - amaliy ishi


Bajardi: Murodaliyev S
Qabul qildi: Zohidov J

QARSHI-2022
4 - amaliy ishi

Berilgan funksiya uchun Fure koeffitsiyentalarini aniqlang, Hosil bo’lgan formula uchun algoritm va dastur tuzilsin! Bu yerda jurnal tartib raqami.


k = 16;
Dastur kodi :
#include
#include

const double PI = 3.14159265358979323846;

double f(double x) {
return 16 * cos(x);
}

double calculateFourierCoefficient(double (*function)(double), double x, int n, bool isCosine) {


double coefficient = 0.0;
double stepSize = 0.0001;

for (double t = -PI; t <= PI; t += stepSize) {


double value = function(t);

if (isCosine)


value *= cos(n * t);
else
value *= sin(n * t);

coefficient += value * stepSize;


}

return coefficient / PI;


}

int main() {


int n;

std::cout << "Nechta fur'e qator koeffisentlarini kerak : ";


std::cin >> n;

double a0 = calculateFourierCoefficient(f, 0, 0, true);


std::cout << "a0: " << a0 << std::endl;

for (int i = 1; i <= n; i++) {


double an = calculateFourierCoefficient(f, 0, i, true);
double bn = calculateFourierCoefficient(f, 0, i, false);

std::cout << "a" << i << ": " << an << std::endl;


std::cout << "b" << i << ": " << bn << std::endl;

}

return 0;


}
Natija:

Download 23.31 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling