gn="justify"> На кожній ітерації рахуємо по одному значенню функції, оскільки одне вже пораховано раніше і являє собою точку золотого перетину.
4.2 Лістинг програми
unit Unit1;, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,, TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls, Buttons,, Math, jpeg; _Form1 = class ( TForm) _Button1: TButton; _Chart1: TChart;: TLineSeries; _BitBtn1: TBitBtn;: TPointSeries; _StringGrid1: TStringGrid; _StringGrid2: TStringGrid; __Label4: TLabel;: TImage;: TRadioButton;: TRadioButton;: TRadioButton;: TRadioButton;: TRadioButton; : TRadioButton;: TPointSeries;: TLabel;: TLabel;: TEdit;: TEdit;: TLabel; Kovalenko_Button1Click (Sender: TObject); Kovalenko_BitBtn1Click (Sender: TObject);
{Private declarations}
{Public declarations}; matr = array [1 .. 7,1 .. 7] of real; mass = array [1 .. 7] of real; _Form1:
{$ R *. dfm} TKovalenko_Form1.Kovalenko_Button1Click (Sender: TObject); r = 0.000001; a0 = 1; b0 = 2; _Chart1.Visible: = true; _StringGrid2.Visible: = true;: = 7; i : = 1 to m +1 do [i]: = 0; d [i]: = 0; XX [I]: = 0;: = 0; q: = 0; f: = 0; [1]: = 0.5; y [1]: = -5.5; [2]: = 1; y [2]: = 0.55; [3]: = 1.5; y [3]: = -10; [4]: ​​= 2; y [4]: = 11.5; [5]: = 2.5; y [5]: = 9.5; [6]: = 3; y [6]: = -10.2; [7]: = 3.5; y [7]: = 11.5; j: = 1 to 7 do_Chart1.SeriesList.Series [1]. AddXY (x [j], y [j], '', clyellow);; RadioButton1.Checked then m: = 1; RadioButton2.Checked then m: = 2; RadioButton3.Checked then m: = 3; RadioButton4.Checked then m: = 4; RadioButton5.Checked then m: = 5; RadioButton6.Checked then m: = 6; [1,1]: = n; i: = 1 to m +1 dok: = 1 to m +1 do: = 0; j: = 1 to n do: = s + power (x [j], (i + k-2)); [i , k]: = s;; i: = 1 to m +1 do: = 0; j: = 1 to n do: = s + ((power (x [j], i-1)) * y [j] ); [i]: = s;;
{Метод Гаусса} i: = 1 to (m +1) do [i, i]: = 1; [1, i]: = a [1, i]/a [1,1]; [i , 1]: = a [i, 1];; [1]: = d [1]/a [1,1]; i: = 2 to (m +1) dok: = i to (m +1) do: = 0; j: = 1 to i-1 do: = s + c [k, j] * b [j, i]; [k, i]: = a [k, i]-s;; k : = i +1 to (m +1) do: = 0; j: = 1 to i-1 do: = s + c [i, j] * b [j, k]; [i, k]: = (a [i, k] - s)/c [i, i];;; i: = 2 to (m +1) do: = 0; j: = 1 to i-1 do: = s + c [ i, j] * YY [j]; [i]: = (d [i]-s)/c [i, i];; [n]: = YY [n]; i: = 1 to n-1 do: = 0; j: = n-i +1 to n do: = s + b [ni, j] * XX [j]; [ni]: = YY [ni]-s;; i: = 1 to m +1 do_StringGrid1.Cells [Kovalenko_StringGrid1.colCount-
to 1500 do: = 0; i: = 1 to (m +1) do: = s + XX [i] * (power (q, i-1));
1,0]: = FloatToStrF (q, ffGeneral, 6,6); _StringGrid2.Cells [Kovalenko_StringGrid2.colCount-
1,1]: = FloatToStrF (f, ffGeneral, 6,6); _StringGrid2.ColCount: = Kovalenko_StringGrid2.ColCount +1;
end;
{Метод золотого перерізу}
ax: = 1; bx: = 2; X1: = 0; X2: = 0; abs (bx-ax)> = r do: = ax +0.382 * (bx-ax);: = ax + 0.618 * (b...