[go: up one dir, main page]

Menu

[73c35b]: / anal / cerfexp.m  Maximize  Restore  History

Download this file

35 lines (34 with data), 969 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
% cerfexp.m: Approximation for the function (1-erf(x))*exp(x**2), used in pldf
% GUISDAP v.1.60 96-05-27 Copyright Asko Huuskonen and Markku Lehtinen
%
%
% Approximation for the function (1-erf(x))*exp(x**2) with
% accuracy 1e-8 for all x. Method: power series for
% erf(x) for small x, asymptotic continued fractions expansion
% for large x (Abramovitz-Stegun formula 7.1.14)
% Markku Lehtinen 2.7.1979
%
% res=cerfexp(x)
%
function res=cerfexp(x)
%
x1=abs(x);
sqx=x*x;
if (x1<1.)
tail=0.;
term=sqx*sqx/10.;
erf=1.-sqx/3.+term;
for n=3:12
term=-term*sqx*(2*n-1.)/(2*n+1.)/n;
tail=tail+term;
end
erf=(erf+tail)*x*2./sqrt(pi);
res=(1-erf)*exp(sqx);
else
dum=0;
for n=(55:-1:1)
dum=n/2/(dum+x1);
end
res=1/(dum+x1)/sqrt(pi);
if (x<0), res=2*exp(sqx)-res; end
end