• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Delphi数学运算函数_Delphi

Delphi 搞代码 3年前 (2018-08-09) 139次浏览 已收录 0个评论

作者:lyboy99
e-mail:[email protected]   
url: http://hnh.126.com
给大家提供几个常用函数,希望可以对你有帮助.
用下面的函数可以轻松,设计个强大的科学计算机器.

function rnd(arg1:double):double;
Begin
    result := Random * int(arg1);
end;

http://www.gaodaima.com/65715.htmlDelphi数学运算函数_Delphi

function arcsinh(arg1:double):double;
begin
       result:=Ln(arg1+sqrt(1+power(arg1,2)));
end;

function arccosh(arg1:double):double;
begin
       result :=Ln(arg1+sqrt(power(arg1,2)-1));
end;

function arctanh(arg1:double):double;
begin
       result :=Ln((1+arg1)/(1-arg1))/2;
end;

function arcsech(arg1:double):double;
begin
       result :=Ln((1/arg1)+sqrt(power((1/arg1),2)-1));
end;

function arccosech(arg1:double):double;
begin
       result :=Ln((1/arg1)+sqrt(1+power((1/arg1),2)));
end;

function arccoth(arg1:double):double;
begin
       result :=Ln((1+(1/arg1))/(1-(1/arg1)))/2;
end;

function degarcsin(arg1:double):double;
begin
       result :=arcsin(DegToRad(arg1));
end;

function arcsec(arg1:double):double;
begin
    result  := arccos(1/arg1);
end;

function degarcsec(arg1:double):double;
begin
    result := RadToDeg(arccos(1/arg1));
end;

function arccosec(arg1:double):double;
begin
    result  := arcsin(1/arg1);
end;

function degarccosec(arg1:double):double;
begin
    result  := RadToDeg(arcsin(1/arg1));
end;

function degarccos(arg1:double):double;
begin
       result :=arccos(DegToRad(arg1));
end;

function arccot(arg1:double):double;
begin
    result  := arctan(1/arg1);
end;

function degarccot(arg1:double):double;
begin
    result  := RadToDeg(arctan(1/arg1));
end;

function cosech(arg1:double):double;
begin
    result  := 2/(exp(arg1)-exp(-arg1));
end;

function sech(arg1:double):double;
begin
    result  := 2/(exp(arg1)+exp(-arg1));
end;

function tanh(arg1:double):double;
begin
    result  := (exp(arg1)-exp(arg1))/(exp(arg1)+exp(-arg1));
end;

function coth(arg1:double):double;
begin
    result := (exp(arg1)+exp(arg1))/(exp(arg1)-exp(-arg1));
end;

function degarctan(arg1:double):double;
begin
    result:= RadToDeg(arctan(arg1));
end;

function arg(arg1,arg2:double):double;
begin
    if arg1 < 0 then
      result := arctan(arg2/arg1)+Pi
    else
      if arg1>0 then
        result  := arctan(arg2/arg1)
      else
        if arg2 > 0 then
          result  := 0.5 * Pi
        else
          result := -0.5 * Pi;
end;

function sinh(arg1:double):double;
begin
    result := (exp(arg1)-exp(-arg1))*0.5;
end;

function cosh(arg1:double):double;
begin
    result  := (exp(arg1)+exp(-arg1))*0.5;
end;

function cot(arg1:double):double;
begin
      if Abs(arg1)>0.000000001 then result  := cotan(arg1) else result :=100000;
end;

function cotrad(arg1:double):double;
begin
    result := cotan(DegToRad(arg1));
end;

function sec(arg1:double):double;
begin
    result := 1/cos(arg1);
end;

function cosec(arg1:double):double;
begin
   if Abs(arg1)>0.000000001 then result:= 1/sin(arg1) else result:=1000000;
end;

function tanrad(arg1:double):double;
begin
    result  := tan(DegToRad(arg1));
end;

function sinrad(arg1:double):double;
begin
    result  := sin(DegToRad(arg1));
end;

function cosrad(arg1:double):double;
begin
    result := cos(DegToRad(arg1));
end;

function cosecrad(arg1:double):double;
begin
    result  := 1/sin(DegToRad(arg1));
end;

function secrad(arg1:double):double;
begin
    result:= 1/cos(DegToRad(arg1));
end;

function blanc(arg1:double):double;
Var
   temp,res:extended;
   count:integer;
begin
  Begin
  res:=0;
   for count := 0 to 49 do
   begin
     arg1:=arg1-int(arg1-(Ord(arg1<0)));
     if (arg1)<0.5 then temp:=(arg1) else temp:=(1-arg1);
     res:=res+ temp/(power(2,count));
     arg1:=2*arg1;
   end;
  end;
  result:=res;
end;

function min(arg1,arg2:double):double;
begin
    if arg1 < arg2 then
      result  := arg1
    else
      result := arg2;
end;

function max(arg1,arg2:double):double;
begin
    if arg1 < arg2 then
      result  := arg2
    else
      result  := arg1;
end;

function heaviside(arg1:double):double;
begin
    if arg1 < 0 then
      result := 0
    else
      result  := 1;
end;

function sign(arg1:double):double;
begin
    if arg1 < 0 then
      result := -1
    else
      if arg1 > 0 then
        result := 1.0
      else
        result := 0.0;
end;

function zero(arg1:double):double;
begin
    if arg1 = 0.0 then
      result := 0.0
    else
      result:= 1.0;
end;

function ceil(arg1:double):double;
begin
    if frac(arg1) > 0 then
      result:= int(arg1 + 1)
    else
      result:= int(arg1);
end;

function floor(arg1:double):double;
begin
    if frac(arg1) < 0 then
      result:= int(arg1 – 1)
    else
      result:= int(arg1);
end;

function radius(arg1,arg2:double):double;
begin
    result:= sqrt(sqr(arg1)+sqr(arg2));
end;

欢迎大家阅读《Delphi数学运算函数_Delphi》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址