home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SPECFUN.DI$ / ERF.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  682 b   |  32 lines

  1. function z = erf(x,y)
  2. %ERF    The error function.
  3. %    y = erf(x).
  4. %    y = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt.
  5. %
  6. %    See also ERFC, ERFCX, ERFINV.
  7.  
  8. %    Ref: Abramowitz & Stegun, Handbook of Mathemtical Functions, sec. 7.1.
  9.  
  10. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  11.  
  12. % Derived from a FORTRAN program by W. J. Cody.
  13. % See ERFCORE.
  14.  
  15. if nargin == 1
  16.     z = erfcore(x,0);
  17. elseif nargin == 2
  18.     if max(size(x))==1 | max(size(y))==1
  19.         if ~finite(y) & ~isnan(y) & y>0
  20.             z = erfcore(x,1);
  21.         elseif ~finite(x) & ~isnan(x) & x<0
  22.             z = 1 + erfcore(x,1);
  23.         else
  24.             error('Invalid input arguments.');
  25.         end
  26.     else
  27.         z = erfcore(y,1)-erfcore(x,1);
  28.     end
  29. end
  30.         
  31.  
  32.