Task 4 and 5 are done

This commit is contained in:
AZEN-SGG 2025-05-12 19:59:36 +03:00
parent 6efd4f5786
commit 67a26248b1
13 changed files with 285 additions and 90 deletions

26
2025.05.09/05Ex/solve.c Normal file
View file

@ -0,0 +1,26 @@
#include "solve.h"
#include <math.h>
#include <float.h>
double t5_solve (
double (*f) (double),
double a, double b,
int n
) {
const double h = (b - a) / (2 * n);
double x = a;
double sum = (f(a) + f(b)) * 0.5;
if (h < NUM_FPE)
return DBL_MAX;
for (int i = 1; i < (2 * n - 1); ++i)
{
x += h;
sum += ((i & 1) + 1) * f(x);
}
return (b - a) * sum / (3 * n);
}