unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    pgc1: TPageControl;
    ts1: TTabSheet;
    ts2: TTabSheet;
    ts3: TTabSheet;
    cht1: TChart;
    lnsrsSeries1: TLineSeries;
    edt1: TEdit;
    edt2: TEdit;
    lbl1: TLabel;
    lbl2: TLabel;
    btn1: TButton;
    edt3: TEdit;
    edt4: TEdit;
    edt5: TEdit;
    lbl3: TLabel;
    lbl4: TLabel;
    lbl5: TLabel;
    edt6: TEdit;
    edt7: TEdit;
    edt8: TEdit;
    edt9: TEdit;
    lbl6: TLabel;
    lbl7: TLabel;
    lbl8: TLabel;
    lbl9: TLabel;
    img1: TImage;
    btn2: TButton;
    btn3: TButton;
    Button1: TButton;
    Button2: TButton;
    procedure btn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  x1,x2,y,A,B,C:Extended;


implementation

{$R *.dfm}

Function fun(x,A,B,C: extended):extended;
 begin
  Result:=(-A*x-C)/B;
 end;


procedure TForm1.btn1Click(Sender: TObject);
begin
x1:=StrToFloat(edt1.Text);
x2:=StrToFloat(edt2.Text);
A:=StrToFloat(edt3.Text);
B:=StrToFloat(edt4.Text);
C:=StrToFloat(edt5.Text);
with cht1 do
 begin
      LeftAxis.Automatic:=False;
      LeftAxis.Minimum:=StrToFloat(edt8.Text);
      LeftAxis.Maximum:=StrToFloat(edt6.Text);
      BottomAxis.Automatic:=False;
      BottomAxis.Minimum:=StrToFloat(edt9.Text);
      BottomAxis.Maximum:=StrToFloat(edt7.Text);
      SeriesList[0].Clear;
      y:=fun(x1,A,B,C);
SeriesList[0].AddXY(x1,y);
      y:=fun(x2,A,B,C);
SeriesList[0].AddXY(x2,y);
   end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Edt1.Text:='1';   Edt2.Text:='3';    Edt3.Text:='1';    Edt4.Text:='3';
 Edt5.Text:='0';      Edt6.Text:='20';   Edt7.Text:='20';    Edt8.text:='-20';
 Edt9.Text:='-20'
end;

procedure TForm1.btn2Click(Sender: TObject);
var ymax, ymin, xmax, xmin, xo, yo,xImax, yImax:Integer;
    hx,hy:Extended;
begin
x1:=StrToFloat(edt1.Text);
x2:=StrToFloat(edt2.Text);
ymax:=Strtoint(edt7.text);
ymin:=StrToInt(edt9.text);
xmax:=StrToint(edt6.text);
xmin:=StrToInt(edt8.text);
A:=StrToFloat(edt3.Text);
B:=StrToFloat(edt4.Text);
C:=StrToFloat(edt5.Text);
  yo:=ymax div 2;
  xo:=xmax div 2;
  with Img1.Canvas do
  begin
    Pen.Color:=clBlack;
    Brush.Color:=clRed;
    xImax:=Img1.Width;
    yImax:=Img1.Height;
      MoveTo(xo,yo);
      LineTo(xo,yImax);
      MoveTo(xo,yo);
      LineTo(xImax,yo);
    hx:=(xmax-xmin)/xImax;
    hy:=(ymax-ymin)/yImax;

      Pen.Color:=clRed;
      y:=fun(x1,A,B,C);
      MoveTo(Round((xo+x1)/hx),Round((yo+y)/hy));
      y:=fun(x2,A,B,C);
      LineTo(Round((xo+x2)/hx),Round((yo+y)/hy));
  end;

 end;

 Function Expo(x:extended):extended;
    Begin
    Result:=exp(2*x);
    end;

procedure TForm1.Button2Click(Sender: TObject);
begin   with cht1 do
 begin
      LeftAxis.Automatic:=False;
      LeftAxis.Minimum:=StrToFloat(edt8.Text);
      LeftAxis.Maximum:=StrToFloat(edt6.Text);
      BottomAxis.Automatic:=False;
      BottomAxis.Minimum:=StrToFloat(edt9.Text);
      BottomAxis.Maximum:=StrToFloat(edt7.Text);
     SeriesList[0].Clear; end;
While x1<x2 do begin
y:=Expo(x1);
cht1.SeriesList[0].AddXY(x1,y);
x1:=x1+0.1;
end;
end;

end.













