The complementary error function, denoted erfc, is defined as
Which also defines erfcx, the scaled complementary error function(which can be used instead of erfc to avoid arithmetic underflow).
The imaginary error function, denoted erfi, is defined as
,
Where D(x) is the Dawson function (which can be used instead of erfi to avoid arithmetic overflow).When the error function is evaluated for arbitrary complex arguments z, the resulting complex error function is usually discussed in scaled form as the Faddeeva function:
2篇关于误差函数的文献
本帖隐藏的内容
由于MATLAB的所有版本已经拥有erf、erfc及其逆函数的代码,但是只有R2014a才有erfi函数的代码,下面将给出erfi函数的MATLAB(R2014a)代码。
本帖隐藏的内容
function ans=erfi(x)% %erfi(x). The Imaginary error function, as it is defined in Mathematica
% %erfi(z)==erf(iz)/i (z could be complex) using
% %the incomplete gamma function in matlab: gammainc
% %Using "@": erfi = @(x) real(-sqrt(-1).*sign(x).*gammainc(-x.^2,1/2))
% %Note: limit(x->0) erfi(x)/x -> 2/sqrt(pi)
%
% %Example 1:
% x=linspace(0.001,6,100);
% y=exp(-x.^2).*erfi(x)./2./x;
% figure(1), clf;plot(x,y*sqrt(pi))
%
% %Example 2:
% [x,y]=meshgrid(linspace(-3,3,180),linspace(-3,3,180));
% z=x+i*y;
% figure(1), clf;contourf(x,y,log(erfi(z)))
% axis equal;axis off
xc=5.7;%cut for asymptotic approximation (when x is real)
ans=~isreal(x).*(-(sqrt(-x.^2)./(x+isreal(x))).*gammainc(-x.^2,1/2))+...
isreal(x).*real(-sqrt(-1).*sign(x).*((x<xc).*gammainc(-x.^2,1/2))+...
(x>=xc).*exp(x.^2)./x/sqrt(pi));
其数值形式的MATLAB Code为
function f=erfi1(y)
fun=inline('exp(x.^2)*2/sqrt(pi)','x');
f=quadl(fun,0,y);