unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart,Math;

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Image1: TImage;
    Button1: TButton;
    Button2: TButton;
    Chart1: TChart;
    Button3: TButton;
    Button4: TButton;
    Series1: TLineSeries;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Label12: TLabel;
    Edit11: TEdit;
    Label13: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  xn,xk,x,y,h,xomin,xomax,yomin,yomax:extended;
  m,i,delt:integer;

implementation

{$R *.dfm}

function f(x:extended):extended;
begin
  result:=(exp(x)+exp(-x))/2;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:='0,1';  Edit2.Text:='1'; Edit3.Text:='5'; Edit4.Text:='0';
Edit5.Text:='10'; Edit6.Text:='0'; Edit7.Text:='20';
Edit8.Text:='160'; Edit9.Text:='125'; Edit10.Text:='125';Edit11.Text:='160';
end;

procedure TForm1.Button1Click(Sender: TObject);
var a,b,c,d,xmax,ymax:integer;
r1,r2:integer;
begin
a:=StrToInt(Edit8.Text);
b:=StrToInt(Edit9.Text);
c:=StrToInt(Edit10.Text);
d:=StrToInt(Edit11.Text);
if ((a=b) and (c=d)) or ((a=c) and (b=d)) or
 ((b=c) and (a=d)) then

  with Image1.Canvas do begin
  Pen.Color:=clBlack;
  Brush.Color:=clGreen;
  xmax:=Image1.Width;
  ymax:=Image1.Height;
   r1:=xmax div 12;
   r2:=ymax div 3;

  Pen.Color:=clRed;
  Pen.Width:=2;
 if ((a=b) and (c=d)) then begin
 MoveTo(r1,r2);
 LineTo(r1+b,r2);
 MoveTo(r1+b,r2);
 LineTo(r1+b,r2+c);
 MoveTo(r1+b,r2+c);
 LineTo(r1,r2+c);
 MoveTo(r1,r2+c);
 LineTo(r1,r2)
 end
 else
 if ((a=c) and (b=d)) then begin
 MoveTo(r1,r2);
 LineTo(r1+a,r2);
 MoveTo(r1+a,r2);
 LineTo(r1+a,r2+b);
 MoveTo(r1+a,r2+b);
 LineTo(r1,r2+b);
 MoveTo(r1,r2+b);
 LineTo(r1,r2)
 end
 else
 if ((a=d) and (b=c)) then begin
 MoveTo(r1,r2);
 LineTo(r1+a,r2);
 MoveTo(r1+a,r2);
 LineTo(r1+a,r2+d);
 MoveTo(r1+a,r2+d);
 LineTo(r1,r2+d);
 MoveTo(r1,r2+d);
 LineTo(r1,r2)
     end; end
  else MessageDlg('Прямоугольник не существует',mtInformation,[mbOk],0);
end; 

procedure TForm1.Button2Click(Sender: TObject);
begin
{ClipBoard.Assign(Image1.Picture);             }
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
xn:=StrToFloat(Edit1.Text);
xk:=StrToFloat(Edit2.Text);
m:=StrToInt(Edit3.Text);
xomin:=StrToFloat(Edit4.Text);
xomax:=StrToInt(Edit5.Text);
yomin:=StrToFloat(Edit6.Text);
yomax:=StrToFloat(Edit7.Text);
  with chart1 do begin
    LeftAxis.Automatic:=False;
    LeftAxis.Minimum:=yomin;
    LeftAxis.Maximum:=yomax;
    BottomAxis.Automatic:=False;
    BottomAxis.Minimum:=xomin;
    BottomAxis.Maximum:=xomax;
    SeriesList[0].Clear;
    h:=(xk-xn)/(m);
    x:=xn;
    for i:=1 to m do begin
      y:=f(x);
      SeriesList[0].AddXY(x,y);
      x:=x+h;
      end;
    end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
Chart1.CopyToClipboardMetafile(True);
end;

end.
