------------------------------------------ ------------------------------
__fastcall TForm1 :: TForm1 (TComponent * Owner)
: TForm (Owner)
{
}
vector Simple (double (* f) (vector ), vector x0, double h)
{fxk, fxk1; xk = x0; xk1 = x0; (int i = 0; i <2; i + +)
{
{= f (xk); [i] = xk [i] + h; = f (xk1); = xk1;
} (fxk> fxk1);
} (xk1);
} Descent (double (* f) (vector ), vector x0, double h, double e)
{ xk = x0; xk1 = x0; (int NumOfMetIt = 1;; NumOfMetIt + +)
{-> LabeledEdit3-> Text = IntToStr (NumOfMetIt); = Simple (f, xk, h); -> Series1-> AddXY (xk [0], xk [1], "" ;, Form1-> ColorBox1-> Selected); -> Series1-> AddXY (xk1 [0], xk1 [1], "", Form1-> ColorBox1-> Selected); (fabs (f (xk)-f (xk1))
}
}
x)
{(x [0] + x [1] -2.0);
} g2 (vector x)
{(-x [0] + x [1] -1.0);
} g3 (vector x)
{(-x [1] -3.0);
}
x)
{(2.0 * (x [0] -3.0) * (x [0] -3.0) + (x [1] -2.0) * (x [1] -2.0));
}
x)
{(2.0 * (x [0] -3.0) * (x [0] -3.0) + (x [1] -2.0) * (x [1] -2.0) + * (x [0] + x [1] -2.0) * (x [0] + x [1] -2.0) + * (-x [0] + x [1] -1.0) * (-x [0] + x [1] - 1.0) + * (-x [1] -3.0) * (-x [1] -3.0));
} __fastcall TForm1 :: Button1Click (TObject * Sender)
{ x0;
x0.push_back (-3.75);
x0.push_back (-2.0); res = Descent (f, x0, 1e-3, 1e-2); -> Text = FloatToStrF (res [0], ffFixed, 10,2) ; -> Text = FloatToStrF (res [1], ffFixed, 10,2);
}
// --------------------------------------------- ------------------------------ __fastcall TForm1 :: Button2Click (TObject * Sender)
{e = 1e-2; prev;. push_back (-3.75);. push_back (-2.0); -> Series1-> Clear (); last; (int NumOfIt = 1;; NumOfIt + +)
{-> LabeledEdit6-> Text = IntToStr (NumOfIt); = Descent (rf, prev, 1e-3, e); (fabs (rf (prev)-rf (last))
{(g1 (last) <= 0) = 0.0; * = 12.0; (g2 (last) <= 0) = 0.0; * = 12.0; (g3 (last) <= 0) = 0.0 ; * = 12.0;
} = last;
} -> Text = FloatToStrF (last [0], ffFixed, 10,2); -> Text = FloatToStrF (last [1], ffFixed, 10,2);
}
// --------------------------------------------- ------------------------------ __fastcall TForm1 :: Button4Click (TObject * Sender)
{-> Series3-> AddXY (0.500, 1.500, "", Form1-> ColorBox1-> Selected); -> Series3-> AddXY (-4.000, -3.000, " ", Form1-> ColorBox1-> Selected); -> Series4-> AddXY (-4.000, -3.000," ", Form1-> ColorBox1-> Selected); -> Series4- > AddXY (5.000, -3.000, "", Form1-> ColorBox1-> Selected); -> Series5-> AddXY (5.000, -3.000, "", Form1-> ColorBox1- > Selected); -> Series5-> AddXY (0.502, 1.501, "", Form1-> ColorBox1-> Se...