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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class метод_итерации
{
static double func(double x)
{
return Math.Sin(1 / x) / (x * x);
}
static void Main(string[] args)
{
double a = 1, b = 2.5;
int n = 100000;
double h = (b - a) / n;
double answer = func(a) + func(b);
double local_answer = 0;
for (int i = 2; i < n; ++i)
{
double local_a = a + (b - a) * (i - 1) / n;
double local_b = a + (b - a) * i / n;
local_answer += (func(local_a) + func(local_b));
}
answer += 2 * local_answer;
answer *= h / 4;
Console.WriteLine("{0:f5}",answer);
Console.ReadKey();
}
}
}