Task 10 and 11 are done

This commit is contained in:
AZEN-SGG 2025-05-14 20:12:23 +03:00
parent ff1903ff80
commit c40059bcdc
19 changed files with 741 additions and 0 deletions

46
2025.05.09/11Ex/solve.c Normal file
View file

@ -0,0 +1,46 @@
#include "solve.h"
#include "integral.h"
#include <math.h>
#include <float.h>
#define MAX_ITER 30
double t11_solve (
double (*f) (double),
double a, double eps,
double *res
) {
int it;
int h = 1;
double b = a;
double integ = 0;
for (it = 1; it <= MAX_ITER; ++it)
{
int n;
double ipart = 0;
b += h;
n = simpson(f, a, b, eps, &ipart);
if (n < 0)
return -2;
integ += ipart;
if (fabs(ipart) < eps)
break;
a = b;
h <<= 1;
}
if (it > MAX_ITER)
return -1;
*res = integ;
return b;
}