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
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();
}
const double eps = 1e-8;
double f(double x)
{
return 3.0 * x * x * x + 2.0 * x * x + x - 5.0;
}
double f1(double x)
{
return 9.0 * x * x + 4.0 * x + 1.0;
}
private void Form1_Load(object sender, EventArgs e)
{
double x0 = 0.0, x = 0.0;
double x1 = x0 - f(x0) / f1(x0);
while (Math.Abs(x1 - x0) > eps)
{
x0 = x1;
x1 = x0 - f(x0) / f1(x0);
chart1.Series[0].Points.AddXY(x, x1);
x += 1.0;
}
}
}
}