Change Task 2

This commit is contained in:
AZEN-SGG 2025-05-02 02:28:33 +03:00
parent 71db8aa5cb
commit abe10d6036
2 changed files with 12 additions and 7 deletions

View file

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
cl = get_call_function_count();
if (it >= m)
if (it > m)
{
fprintf(stdout, "%s : Task = %d NOT FOUND Count = %d T = %.2f\n", argv[0], task, cl, t);
return -2;

View file

@ -10,20 +10,25 @@ int t2_solve (
int m, double *x
) {
int it = 0;
double y = f(x_0);
for (it = 1; it < m; ++it)
for (it = 1; it <= m; ++it)
{
double y = f(x_0);
double dy = d(x_0);
if (y - eps < DBL_EPSILON)
break;
x_0 -= (y / d(x_0));
y = f(x_0);
if (fabs(dy) < DBL_EPSILON)
{
it = m+1;
break;
}
x_0 -= (y / dy);
}
*x = x_0;
return it;
}