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

View file

@ -3,12 +3,24 @@
#include <math.h>
#include <float.h>
int t3_solve (
double t4_solve (
double (*f) (double),
double x, double h
double a, double b,
int n
) {
if (h < DBL_EPSILON)
const double h = (b - a) / n;
double x = a;
double sum = (f(a) + f(b)) * 0.5;
if (h < NUM_FPE)
return DBL_MAX;
return (f(x + h) - 2 * f(x) + f(x - h)) / (h * h);
for (int i = 1; i < (n - 1); ++i)
{
x += h;
sum += f(x);
}
return h * sum;
}