unit calk; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, Grids; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Button10: TButton; Button11: TButton; Button12: TButton; Button13: TButton; Button14: TButton; Button15: TButton; Button16: TButton; Button17: TButton; Button18: TButton; Button19: TButton; Button2: TButton; Button20: TButton; Button21: TButton; Button22: TButton; Button23: TButton; Button24: TButton; Button25: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; Button8: TButton; Button9: TButton; CheckBox1: TCheckBox; Edit1: TEdit; Edit10: TEdit; Edit11: TEdit; Edit12: TEdit; Edit13: TEdit; Edit14: TEdit; Edit15: TEdit; Edit16: TEdit; Edit17: TEdit; Edit18: TEdit; Edit19: TEdit; Edit2: TEdit; Edit20: TEdit; Edit21: TEdit; Edit22: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; Edit8: TEdit; Edit9: TEdit; Label1: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label18: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; StringGrid1: TStringGrid; procedure Button10Click(Sender: TObject); procedure Button11Click(Sender: TObject); procedure Button12Click(Sender: TObject); procedure Button13Click(Sender: TObject); procedure Button14Click(Sender: TObject); procedure Button15Click(Sender: TObject); procedure Button16Click(Sender: TObject); procedure Button17Click(Sender: TObject); procedure Button18Click(Sender: TObject); procedure Button19Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button20Click(Sender: TObject); procedure Button21Click(Sender: TObject); procedure Button22Click(Sender: TObject); procedure Button23Click(Sender: TObject); procedure Button24Click(Sender: TObject); procedure Button25Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Edit14Change(Sender: TObject); procedure Edit14KeyPress(Sender: TObject; var Key: char); procedure Edit18Change(Sender: TObject); procedure Edit18KeyPress(Sender: TObject; var Key: char); procedure Edit1Change(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: char); procedure Edit2Change(Sender: TObject); procedure Edit2KeyPress(Sender: TObject; var Key: char); procedure Edit3Change(Sender: TObject); procedure Edit3KeyPress(Sender: TObject; var Key: char); procedure Edit4Change(Sender: TObject); procedure Edit4KeyPress(Sender: TObject; var Key: char); procedure FormCreate(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation function figure(n: string): byte; //количество значащих цифр в числе n type DigitChar = set of '0'..'9'; var digit: DigitChar; extent: byte; //длина подстроки без порядка b: boolean; //b=true - первая значащая цифра достигнута i: byte; begin digit:=['0','1','2','3','4','5','6','7','8','9']; figure:=0; b:=false; if pos('E',n)=0 then extent:=length(n) else extent:= pos('E',n)-1; for i:=1 to extent do begin if (n[i] in digit) and (n[i]<>'0') then b:=true; if (n[i] in digit) and (b=true) then figure:=figure+1; end; end; function output(n0: string): string; var n: string; p: integer; //порядок нормализованной формы v: string; // строка под порядок i: byte; m: string; //строка под значащие цифры k: byte; //длина строки m begin output:='' ; if n0 ='' then exit; if n0[1]='-' then output:=output+'-'; n:=n0; if n0[1]='-' then delete(n,1,1); if StrToFloat(n0)= 0 then begin output:='0'; exit end; m:=''; v:=''; if pos(',',n0)>0 then m:=m+n0[pos(',',n0)-1]; for i:=pos(',',n0)+1 to pos('E',n0)-1 do m:=m+n0[i]; for i:=pos('E',n0)+1 to length(n0) do v:=v+n0[i]; k:=length(m); p:=StrToInt(v); if p=0 then output:=output+copy(n,1,pos('E',n)-1); if (p<0) and (p>=-15) then begin output:=output+'0'+','; for i:=1 to -p-1 do output:=output+'0'; output:=output+m; end; if (p>0) and (p<=15) then begin if p=k-1 then output:=output+m; if pk-1 then begin output:=output+m; output:=output+'E'; output:=output+IntToStr(p-k+1); end; end; if (p>15) or (p<-15) then output:=n0; end; function error(n: string): real;//абсолютная погрешность числа var k: byte; //количество значащих цифр n0: string; //число в научной форме p: integer; //порядок w: string; //строка под порядок i: byte; begin k:=figure(n); n0:=FloatToStrf(StrToFloat(n), ffExponent, k, 4); w:=''; for i:=pos('E',n0)+1 to length(n0) do w:=w+n0[i]; p:=StrToInt(w); error:=0.5; if p-k+1>0 then for i:=1 to p-k+1 do error:=error*10; if k-1-p>0 then for i:=1 to k-1-p do error:=error/10; if k=0 then error:=0; end; function roundoff(n:string; err:real): string;//округление var n0: string; //строка в формате с плавающей точкой p: integer; //порядок v: string; //строка под порядок k: byte; //количество значащих цифр в неокруглённом числе i: byte; j: integer; r: byte; //количество значащих цифр в округлённом числе g: real; //значение значащей цифры f: char; //первая отбрасываемая цифра q: char; //последняя неотбрасываемая цифра a: string; //строка под все значащие цифры неокруглённого числа z: string; //часть строки a b: string; //строка под все значащие цифры округлённого числа c: boolean; // c=true - последний разряд увеличивается на единицу begin roundoff:=''; if StrToFloat(n)= 0 then begin roundoff:='0'; exit; end; k:=figure(n); n0:=FloatToStrf(StrToFloat(n), ffExponent, k, 3); v:=''; for i:=pos('E',n0)+1 to length(n0) do v:=v+n0[i]; p:=StrToInt(v); g:=1; if p>0 then for j:=1 to p do g:=g*10; if p<0 then for j:=1 to -p do g:=g/10; r:=0; while (g/2 >= err ) and (r<15) do begin r:=r+1; g:=g/10; end; a:=n0[pos(',',n0)-1]; for i:=pos(',',n0)+1 to pos('E',n0)-1 do a:=a+n0[i]; if r=0 then begin roundoff:='0'; exit; end; z:=copy(a,1,r); c:=false; q:=z[r]; if length(a)>length(z) then f:=a[r+1] else f:='e'; if (f='6') or (f='7') or (f='8') or (f='9') then c:=true; if (f='5') then begin for i:= r+2 to length(a) do if StrToInt(a[i])>0 then c:=true; if (not c) and (odd(StrToInt(q))) then c:=true; end; if c then b:=FloatToStr(StrToFloat(z)+1) else b:=z; if length(b)>length(z) then p:=p+1; v:=IntToStr(p); if n0[1]='-' then roundoff:=roundoff+'-'; roundoff:=roundoff+b[1]; delete(b,1,1); if length(b)>0 then roundoff:=roundoff+','; roundoff:=roundoff+ b+'E'+v; end; procedure showing; //показать промежуточные результаты begin Form1.Edit10.Visible:=true; Form1.Label10.Visible:=true; Form1.Edit11.Visible:=true; Form1.Label11.Visible:=true; if Form1.Edit12.Text<>'' then begin Form1.Edit12.Visible:=true; Form1.Label12.Visible:=true; end; if Form1.Edit13.Text <>'' then begin Form1.Edit13.Visible:=true; Form1.Label13.Visible:=true; end; if Form1.Edit15.Text <>'' then begin Form1.Edit15.Visible:=true; Form1.Label14.Visible:=true; end; end; procedure result; //относительная погрешность var x: real; dx: real; y:real; dy: real; z: real; dz: real; begin x:=0; dx:=0; y:=0; dy:=0; z:=0; dz:=0; if (Form1.Edit1.Text<>'') then x:=StrToFloat(Form1.Edit1.Text); if (Form1.Edit3.Text<>'') then dx:=StrToFloat(Form1.Edit3.Text); if (Form1.Edit2.Text<>'') then y:=StrToFloat(Form1.Edit2.Text); if (Form1.Edit4.Text<>'') then dy:=StrToFloat(Form1.Edit4.Text); z:=StrToFloat(Form1.Edit7.Text); dz:=StrToFloat(Form1.Edit8.Text); Form1.Edit7.Visible:=true; Form1.Label7.Visible:=true; if Form1.CheckBox1.Checked then showing; if (x<>0) and (dx0) and (dy0) and (dz'' then begin Form1.Edit5.Visible:=true; Form1.Label6.Visible:=true; end; if Form1.Edit6.Text <>'' then begin Form1.Edit6.Visible:=true; Form1.Label6.Visible:=true; end; if Form1.Edit8.Text <>'' then begin Form1.Edit8.Visible:=true; Form1.Label8.Visible:=true; end; if Form1.Edit9.Text <>'' then begin Form1.Edit9.Visible:=true; Form1.Label9.Visible:=true; end; if Form1.Edit20.Text <>'' then begin Form1.Edit20.Visible:=true; Form1.Label18.Visible:=true; end; if Form1.Edit5.Text='0,00000000000000E+000' then Form1.Edit5.Text:='0'; if Form1.Edit6.Text='0,00000000000000E+000' then Form1.Edit6.Text:='0'; if Form1.Edit8.Text='0,00000000000000E+000' then Form1.Edit8.Text:='0'; if Form1.Edit9.Text='0,00000000000000E+000' then Form1.Edit9.Text:='0'; if Form1.Edit11.Text='0,00000000000000E+000' then Form1.Edit11.Text:='0'; if Form1.Edit12.Text='0,00000000000000E+000' then Form1.Edit12.Text:='0'; if Form1.Edit13.Text='0,00000000000000E+000' then Form1.Edit13.Text:='0'; if Form1.Edit15.Text='0,00000000000000E+000' then Form1.Edit15.Text:='0'; end; function remarcsin(n: integer): real; //погрешность метода вычисления arcsin(1) const //0.257/0.48/exp(0.48*ln(n)) mist = 1E-14/9; //минимальная относительная погрешность чисел типа real var x: real; //аргумент функции k: integer; // номер членa ряда Тейлора, k>=0 c: real; // с=с(k, x)- член ряда в точке x z: real; // значение частичной суммы ряда cont: boolean;//условие завершения вычисления функции begin x:=(n-1)/(n+1); k:=1; c:=2*x; z:=0; cont:=false; repeat z:=z+c; c:=c*x*x*(2*k-1)/(2*k+1); k:=k+1; if abs(c)<=mist*abs(z) then cont:=true; until cont; x:=0.48*z; k:=0; c:=1; z:=0; cont:=false; repeat z:=z+c; c:=c*x/(k+1); k:=k+1; if abs(c)<=mist*abs(z) then cont:=true; until cont; remarcsin:=0.257/0.48/z; end; function series(x: real; dx: real; o: string): real; const //функция от аргумента x, заданного с погрешностью dx mist = 1E-14/9; //минимальная относительная погрешность чисел типа real max = 9999; //максимальное количество слагаемых в ряду var k: integer; // номер членa ряда Тейлора, k>=0 xt: real; // x+dx, если x>0; x-dx, если x<0; c: real; // с=с(k, x)- член ряда в точке x ct: real; // сt=сt(k, xd) - член ряда в точке xt z: real; // значение частичной суммы ряда dc: real; // dc=dc(k, x)=abs(с(k, xt)-c(k, x))- погрешность члена ряда dz: real; // dz=dz(k, x)=abs(z(k, xt)-z(k, x))- погрешность действий dr: real; // значение остатка ряда Тейора u: string; // нормализованная форма неокруглённой суммы z w: string; // нормализованная форма округлённой суммы z d0: real; // погрешность округления cont: boolean;//условие завершения вычисления функции t, dt: real; //аргумент и погрешность аргумента для ряда логарифма l: integer; begin if (o='log') then begin t:=(x-1)/(x+1); dt:=2*dx/(x+1)/(x+1); x:=t; dx:=dt; end; if (o='sin') or (o='log') then k:=1; if (o='cos') or (o='exp') or (o='arc') then k:=0; if x>0 then xt:=x+dx; if x<0 then xt:=x-dx; if (o='sin') or (o='arc') then c:=x; if (o='cos') or (o='exp') then c:=1; if (o='log') then c:=2*x; if (o='sin') or (o='arc') then ct:=xt; if (o='cos') or (o='exp') then ct:=1; if (o='log') then ct:=2*xt; if (o='sin') or (o='log') or (o='arc') then dc:=dx; if (o='cos') or (o='exp') then dc:=0; z:=0; dz:=0; d0:=error(FloatToStrF(abs(c), ffExponent, 15, 3)); if Form1.CheckBox1.Checked then Form1.StringGrid1.Visible:=true; cont:=false; repeat z:=z+c; dz:=dz+dc; l:=k+1; Form1.StringGrid1.RowCount:=l+1;; Form1.StringGrid1.Cells[0,l]:=IntToStr(k); if c>=0 then Form1.StringGrid1.Cells[1,l]:=' '+output(FloatToStrF(c,ffExponent,15,3)) else Form1.StringGrid1.Cells[1,l]:=output(FloatToStrF(c,ffExponent,15,3)); if dc<>0 then Form1.StringGrid1.Cells[2,l]:=FloatToStrF(dc, ffExponent, 15, 3 ) else Form1.StringGrid1.Cells[2,l]:=FloatToStr(dc); if z>=0 then Form1.StringGrid1.Cells[3,l]:=' '+output(FloatToStrF(z,ffExponent,15,3)) else Form1.StringGrid1.Cells[3,l]:=output(FloatToStrF(z,ffExponent,15,3)); if dz<>0 then Form1.StringGrid1.Cells[4,l]:=FloatToStrF(dz, ffExponent, 15, 3 ) else Form1.StringGrid1.Cells[4,l]:=FloatToStr(dz); if o='sin' then c:=-c*x*x/(2*k)/(2*k+1); if o='cos' then c:=-c*x*x/(2*k+1)/(2*k+2); if o='exp' then c:=c*x/(k+1); if o='log' then c:=c*x*x*(2*k-1)/(2*k+1); if o='arc' then c:=c*x*x*(2*k+1)/(2*k+2)*(2*k+1)/(2*k+3); if error(FloatToStrF(abs(c), ffExponent, 15, 3))>d0 then d0:=error(FloatToStrF(abs(c), ffExponent, 15, 3)); if o='sin' then ct:=-ct*xt*xt/(2*k)/(2*k+1); if o='cos' then ct:=-ct*xt*xt/(2*k+1)/(2*k+2); if o='exp' then ct:=ct*xt/(k+1); if o='log' then ct:=ct*xt*xt*(2*k-1)/(2*k+1); if o='arc' then ct:=ct*xt*xt*(2*k+1)/(2*k+2)*(2*k+1)/(2*k+3); dc:=abs(ct-c); if (o='sin') and ((abs(c)<=dc) or (abs(c)<=mist*abs(z))) and (k>abs(x)/2) then cont:=true; if (o='cos') and ((abs(c)<=dc) or (abs(c)<=mist*abs(z))) and (k>abs(x)/2) then cont:=true; if (o='exp') and ((abs(c)<=dc) or (abs(c)<=mist*abs(z))) and (k>abs(x)) then cont:=true; if (o='log') and ((abs(c)<=dc) or (abs(c)<=mist*abs(z)) or (k>=max)) then cont:=true; if (o='arc') and (abs(x)<1) and ((abs(c)<=dc) or (abs(c)<=mist*abs(z)) or (k>=max)) then cont:=true; if (o='arc') and (abs(x)=1) and ((abs(c)<=dc) or (abs(c)<=mist*abs(z)) or (k>=max)) and (k>=72) then cont:=true; k:=k+1; until cont; if (o='sin') and (k>abs(x)/2) then dr:=abs(c); if (o='cos') and (k>abs(x)/2) then dr:=abs(c); if (o='exp') and (x<=0) and (k>abs(x)) then dr:=abs(c); if (o='exp') and (x>0) and (k>x) then dr:=c*k/(k-x); if (o='log') then dr:=abs(c)/(1-x*x); if (o='arc') and (abs(x)<1) then dr:=abs(c)/(1-x*x); if (o='arc') and (abs(x)=1) then dr:=remarcsin(k); u:=FloatToStrF(z, ffExponent, 15, 3); w:=roundoff(u, dz+dr+d0); d0:=abs(StrToFloat(w)-z); if d06) and (e2<>6) then ShowMessage(m3); end; { TForm1 } procedure TForm1.Button1Click(Sender: TObject); //сложение var x: real; //основание dx: real; //погрешность основания y: real; //показатель dy: real; //погрешность показателя begin clearing; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; if Edit2.Text='' then begin Edit2.SetFocus; exit; end; if Edit4.Text='' then Edit4.Text:=inputerr(Edit2.Text); if Edit4.Text='' then begin Edit4.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); y:=StrToFloat(Edit2.Text); dy:=StrToFloat(Edit4.Text); binar(x, y, dx, dy, '+'); Label3.Caption:=' x+y ='; result; end; procedure TForm1.Button2Click(Sender: TObject); //вычитание var x: real; //основание dx: real; //погрешность основания y: real; //показатель dy: real; //погрешность показателя begin clearing; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; if Edit2.Text='' then begin Edit2.SetFocus; exit; end; if Edit4.Text='' then Edit4.Text:=inputerr(Edit2.Text); if Edit4.Text='' then begin Edit4.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); y:=StrToFloat(Edit2.Text); dy:=StrToFloat(Edit4.Text); y:=-y; binar(x, y, dx, dy, '+'); Label3.Caption:=' x-y ='; result; end; procedure TForm1.Button3Click(Sender: TObject); //умножение var x: real; //основание dx: real; //погрешность основания y: real; //показатель dy: real; //погрешность показателя begin clearing; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; if Edit2.Text='' then begin Edit2.SetFocus; exit; end; if Edit4.Text='' then Edit4.Text:=inputerr(Edit2.Text); if Edit4.Text='' then begin Edit4.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); y:=StrToFloat(Edit2.Text); dy:=StrToFloat(Edit4.Text); binar(x, y, dx, dy, '*'); Label3.Caption:=' x*y ='; result; end; procedure TForm1.Button4Click(Sender: TObject); //деление var x: real; //основание dx: real; //погрешность основания y: real; //показатель dy: real; //погрешность показателя begin clearing; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; if Edit2.Text='' then begin Edit2.SetFocus; exit; end; if Edit4.Text='' then Edit4.Text:=inputerr(Edit2.Text); if Edit4.Text='' then begin Edit4.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); y:=StrToFloat(Edit2.Text); dy:=StrToFloat(Edit4.Text); if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit2.Text='' then begin Edit2.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; if Edit4.Text='' then Edit4.Text:=inputerr(Edit2.Text); if Edit4.Text='' then begin Edit4.SetFocus; exit; end; if y=0 then begin showmessage('На нуль делить нельзя '); Form1.Edit2.Text:=''; Form1.Edit2.SetFocus; exit; end; binar(x, y, dx, dy, '/'); Label3.Caption:=' x/y ='; result; end; procedure TForm1.Button5Click(Sender: TObject); begin Edit19.Text:=Edit12.Text; Edit1.Text:=Edit10.Text; Edit3.Text:=Edit19.Text; Edit2.Text:=''; Edit4.Text:=''; Edit2.SetFocus; end; procedure TForm1.Button6Click(Sender: TObject); //синус var x: real; //значение аргумента dx: real; // погрешность аргумента dz: real; // погрешность синуса, вычисляемая по формуле dz=cos(x)*dx begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); dz:=abs(series(x, 0, 'cos'))*dx; clearing; Edit13.Text:=FloatToStrF(dz, ffExponent, 15, 3); series(x, dx, 'sin'); Label3.Caption:=' Sin(x) ='; result; end; procedure TForm1.Button7Click(Sender: TObject); //косинус var x: real; //значение аргумента dx: real; // погрешность аргумента dz: real; // погрешность косинуса, вычисляемая по формуле dz=sin(x)*dx begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); dz:=abs(series(x, 0, 'sin'))*dx; clearing; Edit13.Text:=FloatToStrF(dz, ffExponent, 15, 3); series(x, dx, 'cos'); Label3.Caption:=' Cos(x) ='; result; end; procedure TForm1.Button8Click(Sender: TObject); //тангенс var x: real; //значение аргумента dx: real; // погрешность аргумента dz: real; //погрешность функции тангенс по формуле 1/(cos(x))^2 *dx begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); if series(x, 0, 'cos')=0 then begin showmessage('функция tg(x) не опредosелена '); Form1.Edit1.Text:=''; Form1.Edit1.SetFocus; exit; end; dz:=dx/series(x, 0, 'cos')/series(x, 0, 'cos'); clearing; Edit13.Text:=FloatToStr(dz); tangens(x, dx, 'tg'); Label3.Caption:=' Tg(x) ='; result; StringGrid1.Visible:=false; end; procedure TForm1.Button9Click(Sender: TObject); //котангенс var x: real; //значение аргумента dx: real; // погрешность аргумента dz: real; //погрешность функции котангенс по формуле 1/(sin(x))^2 *dx begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); if series(x, 0, 'sin')=0 then begin showmessage('функция ctg(x) не определена '); Form1.Edit1.Text:=''; Form1.Edit1.SetFocus; exit; end; dz:=dx/series(x, 0, 'sin')/series(x, 0, 'sin'); clearing; Edit13.Text:=FloatToStr(dz); tangens(x, dx, 'ctg'); Label3.Caption:=' Ctg(x) ='; result; StringGrid1.Visible:=false; end; procedure TForm1.Button10Click(Sender: TObject); //экспонента var x: real; //значение аргумента dx: real; // погрешность аргумента dz: real; // погрешность экспоненты, вычисляемая по формуле dz=exp(x)*dx begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); if dx>abs(x) then begin showmessage('Недопустимо высокая погрешность аргумента'); Edit3.Text:=''; Edit3.SetFocus; Exit; end; dz:=series(x, 0, 'exp')*dx; clearing; Edit13.Text:=FloatToStrF(dz, ffExponent, 15, 3); series(x, dx, 'exp'); Label3.Caption:=' Exp(x) ='; result; end; procedure TForm1.Button11Click(Sender: TObject); //арксинус var x: real; //значение аргумента dx: real; //погрешность аргумента dz: real; //погрешность арксинуса, вычисляемая по формуле dz=dx/sqrt(1-x*x) begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); if abs(x)>1 then begin showmessage('функция Arcsin(x) не определена '); Edit1.Text:=''; Edit1.SetFocus; exit; end; if dx>0.5 then begin showmessage('Недопустимо высокая погрешность аргумента'); Edit3.Text:=''; Edit3.SetFocus; Exit; end; if x<1 then begin dz:=dx/sqrt(1-x*x); Edit13.Text:=FloatToStrF(dz, ffExponent, 15, 3); end else Edit13.Text:='бесконечность'; series(x, dx, 'arc'); Label3.Caption:=' arcsin(x) ='; result; end; procedure TForm1.Button12Click(Sender: TObject); //арккосинус var x: real; //значение аргумента dx: real; //погрешность аргумента z: real; //значение функции dz: real;//погрешность арккосинуса, вычисляемая по формуле dz=dx/sqrt(1-x*x) d0: real; //погрешность метода + погрешность действий для арксинуса u: string; //неокруглённое значение арккосинуса w: string; //округлённое значение арккосинуса i: integer; begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); if abs(x)>1 then begin showmessage('функция Arccos(x) не определена '); Edit1.Text:=''; Edit1.SetFocus; exit; end; if dx>0.5 then begin showmessage('Недопустимо высокая погрешность аргумента'); Edit3.Text:=''; Edit3.SetFocus; Exit; end; if x<1 then begin dz:=dx/sqrt(1-x*x); Edit13.Text:=FloatToStr(dz); end else Edit13.Text:='бесконечность'; z:=Pi/2-series(x, dx, 'arc'); d0:=StrToFloat(Edit12.Text)+StrToFloat(Edit15.Text); u:=FloatToStrF(z, ffExponent, 15, 3); Edit10.Text:=output(u); w:=roundoff(u, d0); Edit7.Text:=output(w); for i:=1 to Form1.StringGrid1.RowCount-1 do Form1.StringGrid1.Rows[i].Clear; Label3.Caption:=' arccos(x) ='; result; StringGrid1.Visible:=false; end; procedure TForm1.Button13Click(Sender: TObject); //арктангенс var x: real; //значение аргумента dx: real; //погрешность аргумента dz: real;//погрешность арктангенса, вычисляемая по формуле dz=dx/(1+x*x) i: integer; begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); series(x/degree(1+x*x,1/2,0,0), dx/degree(1+x*x,3/2,0,0), 'arc'); dz:=dx/(1+x*x); Edit13.Text:=FloatToStr(dz); for i:=1 to Form1.StringGrid1.RowCount-1 do Form1.StringGrid1.Rows[i].Clear; Label3.Caption:='Arctg(x) ='; result; StringGrid1.Visible:=false; end; procedure TForm1.Button14Click(Sender: TObject); //арккотангенс var x: real; //значение аргумента dx: real; //погрешность аргумента z: real; //значение арккотангенса dz: real;//погрешность арккотангенса, вычисляемая по формуле dz=dx/(1+x*x) d0: real; //погрешность метода + погрешность действий для арктангенса u: string; //неокруглённое значение арккотангенса w: string; //округлённое значение арккотангенса i: integer; begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); z:=Pi/2-series(x/degree(1+x*x,1/2,0,0), dx/degree(1+x*x,3/2,0,0), 'arc'); dz:=dx/(1+x*x); Edit13.Text:=FloatToStr(dz); d0:=StrToFloat(Edit12.Text)+StrToFloat(Edit15.Text); u:=FloatToStrF(z, ffExponent, 15, 3); Edit10.Text:=output(u); w:=roundoff(u, d0); Edit7.Text:=output(w); for i:=1 to Form1.StringGrid1.RowCount-1 do Form1.StringGrid1.Rows[i].Clear; Label3.Caption:=' Arcctg(x) ='; result; StringGrid1.Visible:=false; end; procedure TForm1.Button15Click(Sender: TObject); //логарифм var x: real; //значение аргумента dx: real; //погрешность аргумента dz: real; //погрешность экспоненты, вычисляемая по формуле dz=1/x*dx begin clearing; clearingbin; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); if x<=0 then begin showmessage('функция Ln(x) не определена '); Edit1.Text:=''; Edit1.SetFocus; exit; end; if dx>x then begin showmessage('Недопустимо высокая погрешность аргумента'); Edit3.Text:=''; Edit3.SetFocus; Exit; end; dz:=dx/x; Edit13.Text:=FloatToStrF(dz, ffExponent, 15, 3); series(x, dx, 'log'); Label3.Caption:=' Ln(x) ='; result; end; procedure TForm1.Button16Click(Sender: TObject); //x^y var x: real; //основание dx: real; //погрешность основания y: real; //показатель dy: real; //погрешность показателя i: integer; begin clearing; if Edit1.Text='' then begin Edit1.SetFocus; exit; end; if Edit3.Text='' then Edit3.Text:=inputerr(Edit1.Text); if Edit3.Text='' then begin Edit3.SetFocus; exit; end; if Edit2.Text='' then begin Edit2.SetFocus; exit; end; if Edit4.Text='' then Edit4.Text:=inputerr(Edit2.Text); if Edit4.Text='' then begin Edit4.SetFocus; exit; end; x:=StrToFloat(Edit1.Text); dx:=StrToFloat(Edit3.Text); y:=StrToFloat(Edit2.Text); dy:=StrToFloat(Edit4.Text); if (x=0) and (y>0) then begin Form1.Edit7.Text:='0'; Form1.Edit8.Text:='0'; Form1.Edit10.Text:='0'; Form1.Edit11.Text:='0'; Form1.Edit13.Text:='0'; result; Label14.Visible:=false; Edit15.Visible:=false; Label12.Visible:=false; Edit12.Visible:=false; exit; end; if ((x<0) and ((Frac(y)<>0) or (dy>0))) or ((x=0) and (y<=0)) then begin showmessage('функция x^y не определена '); Form1.Edit1.Text:=''; Form1.Edit1.SetFocus; exit; end; if (Frac(y)<>0) or (dy>0) then degree(x, y, dx, dy); if (Frac(y)= 0) and (dy=0) then degreemult(x, y, dx); for i:=1 to Form1.StringGrid1.RowCount-1 do Form1.StringGrid1.Rows[i].Clear; Label3.Caption:=' x^y ='; result; StringGrid1.Visible:=false; end; procedure TForm1.Button17Click(Sender: TObject); var x: extended; dx: extended; begin clearing; if Edit14.Text='' then Edit14.Text:='1'; if Edit18.Text='' then Edit18.Text:='1'; x:=Pi*StrToFloat(Edit18.Text)/StrToFloat(Edit14.text); Edit1.Text:=output(FloatToStrF(x, ffExponent, 15, 3)); dx:=error(Edit1.Text); Edit3.Text:=FloatToStr(dx); end; procedure TForm1.Button18Click(Sender: TObject); begin Edit16.Text:=Edit7.Text; Edit17.Text:=Edit8.Text; end; procedure TForm1.Button19Click(Sender: TObject); begin Edit21.Text:=Edit7.Text; Edit22.Text:=Edit8.Text; end; procedure TForm1.Button20Click(Sender: TObject); begin Edit21.Text:=Edit10.Text; Edit22.Text:=Edit12.Text; end; procedure TForm1.Button21Click(Sender: TObject); begin clearing; Edit1.Text:=''; Edit2.Text:=''; Edit3.Text:=''; Edit4.Text:=''; Edit1.SetFocus; end; procedure TForm1.Button22Click(Sender: TObject); begin Edit19.Text:=Edit8.Text; Edit1.Text:=Edit7.Text; Edit3.Text:=Edit19.Text; Edit2.Text:=''; Edit4.Text:=''; Edit2.SetFocus; end; procedure TForm1.Button23Click(Sender: TObject); begin Edit16.Text:=Edit10.Text; Edit17.Text:=Edit12.Text; end; procedure TForm1.Button24Click(Sender: TObject); begin Edit1.Text:=Edit16.Text; Edit3.Text:=Edit17.Text; end; procedure TForm1.Button25Click(Sender: TObject); begin Edit2.Text:=Edit21.Text; Edit4.Text:=Edit22.Text; end; procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char); type DigitChar = set of '0'..'9'; var digit: DigitChar; b: boolean; k1: byte; i: byte; h: string; begin h:=Edit1.Text; b:=false; k1:=0; digit:=['0','1','2','3','4','5','6','7','8','9']; for i:=1 to length(h) do begin if (h[i] in digit) and (h[i]<>'0') then b:=true; if (h[i] in digit) and (b=true) then k1:=k1+1; end; case Key of '0'..'9': if (((k1>=15) and (pos('E',h)=0)) or ((length(h)>=pos('E',h)+5))and (pos('E',h)>0)) then Key :=Chr(0); #8: ; ',': if (pos(',',h)<>0) and (pos('E',h)= 0) then Key :=Chr(0); 'E': if pos('E',h)<>0 then Key :=Chr(0); '-': if length(h) <> pos('E',h) then Key :=Chr(0); else Key :=Chr(0); end; end; procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: char); type DigitChar = set of '0'..'9'; var digit: DigitChar; b: boolean; k1: byte; i: byte; h: string; begin h:=Edit2.Text; b:=false; k1:=0; digit:=['0','1','2','3','4','5','6','7','8','9']; for i:=1 to length(h) do begin if (h[i] in digit) and (h[i]<>'0') then b:=true; if (h[i] in digit) and (b=true) then k1:=k1+1; end; case Key of '0'..'9': if (((k1>=15) and (pos('E',h)=0)) or ((length(h)>=pos('E',h)+5))and (pos('E',h)>0)) then Key :=Chr(0); #8: ; ',': if (pos(',',h)<>0) and (pos('E',h)= 0) then Key :=Chr(0); 'E': if pos('E',h)<>0 then Key :=Chr(0); '-': if length(h) <> pos('E',h) then Key :=Chr(0); else Key :=Chr(0); end; end; procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: char); type DigitChar = set of '0'..'9'; var digit: DigitChar; b: boolean; k1: byte; i: byte; h: string; begin h:=Edit3.Text; b:=false; k1:=0; digit:=['0','1','2','3','4','5','6','7','8','9']; for i:=1 to length(h) do begin if (h[i] in digit) and (h[i]<>'0') then b:=true; if (h[i] in digit) and (b=true) then k1:=k1+1; end; case Key of '0'..'9': if (((k1>=15) and (pos('E',h)=0)) or ((length(h)>=pos('E',h)+5))and (pos('E',h)>0)) then Key :=Chr(0); #8: ; ',': if (pos(',',h)<>0) and (pos('E',h)= 0) then Key :=Chr(0); 'E': if pos('E',h)<>0 then Key :=Chr(0); '-': if (length(h) <> pos('E',h)) or (pos('E',h)= 0) then Key :=Chr(0); else Key :=Chr(0); end; end; procedure TForm1.Edit4KeyPress(Sender: TObject; var Key: char); type DigitChar = set of '0'..'9'; var digit: DigitChar; b: boolean; k1: byte; i: byte; h: string; begin h:=Edit4.Text; b:=false; k1:=0; digit:=['0','1','2','3','4','5','6','7','8','9']; for i:=1 to length(h) do begin if (h[i] in digit) and (h[i]<>'0') then b:=true; if (h[i] in digit) and (b=true) then k1:=k1+1; end; case Key of '0'..'9': if (((k1>=15) and (pos('E',h)=0)) or ((length(h)>=pos('E',h)+5))and (pos('E',h)>0)) then Key :=Chr(0); #8: ; ',': if (pos(',',h)<>0) and (pos('E',h)= 0) then Key :=Chr(0); 'E': if pos('E',h)<>0 then Key :=Chr(0); '-': if (length(h) <> pos('E',h)) or (pos('E',h)= 0) then Key :=Chr(0); else Key :=Chr(0); end; end; procedure TForm1.Edit14KeyPress(Sender: TObject; var Key: char); type DigitChar = set of '0'..'9'; var digit: DigitChar; b: boolean; k1: byte; i: byte; h: string; begin h:=Edit14.Text; b:=false; k1:=0; digit:=['0','1','2','3','4','5','6','7','8','9']; for i:=1 to length(h) do begin if (h[i] in digit) and (h[i]<>'0') then b:=true; if (h[i] in digit) and (b=true) then k1:=k1+1; end; case Key of '0'..'9': if (((k1>=3) and (pos('E',h)=0)) or ((length(h)>=pos('E',h)+5))and (pos('E',h)>0)) then Key :=Chr(0); #8: ; ',': if (pos(',',h)<>0) and (pos('E',h)= 0) then Key :=Chr(0); 'E': if pos('E',h)<>0 then Key :=Chr(0); '-': if (length(h) <> pos('E',h)) or (pos('E',h)= 0) then Key :=Chr(0); else Key :=Chr(0); end; end; procedure TForm1.Edit18KeyPress(Sender: TObject; var Key: char); type DigitChar = set of '0'..'9'; var digit: DigitChar; b: boolean; k1: byte; i: byte; h: string; begin h:=Edit18.Text; b:=false; k1:=0; digit:=['0','1','2','3','4','5','6','7','8','9']; for i:=1 to length(h) do begin if (h[i] in digit) and (h[i]<>'0') then b:=true; if (h[i] in digit) and (b=true) then k1:=k1+1; end; case Key of '0'..'9': if (((k1>=3) and (pos('E',h)=0)) or ((length(h)>=pos('E',h)+5))and (pos('E',h)>0)) then Key :=Chr(0); #8: ; ',': if (pos(',',h)<>0) and (pos('E',h)= 0) then Key :=Chr(0); 'E': if pos('E',h)<>0 then Key :=Chr(0); '-': if (length(h) <> pos('E',h)) or (pos('E',h)= 0) then Key :=Chr(0); else Key :=Chr(0); end; end; procedure TForm1.FormCreate(Sender: TObject); begin clearing; end; procedure TForm1.Edit1Change(Sender: TObject); begin clearing; end; procedure TForm1.Edit2Change(Sender: TObject); begin clearing; end; procedure TForm1.Edit3Change(Sender: TObject); begin clearing; end; procedure TForm1.Edit4Change(Sender: TObject); begin clearing; end; procedure TForm1.Edit14Change(Sender: TObject); begin clearing; end; procedure TForm1.Edit18Change(Sender: TObject); begin clearing; end; initialization {$I calk.lrs} end.