Task 8 is done

This commit is contained in:
AZEN-SGG 2025-05-11 09:09:14 +03:00
parent 84233f1e84
commit 0cde98a554
2 changed files with 8 additions and 58 deletions

View file

@ -1,50 +0,0 @@
#ifndef COMP_H
#define COMP_H
#include <float.h>
#include <math.h>
static inline double * fpmax (double *pa, double *pb, double fa, double fb, double *max_f_p)
{
if ((fa - fb) > DBL_EPSILON)
{
*max_f_p = fa;
return pa;
} else
{
*max_f_p = fb;
return pb;
}
}
static inline double * fp_abs_max (double *pa, double *pb, double *fa, double *fb, double **max_f_p)
{
if ((fabs(*fa) - fabs(*fb)) > DBL_EPSILON)
{
*max_f_p = fa;
return pa;
} else
{
*max_f_p = fb;
return pb;
}
}
static inline int is_equal (const double a, const double b)
{
double diff = a - b;
double max_val = (a > b) ? a : b;
return ((diff < 0) ? -diff : diff) < (DBL_EPSILON * max_val);
}
static inline int is_null (const double a)
{
return ((a < 0) ? -a : a) < DBL_EPSILON;
}
static inline int is_eps (const double a, const double eps)
{
return (((a < 0) ? -a : a) - eps) < DBL_EPSILON;
}
#endif

View file

@ -33,20 +33,20 @@ int t8_solve (
y_l = y;
x += h;
y = f(x);
if ((y_l - y) > DBL_EPSILON)
break;
if ((a - x) > DBL_EPSILON || (x - b) > DBL_EPSILON) {
*res = x_l;
return it;
}
y = f(x);
if ((y_l - y) > DBL_EPSILON) {
if ((y_l - y) < eps) {
*res = x_l;
return it;
}
break;
}
}
if ((y_l - y) < eps) {
*res = x_l;
return it;
}
}