📄 complex_hss.pas
字号:
//==============================================================================
{复数对数}
Function C_Ln (const Z1: TComplex;const K:integer=0): TComplex; {Z:=Ln(Z1)}
Begin
result.x:=0.5*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
result.y:=ArcTan2(Z1.y, Z1.x)+(2*PI)*K;
End;
Procedure C_LnV (var Z1: TComplex;const K:integer=0); {Z1:=Ln(Z1)}
var tmp: CmxFloat;
Begin
tmp:=0.5*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
Z1.y:=ArcTan2(Z1.y, Z1.x)+(2*PI)*K;
Z1.x:=tmp;
End;
Function C_Log2 (const Z1: TComplex;const K:integer=0): TComplex; {Z:=Log2(Z1)}
Begin
result.x:=0.5*Ln2P*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
result.y:=ArcTan2(Z1.y, Z1.x)+2*K*Ln2P*PI;
End;
Procedure C_Log2V (var Z1: TComplex;const K:integer=0); {Z1:=Log2(Z1)}
var tmp: CmxFloat;
Begin
tmp:=0.5*Ln2P*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
Z1.y:=ArcTan2(Z1.y, Z1.x)+2*K*Ln2P*PI;
Z1.x:=tmp;
End;
Function C_Log10 (const Z1: TComplex;const K:integer=0): TComplex; {Z:=Log10(Z1)}
Begin
result.x:=0.5*Ln10P*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
result.y:=ArcTan2(Z1.y, Z1.x)+2*K*Ln10P*PI;
End;
Procedure C_Log10V (var Z1: TComplex;const K:integer=0); {Z1:=Log10(Z1)}
var tmp: CmxFloat;
Begin
tmp:=0.5*Ln10P*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
Z1.y:=ArcTan2(Z1.y, Z1.x)+2*K*Ln10P*PI;
Z1.x:=tmp;
End;
Function C_LogN (const NBase:CmxFloat;const Z1: TComplex;const K:integer=0): TComplex; {Z:=LogN(Z1)}
var LnNp: CmxFloat;
Begin
LnNp:=1/ln(NBase+SmallLimit);
result.x:=0.5*LnNp*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
result.y:=ArcTan2(Z1.y, Z1.x)+2*K*LnNp*PI;
End;
Procedure C_LogNV (const NBase:CmxFloat;var Z1: TComplex;const K:integer=0); {Z1:=LogN(Z1)}
var LnNp: CmxFloat;
tmp : CmxFloat;
Begin
LnNp:=1/Ln(NBase+SmallLimit);
tmp:=0.5*LnNp*Ln(sqr(Z1.x)+sqr(Z1.y) + SmallLimit);
Z1.y:=ArcTan2(Z1.y, Z1.x)+2*K*LnNp*PI;
Z1.x:=tmp;
End;
//==============================================================================
{复数三角函数}
Function C_Sin (const Z1: TComplex): TComplex; {Z:=Sin(Z1)}
{计算复数正弦: sin(x + i*y)= sinx*coshy+i*cosx*sinhy}
var
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x,s,c);
SinHCosH(Z1.y,sh,ch);
result.x:=S*ch;
result.y:=C*sh;
End;
Procedure C_SinV (var Z1: TComplex); {Z1:=Sin(Z1)}
var tmp : CmxFloat;
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x,s,c);
SinHCosH(Z1.y,sh,ch);
tmp:=S*ch;
Z1.y:=C*sh;
Z1.x:=tmp;
End;
Function C_Cos (const Z1: TComplex): TComplex; {Z:=Cos(Z1)}
var
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x,s,c);
SinHCosH(Z1.y,sh,ch);
result.x:= C*Ch;
result.y:=-S*Sh;
End;
Procedure C_CosV (var Z1: TComplex); {Z1:=Cos(Z1)}
var tmp: CmxFloat;
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x,s,c);
SinHCosH(Z1.y,sh,ch);
tmp := C*Ch;
Z1.y:=-S*Sh;
Z1.x:=tmp;
End;
Function C_Tan (const Z1: TComplex): TComplex; {Z:=Tan(Z1)}
var tmp: CmxFloat;
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x*2,s,c);
SinHCosH(Z1.y*2,sh,ch);
tmp:=1/(C+Ch);
result.x:=S*tmp;
result.y:=Sh*tmp;
End;
Procedure C_TanV (var Z1: TComplex); {Z1:=Tan(Z1)}
var tmp: CmxFloat;
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x*2,s,c);
SinHCosH(Z1.y*2,sh,ch);
tmp:=1/(C+Ch);
Z1.x:=S*tmp;
Z1.y:=Sh*tmp;
End;
Function C_Cot (const Z1: TComplex): TComplex; {Z:=Cotan(Z1)=>1/tan(Z1)}
var tmp: CmxFloat;
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x*2,s,c);
SinHCosH(Z1.y*2,sh,ch);
tmp:=1/(Ch-C);
result.x:= S*tmp;
result.y:=-Sh*tmp;
End;
Procedure C_CotV(var Z1: TComplex); {Z1:=Cotan(Z1)}
var tmp: CmxFloat;
c,s : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.x*2,s,c);
SinHCosH(Z1.y*2,sh,ch);
tmp:=1/(Ch-C);
Z1.x:= S*tmp;
Z1.y:=-Sh*tmp;
End;
Function C_Csc (const Z1: TComplex): TComplex; {Z:=Csc(Z1) => 1/sin(Z1)}
Begin
result:=C_Rev(C_Sin(Z1));
End;
Procedure C_CscV (var Z1: TComplex); {Z1:=Csc(Z1)}
Begin
Z1:=C_Rev(C_Sin(Z1));
End;
Function C_Sec (const Z1: TComplex): TComplex; {Z:=Sec(Z1) => 1/Cos(Z1)}
Begin
result:=C_Rev(C_Cos(Z1));
End;
Procedure C_SecV (var Z1: TComplex); {Z1:=Sec(Z1)}
Begin
Z1:=C_Rev(C_Cos(Z1));
End;
//------------------------------------------------------------------------------
Function C_Sinh (const Z1: TComplex): TComplex; {Z:=Sinh(Z1)}
var
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.y,s,c);
SinHCosH(Z1.x,sh,ch);
result.x:=Sh*C;
result.y:=Ch*S;
End;
Procedure C_SinhV(var Z1: TComplex); {Z1:=Sinh(Z1)}
var tmp: CmxFloat;
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.y,s,c);
SinHCosH(Z1.x,sh,ch);
tmp :=Sh*C;
Z1.y:=Ch*S;
Z1.x:=tmp;
End;
Function C_Cosh (const Z1: TComplex): TComplex; {Z:=Cosh(Z1)}
var
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.y,s,c);
SinHCosH(Z1.x,sh,ch);
result.x:=Ch*C;
result.y:=Sh*S;
End;
Procedure C_CoshV(var Z1: TComplex); {Z1:=Cosh(Z1)}
var tmp: CmxFloat;
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(Z1.y,s,c);
SinHCosH(Z1.x,sh,ch);
tmp :=Ch*C;
Z1.y:=Sh*S;
Z1.x:=tmp;
End;
Function C_Tanh (const Z1: TComplex): TComplex; {Z:=Tanh(Z1)}
var tmp: CmxFloat;
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(2*Z1.y,s,c);
SinHCosH(2*Z1.x,sh,ch);
tmp:=1/(Ch+C);
result.x:=Sh*tmp;
result.y:=S*tmp;
End;
Procedure C_TanhV (var Z1: TComplex); {Z1:=Tanh(Z1)}
var tmp: CmxFloat;
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(2*Z1.y,s,c);
SinHCosH(2*Z1.x,sh,ch);
tmp:=1/(Ch+C);
Z1.x:=Sh*tmp;
Z1.y:=S*tmp;
End;
Function C_Coth(const Z1: TComplex): TComplex; {Z:=Cotanh(Z1)}
var tmp: CmxFloat;
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(2*Z1.y,s,c);
SinHCosH(2*Z1.x,sh,ch);
tmp:=1/(Ch-C);
result.x:= Sh*tmp;
result.y:=-S*tmp;
End;
Procedure C_CothV(var Z1: TComplex); {Z1:=Cotanh(Z1)}
var tmp: CmxFloat;
s,c : CmxFloat;
ch,sh : CmxFloat;
Begin
sincos(2*Z1.y,s,c);
SinHCosH(2*Z1.x,sh,ch);
tmp:=1/(Ch-C);
Z1.x:= Sh*tmp;
Z1.y:=-S*tmp;
End;
Function C_CscH (const Z1: TComplex): TComplex; {Z:=CscH(Z1) => 1/sinH(Z1)}
Begin
result:=C_Rev(C_SinH(Z1));
End;
Procedure C_CscHV (var Z1: TComplex); {Z1:=CscH(Z1)}
Begin
Z1:=C_Rev(C_SinH(Z1));
End;
Function C_SecH (const Z1: TComplex): TComplex; {Z:=SecH(Z1) => 1/CosH(Z1)}
Begin
result:=C_Rev(C_CosH(Z1));
End;
Procedure C_SecHV (var Z1: TComplex); {Z1:=SecH(Z1)}
Begin
Z1:=C_Rev(C_CosH(Z1));
End;
//------------------------------------------------------------------------------
Function C_ArcSin (const Z1: TComplex): TComplex; {Z:=ArcSin(Z1)}
var tmp1 : CmxFloat;
tmp2 : CmxFloat;
tmpR : CmxFloat;
tmpA : CmxFloat;
s,c : CmxFloat;
Begin
With Z1 do
begin
tmp1 :=(Sqr(X)-Sqr(Y));
tmpA:= -2*X*Y;
tmpR:=1-tmp1;
tmp1:=Sqrt(Sqrt(Sqr(tmpR)+Sqr(tmpA)));
tmp2:=0.5*ArcTan2(tmpA,tmpR);
sincos(tmp2,s,c);
tmpR:=tmp1*c-Y;
tmpA:=tmp1*s+X;
result.y:=-0.5*Ln(Sqr(tmpR) + Sqr(tmpA) + SmallLimit);
result.x:=ArcTan2(tmpA, tmpR);
end;
End;
Procedure C_ArcSinV (var Z1: TComplex); {Z1:=ArcSin(Z1)}
var tmp1 : CmxFloat;
tmp2 : CmxFloat;
tmpR : CmxFloat;
tmpA : CmxFloat;
s,c : CmxFloat;
Begin
With Z1 do
begin
tmp1 :=(Sqr(X)-Sqr(Y));
tmpA:= -2*X*Y;
tmpR:=1-tmp1;
tmp1:=Sqrt(Sqrt(Sqr(tmpR)+Sqr(tmpA)));
tmp2:=0.5*ArcTan2(tmpA,tmpR);
sincos(tmp2,s,c);
tmpR:=tmp1*c-Y;
tmpA:=tmp1*s+X;
Y:=-0.5*Ln(Sqr(tmpR) + Sqr(tmpA) + SmallLimit);
X:=ArcTan2(tmpA, tmpR);
end;
End;
Function C_ArcCos (const Z1: TComplex): TComplex; {Z:=ArcCos(Z1)}
var tmp1 : CmxFloat;
tmp2 : CmxFloat;
tmpR : CmxFloat;
tmpA : CmxFloat;
s,c : CmxFloat;
Begin
With Z1 do
begin
tmp1:=(Sqr(X)-Sqr(Y));
tmpA:=2*X*Y;
tmpR:=tmp1-1;
tmp1:=Sqrt(Sqrt(Sqr(tmpR)+Sqr(tmpA)));
tmp2:=0.5*ArcTan2(tmpA,tmpR);
sincos(tmp2,s,c);
tmpR:=tmp1*c+X;
tmpA:=tmp1*s+Y;
result.y:=-0.5*Ln(Sqr(tmpR) + Sqr(tmpA) + SmallLimit);
result.x:=ArcTan2(tmpA, tmpR);
end;
End;
Procedure C_ArcCosV (var Z1: TComplex); {Z1:=ArcCos(Z1)}
var tmp1 : CmxFloat;
tmp2 : CmxFloat;
tmpR : CmxFloat;
tmpA : CmxFloat;
s,c : CmxFloat;
Begin
With Z1 do
begin
tmp1:=(Sqr(X)-Sqr(Y));
tmpA:=2*X*Y;
tmpR:=tmp1-1;
tmp1:=Sqrt(Sqrt(Sqr(tmpR)+Sqr(tmpA)));
tmp2:=0.5*ArcTan2(tmpA,tmpR);
sincos(tmp2,s,c);
tmpR:=tmp1*c+X;
tmpA:=tmp1*s+Y;
Y:=-0.5*Ln(Sqr(tmpR) + Sqr(tmpA) + SmallLimit);
X:=ArcTan2(tmpA, tmpR);
end;
End;
Function C_ArcTan (const Z1: TComplex): TComplex; {Z:=ArcTan(Z1)}
var tmp1 : CmxFloat;
tmp2 : CmxFloat;
tmpR : CmxFloat;
tmpA : CmxFloat;
tmpTR: CmxFloat;
tmpTA: CmxFloat;
tmpf : CmxFloat;
Begin
tmp1:=1+Z1.y; tmp2:= -Z1.x;
tmpR:=1-Z1.y; tmpA:= Z1.x;
tmpf:= 1/(Sqr(tmpR) + Sqr(tmpA) + SmallLimit);
tmpTR:=(tmp1*tmpR + tmp2*tmpA)*tmpf;
tmpT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -