using System using System Collections Generic using System ComponentMo

 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Метод_простой_итерации
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double phi1(double x, double y, double z)
{
return 0.1 * Math.Sin(x) + 0.3 * Math.Cos(y) + 0.2 * Math.Cos(z) - 0.4;
}
double phi2(double x, double y, double z)
{
return 0.2 * Math.Cos(x) - 0.1 * Math.Sin(y) + 0.3 * Math.Sin(z) - 0.3;
}
double phi3(double x, double y, double z)
{
return 0.3 * Math.Sin(x) + 0.2 * Math.Cos(y) - 0.1 * Math.Cos(z) - 0.2;
}
private void Form1_Load(object sender, EventArgs e)
{
double eps = 1e-5;
double[] x = new double[] { 1, 1, 1 };
int n = x.Length;
double norm = 0;
double[] xNext = new double[n];
int count = 1;
do
{
xNext[0] = phi1(x[0], x[1], x[2]);
xNext[1] = phi2(x[0], x[1], x[2]);
xNext[2] = phi3(x[0], x[1], x[2]);
norm = 0;
for (int i = 0; i < n; ++i)
{
norm = Math.Max(Math.Abs(xNext[i] - x[i]), norm);
}
chart1.Series[0].Points.AddXY(count, xNext[0]);
chart2.Series[0].Points.AddXY(count, xNext[1]);
chart3.Series[0].Points.AddXY(count, xNext[2]);
count++;
for (int k = 0; k < n; k++)
{
x[k] = xNext[k];
}
} while (norm > eps);
}
}
}