using System using System Collections Generic using System Linq using

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simple_Iteration {
class Program {
public static double eps = 0.0001;
public static double F(double x) {
double retValue = Math.Sqrt((1 - x) - Math.Tan(x));
return retValue;
}
public static double GetSolve(double leftRange, double rightRange, double lyambda) {
double x1 = leftRange,
x2 = 0.0,
d = 0.0;
do {
x2 = x1 + lyambda * F(x1);
d = Math.Abs(x2 - x1);
x1 = x2;
} while (d > eps);
return x1;
}
static void Main(string[] args) {
double leftRange = 0.0,
rightRange = 1.0,
lyambda = 0.00599,
x = 0;
Console.WriteLine("Границы нахождения корня [{0},{1}]", leftRange, rightRange);
x = GetSolve(leftRange, rightRange, lyambda);
Console.WriteLine("x = {0:f5}", x);
Console.WriteLine("Проверка верности найденного корня:\nF(x1) = {0:f2}", F(x));
Console.ReadKey();
}
}
}