changeset 3599:b8fa63b7ea79

[project @ 2000-02-23 22:48:08 by jwe]
author jwe
date Wed, 23 Feb 2000 22:48:08 +0000
parents 0ae310231c46
children c11d138d654a
files scripts/ChangeLog scripts/specfun/erfinv.m
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sat Feb 19 08:07:10 2000 +0000
+++ b/scripts/ChangeLog	Wed Feb 23 22:48:08 2000 +0000
@@ -1,3 +1,7 @@
+2000-02-23  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* specfun/erfinv.m: Use z_new in convergence test, not z_old.
+
 2000-02-11  Georg Thimm <mgeorg@SGraphicsWS1.mpe.ntu.edu.sg>
 
 	* set/create_set.m: Use find to avoid while loop.
--- a/scripts/specfun/erfinv.m	Sat Feb 19 08:07:10 2000 +0000
+++ b/scripts/specfun/erfinv.m	Wed Feb 23 22:48:08 2000 +0000
@@ -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)