C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <math.h>
float f(float x)
{
return 4 * (x * x + 1) * log(x) - 1;
}
void main()
{
float x0 = 0.1, x1 = 2.00, x2;
float E = 0.01;
int count = 0;
while ((f(x1)) > E)
{
if (f(x1) == f(x0))
{
printf("Ошибка: деление на ноль. Выберите другой интервал.\n");
return;
}
x2 = x1 - f(x1) * (x1 - x0) / (f(x1) - f(x0));
x0 = x1;
x1 = x2;
count++;
}
printf("x: %f\n", x1);
printf("f(x): %f\n", f(x1));
Enter to Rename, Shift+Enter to Preview
OUTPUT
Ejecutar