# HG changeset patch # User jwe # Date 951346088 0 # Node ID b8fa63b7ea79e44a02c5dcf1f2dd134d8a63ed58 # Parent 0ae310231c463d6d8978ed9e34b2c138d7628d66 [project @ 2000-02-23 22:48:08 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2000-02-23 John W. Eaton + + * specfun/erfinv.m: Use z_new in convergence test, not z_old. + 2000-02-11 Georg Thimm * set/create_set.m: Use find to avoid while loop. diff --git a/scripts/specfun/erfinv.m b/scripts/specfun/erfinv.m --- a/scripts/specfun/erfinv.m +++ b/scripts/specfun/erfinv.m @@ -16,7 +16,7 @@ ## -*- texinfo -*- ## @deftypefn {Mapping Function} {} erfinv (@var{z}) -## Computes the inverse of the error function, +## Computes the inverse of the error function. ## @end deftypefn ## @seealso{erf and erfc} @@ -27,7 +27,7 @@ function [y, iterations] = erfinv (x) if (nargin != 1) - usage ("erfinv (x)"); + usage ("erfinv (x, maxit)"); endif maxit = 100; @@ -55,7 +55,7 @@ s = sqrt (pi) / 2; z_old = ones (length (i), 1); z_new = sqrt (-log (1 - abs (x(i)))) .* sign (x(i)); - while (any (abs (erf (z_old) - x(i)) > tol * abs (x(i)))) + while (any (abs (erf (z_new) - x(i)) > tol * abs (x(i)))) z_old = z_new; z_new = z_old - (erf (z_old) - x(i)) .* exp (z_old.^2) * s; if (++iterations > maxit)