You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/12/08 15:24:24 UTC

[commons-numbers] branch master updated: NUMBERS-177: Add scaled complementary error function Erfcx

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git


The following commit(s) were added to refs/heads/master by this push:
     new 797eba3  NUMBERS-177: Add scaled complementary error function Erfcx
797eba3 is described below

commit 797eba323327f8bc232213c25a5b1ccbfadbc2bb
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Mon Dec 6 08:34:26 2021 +0000

    NUMBERS-177: Add scaled complementary error function Erfcx
    
    Updates the rational function approximation for erfc(x > 4) to a
    function valid for the approximation limit of erfcx (x ~ 6.71e7).
    
    Improves the scaling by exp(-x*x) and exp(x*x).
---
 .../org/apache/commons/numbers/gamma/BoostErf.java | 298 +++++++++++++++++----
 .../org/apache/commons/numbers/gamma/Erfcx.java    |  55 ++++
 .../apache/commons/numbers/gamma/BoostErfTest.java | 268 +++++++++++++++++-
 .../apache/commons/numbers/gamma/ErfcxTest.java    |  78 ++++++
 .../commons/numbers/gamma/erfcx_huge_data.csv      | 159 +++++++++++
 .../commons/numbers/gamma/erfcx_large_data.csv     | 105 ++++++++
 .../commons/numbers/gamma/erfcx_medium_data.csv    | 190 +++++++++++++
 .../commons/numbers/gamma/erfcx_neg_data.csv       | 224 ++++++++++++++++
 .../numbers/gamma/erfcx_neg_medium_data.csv        | 188 +++++++++++++
 .../commons/numbers/gamma/erfcx_neg_small_data.csv | 158 +++++++++++
 .../commons/numbers/gamma/erfcx_small_data.csv     | 158 +++++++++++
 src/changes/changes.xml                            |   3 +
 12 files changed, 1833 insertions(+), 51 deletions(-)

diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostErf.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostErf.java
index e6a51c3..e8d3790 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostErf.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/BoostErf.java
@@ -28,7 +28,11 @@ package org.apache.commons.numbers.gamma;
  *
  * <p>This code has been adapted from the <a href="https://www.boost.org/">Boost</a>
  * {@code c++} implementation {@code <boost/math/special_functions/erf.hpp>}.
- * All work is copyright John Maddock 2006 and subject to the Boost Software License.
+ * The erf/erfc functions and their inverses are copyright John Maddock 2006 and subject to
+ * the Boost Software License.
+ *
+ * <p>Additions made to support the erfcx function are original work under the Apache software
+ * license.
  *
  * @see
  * <a href="https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_erf/error_function.html">
@@ -42,6 +46,23 @@ final class BoostErf {
      * and the multiplier is {@code 2^27 + 1}.
      */
     private static final double MULTIPLIER = 1.0 + 0x1.0p27;
+    /** 1 / sqrt(pi). Used for the scaled complementary error function erfcx. */
+    private static final double ONE_OVER_ROOT_PI = 0.5641895835477562869480794515607725858;
+    /** Threshold for the scaled complementary error function erfcx
+     * where the approximation {@code (1 / sqrt(pi)) / x} can be used. */
+    private static final double ERFCX_APPROX = 6.71e7;
+    /** Threshold for the erf implementation for |x| where the computation
+     * uses {@code erf(x)}; otherwise {@code erfc(x)} is computed. The final result is
+     * achieved by suitable application of symmetry. */
+    private static final double COMPUTE_ERF = 0.5;
+    /** Threshold for the scaled complementary error function erfcx for negative x
+     * where {@code 2 * exp(x*x)} will overflow. Value is 26.62873571375149. */
+    private static final double ERFCX_NEG_X_MAX = Math.sqrt(Math.log(Double.MAX_VALUE / 2));
+    /** Threshold for the scaled complementary error function erfcx for x
+     * where {@code exp(x*x) == 1; x <= t}. Value is (1 + 5/16) * 2^-27 = 9.778887033462524E-9.
+     * <p>Note: This is used for performance. If set to 0 then the result is computed
+     * using expm1(x*x) with the same final result. */
+    private static final double EXP_XX_1 = 0x1.5p-27;
 
     /** Private constructor. */
     private BoostErf() {
@@ -60,14 +81,21 @@ final class BoostErf {
     // - Explicitly inline the polynomial function evaluation
     //   using Horner's method (https://en.wikipedia.org/wiki/Horner%27s_method)
     // - Support odd function for f(0.0) = -f(-0.0)
+    // - Support the scaled complementary error function erfcx
     // Erf:
     // - Change extended precision z*z to compute the square round-off
     //   using Dekker's method
-    // - Change the erf threshold for z when p=1 from
+    // - Change extended precision exp(-z*z) to compute using a
+    //   round-off addition to the standard exp result (see NUMBERS-177)
+    // - Change the erf threshold for z when erf(z)=1 from
     //   z > 5.8f to z > 5.930664
-    // - Change edge case detection for integer z
+    // - Change the erfc threshold for z when erfc(z)=0 from
+    //   z < 28 to z < 27.3
+    // - Change rational function approximation for z > 4 to a function
+    //   suitable for erfcx (see NUMBERS-177)
     // Inverse erf:
     // - Change inverse erf edge case detection to include NaN
+    // - Change edge case detection for integer z
     //
     // Note:
     // Constants using the 'f' suffix are machine
@@ -82,7 +110,7 @@ final class BoostErf {
      * @return the complementary error function.
      */
     static double erfc(double x) {
-        return erfImp(x, true);
+        return erfImp(x, true, false);
     }
 
     /**
@@ -92,28 +120,34 @@ final class BoostErf {
      * @return the error function.
      */
     static double erf(double x) {
-        return erfImp(x, false);
+        return erfImp(x, false, false);
     }
 
     /**
      * 53-bit implementation for the error function.
      *
+     * <p>Note: The {@code scaled} flag only applies when
+     * {@code z >= 0.5} and {@code invert == true}.
+     * This functionality is used to compute erfcx(z) for positive z.
+     *
      * @param z Point to evaluate
      * @param invert true to invert the result (for the complementary error function)
+     * @param scaled true to compute the scaled complementary error function
      * @return the error function result
      */
-    private static double erfImp(double z, boolean invert) {
+    private static double erfImp(double z, boolean invert, boolean scaled) {
         if (Double.isNaN(z)) {
             return Double.NaN;
         }
 
         if (z < 0) {
+            // Here the scaled flag is ignored.
             if (!invert) {
-                return -erfImp(-z, invert);
+                return -erfImp(-z, invert, false);
             } else if (z < -0.5) {
-                return 2 - erfImp(-z, invert);
+                return 2 - erfImp(-z, invert, false);
             } else {
-                return 1 + erfImp(-z, false);
+                return 1 + erfImp(-z, false, false);
             }
         }
 
@@ -124,10 +158,11 @@ final class BoostErf {
         // which implementation to use,
         // try to put most likely options first:
         //
-        if (z < 0.5) {
+        if (z < COMPUTE_ERF) {
             //
             // We're going to calculate erf:
             //
+            // Here the scaled flag is ignored.
             if (z < 1e-10) {
                 if (z == 0) {
                     result = z;
@@ -157,11 +192,13 @@ final class BoostErf {
                 Q =                        1.0 + Q * zz;
                 result = z * (Y + P / Q);
             }
-        // Note: Boost threshold of 5.8f has been raised to approximately 5.93 (6073 / 1024)
-        } else if (invert ? (z < 28) : (z < 5.9306640625f)) {
+        // Note: Boost threshold of 5.8f has been raised to approximately 5.93 (6073 / 1024);
+        // threshold of 28 has been lowered to approximately 27.3 (6989/256) where exp(-z*z) = 0.
+        } else if (scaled || (invert ? (z < 27.300781f) : (z < 5.9306640625f))) {
             //
             // We'll be calculating erfc:
             //
+            // Here the scaled flag is used.
             invert = !invert;
             if (z < 1.5f) {
                 // Maximum Deviation Found:                     3.702e-17
@@ -186,7 +223,11 @@ final class BoostErf {
                 Q =     1.84759070983002217845 + Q * zm;
                 Q =                        1.0 + Q * zm;
                 result = Y + P / Q;
-                result *= Math.exp(-z * z) / z;
+                if (scaled) {
+                    result /= z;
+                } else {
+                    result *= expmxx(z) / z;
+                }
             } else if (z < 2.5f) {
                 // Max Error found at double precision =        6.599585e-18
                 // Maximum Deviation Found:                     3.909e-18
@@ -209,10 +250,14 @@ final class BoostErf {
                 Q =    1.53991494948552447182 + Q * zm;
                 Q =                       1.0 + Q * zm;
                 result = Y + P / Q;
-                final double sq = z * z;
-                final double errSqr = squareLowUnscaled(z, sq);
-                result *= Math.exp(-sq) * Math.exp(-errSqr) / z;
-            } else if (z < 4.5f) {
+                if (scaled) {
+                    result /= z;
+                } else {
+                    result *= expmxx(z) / z;
+                }
+            // Lowered Boost threshold from 4.5 to 4.0 as this is the limit
+            // for the Cody erfc approximation
+            } else if (z < 4.0f) {
                 // Maximum Deviation Found:                     1.512e-17
                 // Expected Error Term:                         1.512e-17
                 // Maximum Relative Change in Control Points:   2.222e-04
@@ -234,46 +279,62 @@ final class BoostErf {
                 Q =     1.04217814166938418171 + Q * zm;
                 Q =                        1.0 + Q * zm;
                 result = Y + P / Q;
-                final double sq = z * z;
-                final double errSqr = squareLowUnscaled(z, sq);
-                result *= Math.exp(-sq) * Math.exp(-errSqr) / z;
+                if (scaled) {
+                    result /= z;
+                } else {
+                    result *= expmxx(z) / z;
+                }
             } else {
-                // Max Error found at double precision =        2.997958e-17
-                // Maximum Deviation Found:                     2.860e-17
-                // Expected Error Term:                         2.859e-17
-                // Maximum Relative Change in Control Points:   1.357e-05
-                final double Y = 0.5579090118408203125f;
-                final double iz = 1 / z;
-                double P;
-                P =    -2.8175401114513378771;
-                P =   -3.22729451764143718517 + P * iz;
-                P =    -2.5518551727311523996 + P * iz;
-                P =  -0.687717681153649930619 + P * iz;
-                P =  -0.212652252872804219852 + P * iz;
-                P =  0.0175389834052493308818 + P * iz;
-                P = 0.00628057170626964891937 + P * iz;
-                double Q;
-                Q = 5.48409182238641741584;
-                Q = 13.5064170191802889145 + Q * iz;
-                Q = 22.9367376522880577224 + Q * iz;
-                Q =  15.930646027911794143 + Q * iz;
-                Q = 11.0567237927800161565 + Q * iz;
-                Q = 2.79257750980575282228 + Q * iz;
-                Q =                    1.0 + Q * iz;
-                result = Y + P / Q;
-                final double sq = z * z;
-                final double errSqr = squareLowUnscaled(z, sq);
-                result *= Math.exp(-sq) * Math.exp(-errSqr) / z;
+                // Rational function approximation for erfc(x > 4.0)
+                //
+                // This approximation is not the Boost implementation.
+                // The Boost function is suitable for [4.5 < z < 28].
+                //
+                // This function is suitable for erfcx(z) as it asymptotes
+                // to (1 / sqrt(pi)) / z at large z.
+                //
+                // Taken from "Rational Chebyshev approximations for the error function"
+                // by W. J. Cody, Math. Comp., 1969, PP. 631-638.
+                //
+                // See NUMBERS-177.
+
+                final double izz = 1 / (z * z);
+                double p;
+                p = 1.63153871373020978498e-2;
+                p = 3.05326634961232344035e-1 + p * izz;
+                p = 3.60344899949804439429e-1 + p * izz;
+                p = 1.25781726111229246204e-1 + p * izz;
+                p = 1.60837851487422766278e-2 + p * izz;
+                p = 6.58749161529837803157e-4 + p * izz;
+                double q;
+                q = 1;
+                q = 2.56852019228982242072e00 + q * izz;
+                q = 1.87295284992346047209e00 + q * izz;
+                q = 5.27905102951428412248e-1 + q * izz;
+                q = 6.05183413124413191178e-2 + q * izz;
+                q = 2.33520497626869185443e-3 + q * izz;
+
+                result = izz * p / q;
+                result = (ONE_OVER_ROOT_PI - result) / z;
+
+                if (!scaled) {
+                    // exp(-z*z) can be sub-normal so
+                    // multiply by any sub-normal after divide by z
+                    result *= expmxx(z);
+                }
             }
         } else {
             //
-            // Any value of z larger than 28 will underflow to zero:
+            // Any value of z larger than 27.3 will underflow to zero:
             //
             result = 0;
             invert = !invert;
         }
 
         if (invert) {
+            // Note: If 0.5 <= z < 28 and the scaled flag is true then
+            // invert will have been flipped to false and the
+            // the result is unchanged as erfcx(z)
             result = 1 - result;
         }
 
@@ -281,6 +342,70 @@ final class BoostErf {
     }
 
     /**
+     * Returns the scaled complementary error function.
+     * <pre>
+     * erfcx(x) = exp(x^2) * erfc(x)
+     * </pre>
+     *
+     * @param x the value.
+     * @return the scaled complementary error function.
+     */
+    static double erfcx(double x) {
+        if (Double.isNaN(x)) {
+            return Double.NaN;
+        }
+
+        // For |z| < 0.5 erfc is computed using erf
+        final double ax = Math.abs(x);
+        if (ax < COMPUTE_ERF) {
+            // Use the erf(x) result.
+            // (1 - erf(x)) * exp(x*x)
+
+            final double erfx = erf(x);
+            if (ax < EXP_XX_1) {
+                // No exponential required
+                return 1 - erfx;
+            }
+
+            // exp(x*x) - exp(x*x) * erf(x)
+            // Avoid use of exp(x*x) with expm1:
+            // exp(x*x) - 1 - (erf(x) * (exp(x*x) - 1)) - erf(x) + 1
+
+            // Sum small to large: |erf(x)| > expm1(x*x)
+            // -erf(x) * expm1(x*x) + expm1(x*x) - erf(x) + 1
+            // Negative x: erf(x) < 0, summed terms are positive, no cancellation occurs.
+            // Positive x: erf(x) > 0 so cancellation can occur.
+            // When terms are ordered by absolute magnitude the magnitude of the next term
+            // is above the round-off from adding the previous term to the sum. Thus
+            // cancellation is negligible compared to errors in the largest computed term (erf(x)).
+
+            final double em1 = Math.expm1(x * x);
+            return -erfx * em1 + em1 - erfx + 1;
+        }
+
+        // Handle negative arguments
+        if (x < 0) {
+            // erfcx(x) = 2*exp(x*x) - erfcx(-x)
+
+            if (x < -ERFCX_NEG_X_MAX) {
+                // Overflow
+                return Double.POSITIVE_INFINITY;
+            }
+
+            final double e = expxx(x);
+            return e - erfImp(-x, true, true) + e;
+        }
+
+        // Approximation for large positive x
+        if (x > ERFCX_APPROX) {
+            return ONE_OVER_ROOT_PI / x;
+        }
+
+        // Compute erfc scaled
+        return erfImp(x, true, true);
+    }
+
+    /**
      * Returns the inverse complementary error function.
      *
      * @param z Value (in {@code [0, 2]}).
@@ -589,6 +714,85 @@ final class BoostErf {
         return result;
     }
 
+    /**
+     * Compute {@code exp(x*x)} with high accuracy. This is performed using
+     * information in the round-off from {@code x*x}.
+     *
+     * <p>This is accurate at large x to 1 ulp.
+     *
+     * <p>At small x the accuracy cannot be improved over using exp(x*x).
+     * This occurs at {@code x <= 1}.
+     *
+     * <p>Warning: This has no checks for overflow. The method is never called
+     * when {@code x*x > log(MAX_VALUE/2)}.
+     *
+     * @param x Value
+     * @return exp(x*x)
+     */
+    static double expxx(double x) {
+        // Note: If exp(a) overflows this can create NaN if the
+        // round-off b is negative or zero:
+        // exp(a) * exp1m(b) + exp(a)
+        // inf * 0 + inf   or   inf * -b  + inf
+        final double a = x * x;
+        final double b = squareLowUnscaled(x, a);
+        return expxx(a, b);
+    }
+
+    /**
+     * Compute {@code exp(-x*x)} with high accuracy. This is performed using
+     * information in the round-off from {@code x*x}.
+     *
+     * <p>This is accurate at large x to 1 ulp until exp(-x*x) is close to
+     * sub-normal. For very small exp(-x*x) the adjustment is sub-normal and
+     * bits can be lost in the adjustment for a max observed error of {@code < 2} ulp.
+     *
+     * <p>At small x the accuracy cannot be improved over using exp(-x*x).
+     * This occurs at {@code x <= 1}.
+     *
+     * @param x Value
+     * @return exp(-x*x)
+     */
+    static double expmxx(double x) {
+        final double a = x * x;
+        final double b = squareLowUnscaled(x, a);
+        return expxx(-a, -b);
+    }
+
+    /**
+     * Compute {@code exp(a+b)} with high accuracy assuming {@code a+b = a}.
+     *
+     * <p>This is accurate at large positive a to 1 ulp. If a is negative and exp(a) is
+     * close to sub-normal a bit of precision may be lost when adjusting result
+     * as the adjustment is sub-normal (max observed error {@code < 2} ulp).
+     * For the use case of multiplication of a number less than 1 by exp(-x*x), a = -x*x,
+     * the result will be sub-normal and the rounding error is lost.
+     *
+     * <p>At small |a| the accuracy cannot be improved over using exp(a) as the
+     * round-off is too small to create terms that can adjust the standard result by
+     * more than 0.5 ulp. This occurs at {@code |a| <= 1}.
+     *
+     * @param a High bits of a split number
+     * @param b Low bits of a split number
+     * @return exp(a+b)
+     */
+    private static double expxx(double a, double b) {
+        // exp(a+b) = exp(a) * exp(b)
+        //          = exp(a) * (exp(b) - 1) + exp(a)
+        // Assuming:
+        // 1. -746 < a < 710 for no under/overflow of exp(a)
+        // 2. a+b = a
+        // As b -> 0 then exp(b) -> 1; expm1(b) -> b
+        // The round-off b is limited to ~ 0.5 * ulp(746) ~ 5.68e-14
+        // and we can use an approximation for expm1 (x/1! + x^2/2! + ...)
+        // The second term is required for the expm1 result but the
+        // bits are not significant to change the product with exp(a)
+
+        final double ea = Math.exp(a);
+        // b ~ expm1(b)
+        return ea * b + ea;
+    }
+
     // Extended precision multiplication specialised for the square adapted from:
     // org.apache.commons.numbers.core.ExtendedPrecision
 
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfcx.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfcx.java
new file mode 100644
index 0000000..ca8b907
--- /dev/null
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Erfcx.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.numbers.gamma;
+
+/**
+ * Scaled complementary error function.
+ *
+ * <p>\[ \operatorname{erfcx}(z) = \operatorname{erfc}(z)\ e^{z^2} \]
+ *
+ * <p>For large z the value is approximately:
+ *
+ * <p>\[ \operatorname{erfcx}(z) = \frac{1}{z \sqrt{\pi}} \]
+ *
+ * @see Erfc
+ * @since 1.1
+ */
+public final class Erfcx {
+    /** Private constructor. */
+    private Erfcx() {
+        // intentionally empty.
+    }
+
+    /**
+     * Returns the scaled complementary error function.
+     *
+     * <p>Special cases:
+     * <ul>
+     * <li>If the argument is 0, then the result is 1.
+     * <li>If the argument is +infinity, then the result is 0.
+     * <li>If the argument is negative and {@code exp(z*z)} is infinite, then the result is +infinity.
+     * <li>If the argument is nan, then the result is nan.
+     * </ul>
+     *
+     * @param x Value.
+     * @return the scaled complementary error function.
+     */
+    public static double value(double x) {
+        return BoostErf.erfcx(x);
+    }
+}
+
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/BoostErfTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/BoostErfTest.java
index 5fd4e78..da7bd0e 100644
--- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/BoostErfTest.java
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/BoostErfTest.java
@@ -49,7 +49,8 @@ class BoostErfTest {
         ERF(BoostErf::erf, true),
         ERFC(BoostErf::erfc, false),
         ERF_INV(BoostErf::erfInv, true),
-        ERFC_INV(BoostErf::erfcInv, false);
+        ERFC_INV(BoostErf::erfcInv, false),
+        ERFCX(BoostErf::erfcx, false);
 
         /** The function. */
         private final DoubleUnaryOperator fun;
@@ -112,13 +113,13 @@ class BoostErfTest {
      */
     private enum TestCase {
         /** Erf Boost data. */
-        ERF(TestFunction.ERF, 1.4, 0.25),
+        ERF(TestFunction.ERF, 1.3, 0.2),
         /** Erfc Boost data. */
         ERFC(TestFunction.ERFC, 2.2, 0.5),
         /** Erf Boost large data (simple case where all z>8, p=1.0). */
         ERF_LARGE(TestFunction.ERF, 0, 0.0),
         /** Erfc Boost large data. */
-        ERFC_LARGE(TestFunction.ERFC, 1.99, 0.75),
+        ERFC_LARGE(TestFunction.ERFC, 1.75, 0.7),
         /** Erf Boost small data (no exponentiation required). */
         ERF_SMALL(TestFunction.ERF, 1.2, 0.25),
         /** Erfc Boost small data (no exponentiation required: ulp=0). */
@@ -132,7 +133,19 @@ class BoostErfTest {
         /** Inverse Erf limit data. */
         ERF_INV_LIMIT(TestFunction.ERF_INV, 1.4, 0.5),
         /** Inverse Erfc limit data. */
-        ERFC_INV_LIMIT(TestFunction.ERFC_INV, 1.2, 0.5);
+        ERFC_INV_LIMIT(TestFunction.ERFC_INV, 1.2, 0.5),
+        /** Erfcx negative medium data. */
+        ERFCX_NEG_MEDIUM(TestFunction.ERFCX, 1.7, 0.55),
+        /** Erfcx negative small data. */
+        ERFCX_NEG_SMALL(TestFunction.ERFCX, 0.7, 0.061),
+        /** Erfcx small data. */
+        ERFCX_SMALL(TestFunction.ERFCX, 0.6, 0.073),
+        /** Erfcx medium data. */
+        ERFCX_MED(TestFunction.ERFCX, 1.2, 0.5),
+        /** Erfcx large data. */
+        ERFCX_LARGE(TestFunction.ERFCX, 1.1, 0.45),
+        /** Erfcx huge data. */
+        ERFCX_HUGE(TestFunction.ERFCX, 1.25, 0.45);
 
         /** Sum of the squared ULP error and count n. */
         private final TestUtils.ErrorStatistics stats = new TestUtils.ErrorStatistics();
@@ -209,6 +222,111 @@ class BoostErfTest {
 
     @ParameterizedTest
     @CsvSource({
+        "0, 1",
+        // Reference data from GCC libquadmath expq(z*z)
+        // Cases from known max ulp errors for:
+        // a = z*z; b = z*z round-off
+        // exp(a+b) = exp(a) * exp(b) = exp(a) * expm1(b) + exp(a)
+        "0.042876182518572857, 1.00184005785999452616485960307584103",
+        "0.12332761808971203,  1.01532595755115384513226892929687518",
+        "0.23492402237866017,  1.05674063282543772769083554593703693",
+        "0.5005007866910639,   1.28466892274154983265904587935363446",
+        "0.6079329058333609,   1.44713019294681595655835657289687865",
+        "0.70256943723915932,  1.6382093968128949474570450121807659",
+        "0.82241395271131823,  1.96671514042639717092581737392007089",
+        "1.1676941591314409,   3.90989159781783456283136476225348036",
+        "1.2872328693421708,   5.24339117555116565213868516013500793",
+        "1.763493621168525,    22.4190210354395450203564424019491017",
+        "2.2911777554159483,   190.470153340296021320752950876036293",
+        "2.6219566826446719,   967.443326246348231629933262201707317",
+        "3.0037511703473512,   8287.64469163961117832508854092931197",
+        "4.9612493700241904,   48946578790.7631709834358118976268355",
+        "9.3076562180806182,   4.20727779143532487527563444483221012e+37",
+        "14.323050579907544,   1.24570874136900582743589942668130243e+89",
+        "19.789244604728378,   1.19093202729437857229577485425178318e+170",
+        "25.264725343479071,   1.63276667418921707391087152900497326e+277",
+        "26.471453083170552,   2.12115354204783587764203142231215649e+304",
+        "26.628235718509234,   8.7522773171090885282464768100291983e+307",
+        // Limit.
+        // The next double up (26.64174755704633) has
+        // exp(x*x) = 1.79769313486244732925408679719502907e+308 = Infinity
+        // This is computed as NaN due to lack of overflow checks.
+        "26.641747557046327,   1.79769313486210702414246567679413232e+308",
+    })
+    void testExpxx(double z, BigDecimal expected) {
+        final double actual = BoostErf.expxx(z);
+        TestUtils.assertEquals(expected, actual, 1.0);
+    }
+
+    @ParameterizedTest
+    @CsvSource({
+        // Known cases where exp(x*x) is infinite and the round-off is zero or negative
+        "27,                 3.98728526204259656354686104733435016e+316",
+        "27.45162436,        1.79769313486244732925408679719502907e+308",
+        // Next double after 26.641747557046327
+        "26.64174755704633,  1.79769313486244732925408679719502907e+308",
+    })
+    void testExpxxOverflow(double z, double expected) {
+        final double e = Math.exp(z * z);
+        Assertions.assertEquals(Double.POSITIVE_INFINITY, e);
+        Assertions.assertEquals(Double.POSITIVE_INFINITY, expected);
+        Assertions.assertEquals(Double.NaN, BoostErf.expxx(z), "No overflow checks");
+    }
+
+    @ParameterizedTest
+    @CsvSource({
+        "0, 1",
+        // Reference data from GCC libquadmath expq(-z*z)
+        // Cases from known max ulp errors for:
+        // a = z*z; b = z*z round-off
+        // exp(a+b) = exp(a) * exp(b) = exp(a) * expm1(b) + exp(a)
+        "0.018888546570790723, 0.999643286445856926713199201695735708",
+        "0.044040879540028978, 0.998062280736064566626960146268218869",
+        "0.14252706610502067,  0.979890973955195922461144945194213951",
+        "0.21644880196960639,  0.954230441398827896658935167789523746",
+        "0.38611178653477424,  0.861498200598095608584361373395644347",
+        "0.48918821106359167,  0.78717467413707227187574762653633039",
+        "0.69762286071744906,  0.614665134758267412066486574992456239",
+        "0.74212965000887676,  0.576513560506426682539710563714000483",
+        "0.83549504832885912,  0.497553606822144444881962542058093636",
+        "0.93551572137564831,  0.416782963065511995785537520046193978",
+        "1.1557980830683314,   0.262929535430060880774643925549236367",
+        "1.4043799106718902,   0.139138848619574074162424456941838826",
+        "1.76928217755289,     0.0437020868591733321664690441540917611",
+        "3.030043930000375,    0.000102960388874918024753918581478636755",
+        "6.8941333932059292,   2.28236391243884653067874490191517352e-21",
+        "12.150966601450184,   7.55373161692552909052687379129491314e-65",
+        "18.145618649215113,   1.00621134630738394627962504745954853e-143",
+        "22.58677686154909,    2.74945208846365015258084878726170577e-222",
+        "25.307715003447811,   6.96433586576952601048539830338695099e-279",
+        "26.314662520770881,   1.85270995749302588464727454552962812e-301",
+        "26.550566379026709,   7.1067746279803211201902681713374704e-307",
+        // Limit
+        "27.297128403953796,   2.47032822920651974943004172315065178e-324",
+        // exp(-z*z) = 0
+        "27.2971284039538,     2.47032822920604061009296400001395168e-324",
+    })
+    void testExpmxx(double z, BigDecimal expected) {
+        final double actual = BoostErf.expmxx(z);
+        TestUtils.assertEquals(expected, actual, 1.0);
+    }
+
+    @ParameterizedTest
+    @CsvSource({
+        // Reference data from GCC libquadmath expq(z)
+        // exp(z) is nearly sub-normal
+        "26.589967471163597, 8.75686990774305433076998380040492953e-308",
+        "26.592726991055095, 7.56157741629803260538530412232841961e-308",
+        "26.593224983876986, 7.36392883240998076191982506525092463e-308",
+        "26.596608821043414, 6.15095812619805721349676447899566968e-308",
+    })
+    void testExpmxxCloseToSubNormal(double z, BigDecimal expected) {
+        final double actual = BoostErf.expmxx(z);
+        TestUtils.assertEquals(expected, actual, 1.3);
+    }
+
+    @ParameterizedTest
+    @CsvSource({
         "-Infinity, -1",
         "Infinity, 1",
         "0, 0",
@@ -475,6 +593,148 @@ class BoostErfTest {
         assertRms(name, data, rmsUlp);
     }
 
+    @ParameterizedTest
+    @CsvSource({
+        "NaN, NaN",
+        "0, 1",
+        "-0.0, 1",
+        "1e-100, 1",
+        // expected 1.0000000000000002
+        "-2.220446049250313E-16, 1.0000000000000002505505",
+        // expected 1.0
+        "-1.1102230246251565E-16, 1.000000000000000125275",
+        "1.734723475976807e-17, 0.99999999999999998042574169",
+        // expected 0.9999999999999999
+        "5.551115123125783e-17, 0.99999999999999993736237340916",
+        // max value
+        "1.7976931348623157e308, 3.13840873398544321279297017922274491e-309",
+        "Infinity, 0",
+        "-27, Infinity",
+        "-26.62873571375149, 1.7976931348622485388617592502115433e+308",
+        // This is infinite as a double: matlab erfcx = Inf
+        "-26.628735713751492, 1.79769313486258867776818776259144527e+308",
+    })
+    void testErfcxEdgeCases(double z, double expected) {
+        final double actual = BoostErf.erfcx(z);
+        // Workaround for NaN not having a valid ulp
+        if (Double.isFinite(expected)) {
+            Assertions.assertEquals(expected, actual, Math.ulp(expected));
+        } else {
+            Assertions.assertEquals(expected, actual);
+        }
+    }
+
+    @ParameterizedTest
+    @CsvSource({
+        // matlab: fprintf("%.17g\n, erfcx(z))
+        "-24.356, 8.5293595881160216e+257",
+        "-12.34, 2.7132062210034015e+66",
+        "-6.89, 8.2775358436372447e+20",
+        "-1.11134, 6.4783098090861095",
+        "-0.67868, 2.6356650381821858",
+        "-0.1234, 1.156008270595601",
+        "0.1234, 0.87467990946395457",
+        "0.2836, 0.74601996202714793",
+        "0.7521364, 0.5061525663103037",
+        "1.678, 0.2947001506216585",
+        "2.67868, 0.19827490572168827",
+        "5.6788, 0.09787639472753934",
+        "10.67182, 0.052638121464397732",
+        "15.678, 0.035913308816213706",
+        "23.975, 0.023511995366729203",
+        "26.8989, 0.020959983993738648",
+        "27.1678, 0.020752808901245822",
+        "27.789, 0.020289502724156101",
+        "28.4567, 0.019814028635674531",
+        "33.67868, 0.016744753846685077",
+        "56.567, 0.0099722712078122132",
+        "101.101, 0.0055801820870247853",
+        "234.7, 0.0024038536962965006",
+        "678658.678, 8.3133039013043281e-07",
+    })
+    void testErfcxSpotTests(double z, double expected) {
+        final double actual = BoostErf.erfcx(z);
+        Assertions.assertEquals(expected, actual, Math.ulp(expected));
+    }
+
+    @ParameterizedTest
+    @Order(1)
+    @CsvFileSource(resources = "erfcx_neg_medium_data.csv")
+    void testErfcxNegMedium(double z, BigDecimal expected) {
+        assertErf(TestCase.ERFCX_NEG_MEDIUM, z, expected);
+    }
+
+    @Test
+    @Order(3010)
+    void testErfcxNegMediumRMS() {
+        assertRms(TestCase.ERFCX_NEG_MEDIUM);
+    }
+
+    @ParameterizedTest
+    @Order(1)
+    @CsvFileSource(resources = "erfcx_neg_small_data.csv")
+    void testErfcxNegSmall(double z, BigDecimal expected) {
+        assertErf(TestCase.ERFCX_NEG_SMALL, z, expected);
+    }
+
+    @Test
+    @Order(3020)
+    void testErfcxNegSmallRMS() {
+        assertRms(TestCase.ERFCX_NEG_SMALL);
+    }
+
+    @ParameterizedTest
+    @Order(1)
+    @CsvFileSource(resources = "erfcx_small_data.csv")
+    void testErfcxSmall(double z, BigDecimal expected) {
+        assertErf(TestCase.ERFCX_SMALL, z, expected);
+    }
+
+    @Test
+    @Order(3030)
+    void testErfcxSmallRMS() {
+        assertRms(TestCase.ERFCX_SMALL);
+    }
+
+    @ParameterizedTest
+    @Order(1)
+    @CsvFileSource(resources = "erfcx_medium_data.csv")
+    void testErfcxMedium(double z, BigDecimal expected) {
+        assertErf(TestCase.ERFCX_MED, z, expected);
+    }
+
+    @Test
+    @Order(3040)
+    void testErfcxMediumRMS() {
+        assertRms(TestCase.ERFCX_MED);
+    }
+
+    @ParameterizedTest
+    @Order(1)
+    @CsvFileSource(resources = "erfcx_large_data.csv")
+    void testErfcxLarge(double z, BigDecimal expected) {
+        assertErf(TestCase.ERFCX_LARGE, z, expected);
+    }
+
+    @Test
+    @Order(3050)
+    void testErfcxLargeRMS() {
+        assertRms(TestCase.ERFCX_LARGE);
+    }
+
+    @ParameterizedTest
+    @Order(1)
+    @CsvFileSource(resources = "erfcx_huge_data.csv")
+    void testErfcxHuge(double z, BigDecimal expected) {
+        assertErf(TestCase.ERFCX_HUGE, z, expected);
+    }
+
+    @Test
+    @Order(3060)
+    void testErfcxHugeRMS() {
+        assertRms(TestCase.ERFCX_HUGE);
+    }
+
     /**
      * Assert the function using extended precision.
      *
diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcxTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcxTest.java
new file mode 100644
index 0000000..a877255
--- /dev/null
+++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/ErfcxTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.numbers.gamma;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+/**
+ * Tests for {@link Erfcx}.
+ */
+class ErfcxTest {
+    @ParameterizedTest
+    @CsvSource({
+        "NaN, NaN",
+        "0, 1",
+        "Infinity, 0",
+        "-27, Infinity",
+    })
+    void testErfcxEdgeCases(double z, double expected) {
+        Assertions.assertEquals(expected, Erfcx.value(z));
+    }
+
+    /**
+     * Compare erfcx against reference values computed using matlab.
+     */
+    @ParameterizedTest
+    @CsvSource({
+        // Positives
+        "0.123, 0.87504503469728478",
+        "0.356, 0.69768949677109249",
+        "0.598, 0.56869994421241077",
+        "1.12, 0.39689157691768223",
+        "2.54, 0.20787186512579933",
+        "4.78, 0.11560177456745414",
+        "8.89, 0.06306928075747556",
+        "16.133, 0.034904353289554449",
+        "25.677, 0.021955940669412959",
+        "32.123, 0.017554917112870515",
+        "64.156, 0.0087929589162697615",
+        "128.1256, 0.00440327616930610247",
+        "256.245, 0.0022017416435368476",
+        "512.123, 0.0011016660215700644",
+        "1024.1211, 0.0005509009770282079",
+        "1.87e5, 3.0170565964689267e-06",
+        "1.23e6, 4.5869071833135764e-07",
+        "6.23e7, 9.0560125770105324e-09",
+        "2.34e8, 2.4110665963579326e-09",
+        "1.7976931348623157E308, 3.1384087339854447e-309",
+        // Negatives require accurate computation of exp(z^2)
+        "-0.123, 1.1554430105980469",
+        "-0.356, 1.5725451177335525",
+        "-0.598, 2.2910985922662546",
+        "-1.12, 6.6145770282875613",
+        "-2.54, 1267.2229816784452",
+        "-4.78, 16748041793.844347",
+        "-8.89, 4.2095426970353675e+34",
+        "-16.133, 2.1699859052022138e+113",
+        "-25.677, 4.3151823545771249e+286",
+    })
+    void testErfcx(double z, double expected) {
+        Assertions.assertEquals(expected, Erfcx.value(z), Math.ulp(expected));
+    }
+}
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_huge_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_huge_data.csv
new file mode 100755
index 0000000..fb1ff0e
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_huge_data.csv
@@ -0,0 +1,159 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {-50:5:-5} {-4:1:-1} {0,0,0} {1,1,1} {2,2,2} {3,3,3}
+# {4,4,4,4} {5,5,5,5} {6,6,6,6} {8:2:28}
+# An additional 10 positive test points generated in the range
+# [26.3, 27.3] where erfc(x) transitions to sub-normal.
+# Reference values from customized Boost C++ 128-bit implementation
+# of erfc modifed to remove scaling by exp(-x^2). Values for large x
+# generated using the upper_gamma_fraction(...) continued fraction
+# See: https://mathworld.wolfram.com/Erfc.html Eq.3
+
+# Partition: 100 <= z
+# z, erfcx(z)
+102.29952077160934,0.00551481206974884676446875286320606304
+103.50017201936511,0.00545084363111614798636261825463792064
+103.58396304142204,0.00544643475187555024591078495502437022
+105.4230044810421,0.00535143356841716843901531292236915805
+105.5609746650351,0.00534443977181417466332969500524315112
+106.42113607755707,0.00530124653443092598862333303403629019
+108.03229628904964,0.00522219220926894822590339118923021224
+108.16026285278699,0.00521601425786995434907993750413885907
+109.06091689498882,0.00517294266142791156920201386171246745
+109.14121820310775,0.00516913695730079816350658506310362864
+110.72131298270907,0.00509537468728679300565610449495526792
+113.26841264500692,0.00498080255000802037240193343782011139
+114.89406925601759,0.00491033366525260497335914091987985151
+115.63063949639751,0.00487905705603983364464237577891180739
+115.68588725972278,0.00487672715346130108939230992266420234
+117.18136887657732,0.00481449438195476545482630095240549111
+119.14209812058073,0.00473526756280483156886008696843067396
+120.38323500797867,0.00468645090105367705171643131620436972
+120.41023568103655,0.00468540008838105233260995906005558465
+126.88534637716943,0.00444631377660281965906859967330572902
+127.72124544528185,0.00441721571249154135488633281918770819
+277.00614398390172,0.00203672705291104777583204844776911297
+340.41023941371702,0.00165737420285223247808389825662612108
+353.60693843856711,0.00159552108901264796377973576891841113
+379.24468349357852,0.00148766125609616685305692882930632355
+389.67535179416376,0.00144784042205956146381612909598924147
+407.31665019254052,0.00138513336731049367042784898180518142
+455.26473141354859,0.00123925308419539458183963546878165528
+482.62337451604969,0.00116900341394750798114964738099450841
+486.77026438101694,0.00115904449037064664459835973344161781
+491.68385507128755,0.00114746174978904342735468544513088594
+1139.2998051302197,0.000495207112015481365513324664372789488
+1433.3824404997233,0.000393607058595642220192282045823871305
+1471.2658499694619,0.000383472132680202356089926679395278137
+1496.6721775606327,0.000376962614841793930739264081108515307
+1536.2975918474183,0.000367239698233429860653400719789006797
+1726.0550697923725,0.000326866447505449488076128110891920101
+1758.6148735991735,0.000320814693885077616602102952253879833
+1809.0879619294565,0.000311864049303789868356183099204901648
+1976.5423481793755,0.000285442662971467749121888067767341569
+2018.5584390666806,0.000279501204124545022599098887774946884
+4739.2536190637038,0.000119046081163227144232931266337319176
+5082.1008438065819,0.000111015029013672563225258479926713095
+5188.4834818492718,0.000108738820320539123015098528862024766
+5403.1147245551574,0.000104419321566658875168734509678447818
+5713.8075191740199,9.87414387015816107023827069759622627e-05
+5948.2910540726043,9.48490197346140614087319767193547019e-05
+5970.4037762536664,9.44977252422832637455927654346081355e-05
+7770.7716332808805,7.26040611539550605245329046399135673e-05
+7810.5121853103692,7.22346455056638593185054972008764896e-05
+8185.2763156086721,6.89273712435880705461739677780665729e-05
+19581.670153982923,2.88121277896874661118282250082911149e-05
+20037.453258640853,2.81567510383014817564208162346396787e-05
+20146.794005252967,2.80039386269425865617036323419710912e-05
+21431.503006601317,2.63252457263404852459373780282721936e-05
+24287.669407089441,2.32294656853677840407217995387341497e-05
+27106.067107807456,2.08141439671014442936845785790601098e-05
+28047.303276192953,2.01156445464062941751661656721181195e-05
+28385.407440818399,1.98760431525931806992901782528061484e-05
+29886.805942506533,1.88775469790005163573019478179647374e-05
+29990.650587052041,1.88121822031330501019607004076527426e-05
+77190.222301186426,7.30908095197621938022384568077022062e-06
+89335.328909363438,6.31541396220544530883900204608017677e-06
+91081.63525676656,6.19432865827733064419669562106847442e-06
+101242.60563416444,5.57264977512440217825430688792505877e-06
+103530.10912244421,5.44952177007922771623901997517984162e-06
+104403.99224313986,5.40390813991069447794678481395379382e-06
+105706.71533889914,5.33731070645512367510650608962594179e-06
+115364.41129843242,4.89049939384752598784246241725523099e-06
+116361.69848772249,4.84858497993178338934727597454595461e-06
+117118.53365675754,4.81725279434146824221389626139127164e-06
+271665.72421903361,2.07677867778803647892183351523232237e-06
+271759.52236399846,2.07606187498465386331894343244973872e-06
+297678.63213199947,1.8952975546272818880499498021351664e-06
+315979.37234896986,1.78552662900360446177056044195489041e-06
+326051.50593830482,1.73036950687128009044728065891789202e-06
+332993.38088532008,1.69429669155950599607751632894007725e-06
+415018.80050276598,1.35943138687366123147531096191239979e-06
+426529.9317765726,1.3227432391350738354296660824640935e-06
+482746.47927548533,1.16870781614666930654372002374874033e-06
+516880.31398914073,1.09152848014744396750194089057797564e-06
+1059209.3861929658,5.32651608739352043303009866262810562e-07
+1133722.7128613575,4.97643363008580157942924319735173813e-07
+1151374.3626665405,4.90014023102704172432780003390984138e-07
+1266208.1830454404,4.45574109456954357498054259951587121e-07
+1357833.9386943623,4.15507056842388961857257173201020832e-07
+1464312.3720177021,3.85293189027842368028381240550794653e-07
+1500856.3559666562,3.759117795015456950139062954746796e-07
+1509360.0328110782,3.73793906876458456821034395032160026e-07
+1524409.1405417032,3.70103778928502416542966270633565978e-07
+1912464.8100204759,2.95006517553459528096077550968056341e-07
+5024415.7790879123,1.12289589149041934311133813638135545e-07
+5125246.2141807666,1.10080483935917048718836614652012506e-07
+5713256.0590549754,9.87509710252807646402809022499712647e-08
+5926951.4444225589,9.5190518909795991480846486696600337e-08
+6140575.6485459208,9.18789403207414368718924577945385669e-08
+6596104.6970683821,8.55337520337574516811556372031919123e-08
+6830184.8159968369,8.26023890636712050727825397252616153e-08
+7078872.6608120194,7.97004848909137348314756865555869992e-08
+7209251.3192090699,7.82591088265249075151713977227422988e-08
+7367086.1002958054,7.65824609441034747738832102241065744e-08
+17624761.913898353,3.20111889342943458424340594727066084e-08
+17957221.519522592,3.1418534483989305851093079923083038e-08
+18141180.055494916,3.10999384726829768600415890001441599e-08
+19663499.951216184,2.86922259489649268994954856204952701e-08
+20692171.434352279,2.72658471508268894162623327416671699e-08
+22838238.660744186,2.47037257088271257763654876961291208e-08
+26663063.630145632,2.11599683882491011153978663312377024e-08
+28875588.205617409,1.95386351796636107873353648101166148e-08
+29568150.413109198,1.9080990040473396799050802009515722e-08
+33412711.471488684,1.68854773737588824079857928116266678e-08
+91652678.212598637,6.15573483012744505194656750874397817e-09
+94807486.122974336,5.95089698735338946824483891879896038e-09
+101027798.75890096,5.58449842992396078810552488232194346e-09
+104410097.81814973,5.40359213656135967836906453688661317e-09
+106012979.48931262,5.32189158596974764795536380640605032e-09
+109900863.10950324,5.13362286323090957206974730316356858e-09
+113461231.29450901,4.97253182528312994685439357809526469e-09
+129357503.00702265,4.36147552660418281363549378942755978e-09
+132102222.1981225,4.27085611551336035946608390038544025e-09
+133751299.85768679,4.21819888216459730570248619932708341e-09
+282301907.47873116,1.99853266521149087206134523544452874e-09
+313218660.54737842,1.80126427512902037718780992061343912e-09
+352524170.04437172,1.600428088311625642734514112934215e-09
+362334000.04366082,1.55709810141960761507898361114232302e-09
+366523529.04398936,1.53929976888344178486583270921817965e-09
+393425228.88426983,1.4340452572087556220701968336016726e-09
+402260897.92157298,1.40254642313694088408223377059129324e-09
+415139267.95592588,1.35903689941384836225377689997761622e-09
+505980644.87412769,1.11504182870099543235524982593930899e-09
+514459927.98514795,1.09666380772817739900071872594541172e-09
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_large_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_large_data.csv
new file mode 100644
index 0000000..7743234
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_large_data.csv
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {-50:5:-5} {-4:1:-1} {0,0,0} {1,1,1} {2,2,2} {3,3,3}
+# {4,4,4,4} {5,5,5,5} {6,6,6,6} {8:2:28}
+# An additional 10 positive test points generated in the range
+# [26.3, 27.3] where erfc(x) transitions to sub-normal.
+# Reference values from customized Boost C++ 128-bit implementation
+# of erfc modifed to remove scaling by exp(-x^2). Values for large x
+# generated using the upper_gamma_fraction(...) continued fraction
+# See: https://mathworld.wolfram.com/Erfc.html Eq.3
+
+# Partition: 26.543258454251 <= z < 100
+# z, erfcx(z)
+26.638996841318068,0.0211641941286655173237333756530385001
+26.665395677886622,0.0211432708800371606475671124785918002
+26.757684824163572,0.0210704479189366366060580029040079227
+26.792609444951747,0.0210430203862787776817226045568744046
+26.804291520090398,0.0210338619609048902190279047741083457
+26.98459575798271,0.0208935120127802952443515544131761013
+27.042941378198485,0.0208484953899785169469194074375236704
+27.203816475394714,0.0207253702596851540559060707781543383
+27.281073007488928,0.0206667573514917974020064073527607496
+27.527614135475186,0.0204819075622640307035314903811667482
+28.463288034374848,0.0198094481790991541815895502955444483
+28.682122800799682,0.0196584927431981345372846366302690007
+30.525527970485879,0.0184726479064930889995129092080744334
+30.816467058607969,0.0182984311786074862173599898435535892
+31.196230087640611,0.0180759074375795237193969332031324358
+31.258313936233517,0.0180400425745180749942845951991666287
+31.787415511927552,0.0177400649809823417868440106602623864
+31.9785714280858,0.0176341252746677782848769591183096988
+33.872931290848506,0.016648811362298210604539470983274692
+34.568696833634917,0.0163140027622348005229410719237411038
+36.027912418485279,0.0156537658654241473103186938385327772
+36.409585463395224,0.0154897953555483468804664507015505883
+36.494615332391682,0.0154537323077968432966392247880448893
+37.466423839032764,0.0150531804125790851037489937818248514
+37.946834676066835,0.0148627385600446807639337550749025234
+38.013280428513688,0.0148367770279814904076445094607248035
+39.64311035257677,0.014227194878956483675277452779951723
+41.722049698279015,0.0135186950680329985214371058068825493
+42.216057425538757,0.013360589926979159232645800975036797
+43.700844213691525,0.0129068899625899253270199227322293578
+44.414146385328053,0.0126997079232890973496068422216574319
+45.250862804266752,0.0124649980931872681081832746661643921
+46.261547188620483,0.0121928015417060147853829448699207321
+47.701216158257331,0.0118249750222242573511752747750097971
+49.936593255493932,0.0112958552056496851173043456703342997
+50.426976009490396,0.0111860507688423666591148849330460646
+51.499192621219045,0.0109532451101349737686717944598089769
+51.886424233199513,0.0108715308097207907054586333027944929
+51.987718361333684,0.0108503562938932911581105615981449568
+52.559536351046418,0.0107323534894855018212994349194409048
+54.386913053680907,0.0103718749863183851812016267816440431
+54.913933923880577,0.0102723670062366378970638928273964051
+54.9475055592779,0.0102660929089027455491317957760241891
+55.336491738329237,0.0101939513532942551483631647121552102
+55.449908312170059,0.01017310755090015206798201659628202
+55.761158739139489,0.0101163410892771994918009136597279359
+55.961190092515579,0.0100801921334864249402566879692865086
+56.554007508455776,0.00997456148186269040259370986625297748
+57.214530169173159,0.00985944385313044918255608884272362444
+58.383404781696328,0.00966210968441192073506591050043126268
+59.083580791727599,0.00954764083975635112221631461327882181
+59.909508022743232,0.00941605161561508800416923901742630717
+60.263716553316023,0.00936072271205046788844687400524686163
+60.713315325148457,0.00929142285260419114744684531672773525
+62.117879980747489,0.00908138694758041382525768292051390979
+63.124013405857056,0.00893667535080209446843239114616910782
+63.139078689222011,0.0089345435523275445842666783204096327
+63.288734380497303,0.00891342176347383642404383518522478185
+64.708702930667656,0.00871787273786597332243427271659940423
+65.907479934242815,0.00855934204317937844610817665863977933
+67.5044509003298,0.00835689633417936593912758864393350596
+71.612919340370169,0.00787755335964948186693697118184143052
+73.162997117766864,0.00771068600732085986723196883381092054
+73.799568263415253,0.00764418838931002793681600955668314932
+78.887199246601611,0.00715127765018923216087044224210891698
+80.182532816840819,0.00703576822910654124089439915760038194
+80.698215085319845,0.00699081479117667781680461360039119499
+81.45760093801951,0.00692565301053973173715216217166553855
+83.816895249953149,0.00673073651974288149775519433812503733
+85.312337793462035,0.00661276958561683153103047061639004994
+87.01728184303289,0.00648322176953571612514462354331391845
+87.039294980605234,0.00648158231211280642906075163561995817
+90.97934599262247,0.0062009184919173506723293302309300649
+93.73557536314442,0.00601860585849157887489833691707681158
+96.550422109012388,0.00584315754248279091507341122130140406
+96.823726739330922,0.00582666580513014872209283003461978158
+97.989131645496514,0.00575737532837414811106575398378782004
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_medium_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_medium_data.csv
new file mode 100644
index 0000000..db08dfc
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_medium_data.csv
@@ -0,0 +1,190 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {-50:5:-5} {-4:1:-1} {0,0,0} {1,1,1} {2,2,2} {3,3,3}
+# {4,4,4,4} {5,5,5,5} {6,6,6,6} {8:2:28}
+# An additional 10 positive test points generated in the range
+# [26.3, 27.3] where erfc(x) transitions to sub-normal.
+# Reference values from customized Boost C++ 128-bit implementation
+# of erfc modifed to remove scaling by exp(-x^2). Values for large x
+# generated using the upper_gamma_fraction(...) continued fraction
+# See: https://mathworld.wolfram.com/Erfc.html Eq.3
+
+# Partition: 0.5 <= z < 26.543258454251
+# z, erfcx(z)
+0.55076013518044176,0.590563844804729867935975631890725524
+0.62052732904945163,0.558753441276607331694083108946794091
+0.65087891040211709,0.545813875157277683982991118639274979
+0.71336092556618846,0.520736380860075302881875345303623381
+0.72616712792127935,0.515840461352696270543054194134601979
+0.76803744930339701,0.500374748722502611666050428655289063
+0.77700646313401278,0.497165936133298745207012948989335881
+0.81823064092249786,0.482866005240462472935690815232075576
+0.97958540214394363,0.433226105452136027881373682507131494
+0.99763469867113208,0.428230669601942390688582784959122958
+1.0607941526297278,0.411527127721945689792775248048715603
+1.0628883580866717,0.410993118648285277782779752152936242
+1.0855434360313514,0.405294067049825186168101759400936539
+1.0904038948451795,0.404089678895958094175848412480972224
+1.1389544572755494,0.392400835117188021747499452295310446
+1.1640256885706264,0.386598781460519379005101582575556033
+1.1802578729790929,0.382923619452590311041584604823173323
+1.1957458462633295,0.379474939611414941248338302499648295
+1.2413197201556581,0.369643628496787654229955228543216588
+1.3213988658807776,0.353439970925609611268732099963882754
+1.3807492493931359,0.342239176870456662824811714321845209
+1.3979646689308758,0.339110051413439292333051278885866338
+1.4284789392205259,0.333689841286429787514144746574145705
+1.5074317525603771,0.320373603834282849628978526761206882
+1.5381418591776743,0.315453519414275017630992313892629811
+1.5563878050406603,0.312595436131735741382572598215356841
+1.6143448240051026,0.303824595332539795751213832671123318
+1.7065761506368489,0.290766734481901861788252815613515796
+1.7116795703031733,0.290074461964199146985939173706608889
+1.7144757288993642,0.289696457674246206080553661206396307
+1.7885082275902064,0.280010005898308154951993658206287475
+1.793697215584324,0.27935358365716550747845173602252613
+1.7957583748971977,0.279093633029627812230133074571360764
+1.8006834097726212,0.278474309311692233443414600151216011
+1.8379884926627637,0.273864868804930780347096897193591505
+1.8388391554356451,0.273761415049112739141217724120378926
+1.8628683203662006,0.270868845802806250977282569564402852
+1.8766249592041646,0.269238339861624045526475259357412355
+1.9243403095262654,0.263722037792778249039159280001450107
+1.9784979437254471,0.257711501731140909151732036096351262
+2.0120352107757378,0.25411638651781723593774243603632109
+2.1410801253923579,0.241119487381056895219372748498560209
+2.1435199207229738,0.240885805089134000663084579439307395
+2.2456996798793463,0.231468371526763165329047245559068933
+2.2752851373245684,0.228870143074293397871691904535322929
+2.3360770027068241,0.223700823840549044275068805400515968
+2.3655738372441082,0.22127150797509688303079311834424433
+2.5213316275648916,0.209231684732351727432987927290322634
+2.5589857997322789,0.206506080920861508051620275326963479
+2.615752016674743,0.202522659665394969534946280743602149
+2.6506114484046748,0.200148369270437192254212212162281432
+2.7080347608399498,0.196351119320886046451890735414991578
+2.7113670089730157,0.196134991268185412715057252612339937
+2.7184327970885436,0.195678209217687496664184171945933267
+2.7324671187216651,0.194776940247529308379923392907995357
+2.8698277312967586,0.186358313611290372549674762947782812
+2.8891293674261802,0.185230988658846685955822218506485726
+3.0420748695427169,0.176741235592691019032811932273337279
+3.3028486118872755,0.163876558800900173331872683341347953
+3.4186409598129783,0.158727740125470695558224762726428405
+3.4543243727359396,0.15720363546712350255570253005060433
+3.5051620394971059,0.155080625384239588889720940081381842
+3.5259294263701229,0.154229280487532048098102067956774859
+3.6465854622319203,0.149457170516830552591485797026745968
+3.6915993751032397,0.147749497163286554669096794777498521
+3.8133943424770194,0.143313754018282921475824277230745374
+3.8485615582680981,0.142080814754014441326707741682893438
+3.8791092267731346,0.141026480358786421209866958585137834
+3.9112541370605163,0.139933354766282374731769912542487572
+3.9386318024797702,0.139015284132074819642389919473481174
+4.2117870707509484,0.13046064471479233588184355703033729
+4.2712963812676676,0.128731723958795083202399158814233356
+4.4066515359121192,0.124961436494451824079337715332260767
+4.6135526350842984,0.119598843646244749319974613107007483
+4.7428964880789337,0.116469899773471836081162739122715885
+5.0180240653409269,0.110321442428648427437177447024786075
+5.1871868587695751,0.10684822708754316276360347605624257
+5.2335751179856116,0.105933078132992942929024292910488743
+5.337660316529818,0.103934805044740065850332392160804072
+5.3804436982203416,0.103134800149014367022811669413781415
+5.5572281425607875,0.0999538820364398582831539465853118593
+5.8542928518078998,0.0950234397439907377146890969827126406
+5.9808824836913006,0.0930653694648542282303075627151801401
+6.0425371320367782,0.0921402830330321891667903236732699038
+6.1298723347413677,0.0908605475130461456351937247729494363
+6.2476077512616222,0.0891899472284453199883225971903391666
+6.2997549063540061,0.0884692594274336619592459811259911373
+6.3711747396802094,0.0875007025176548459247693833549037623
+6.6320390848000734,0.084134484488210224075825074331372783
+6.6595922388117899,0.0837938434906936267183717854013971546
+6.8088367930213387,0.0819951706459044233077378530232470431
+6.9210135261055177,0.0806927812742615244239533527402162327
+7.2836569121227264,0.0767493473638777765279722332752043095
+7.3259954362308237,0.0763137213963924515390934114107337581
+7.5635547049355738,0.0739576136494768153701502263391685528
+7.6856243177305039,0.0728021938265261671420420545628049427
+7.7825553527577691,0.0719099218931758464161758769600920663
+7.7961546523734224,0.071786470428949527255320837810676119
+7.8790583805829195,0.071042893626406970487886131819086172
+7.9522792530622457,0.0703987645603252883612932730533918436
+8.6170247697505733,0.0650415634967441272302684884820382088
+8.9422191026984095,0.0627054612029684381658947807010513905
+9.0493795162651178,0.0619717720608140950963079138358633044
+9.2687820749465111,0.0605216209662410933090700531194247829
+10.147235214960496,0.0553341739769621057633331407463519862
+10.571059970042631,0.0531354789665885044424226150308629074
+10.822976516307712,0.051909151981855271970106226999592392
+11.01859375670111,0.0509950931682547312860324159652261861
+11.174118247717292,0.0502909412368450476717395207473790631
+11.362970587169238,0.0494615104552453726702127701197421253
+11.406282930682051,0.0492751126881517560206106927247229413
+11.958198256743131,0.0470168832979151829077462167149114016
+12.325777152959697,0.0456239642193380883746052133514983264
+12.657867335945133,0.0444344332507500200057273408425354723
+12.920440327408498,0.0435368075901386558704736840988710366
+13.599244463681334,0.0413755673404412278414950584859350869
+13.734089492140344,0.0409714667515230751976030263124657427
+13.856758206308093,0.0406106346505880541679214399157246857
+13.893913834000395,0.0405025883300019147172705149917292127
+14.04190868068345,0.0400778600454727886642875590186945478
+14.23628793286202,0.0395333308486032857980749355888447717
+14.419538350699847,0.0390333251434137622330468107570882206
+14.596889226128184,0.0385612872122509138398760148801201823
+14.756408364726303,0.0381463364155132232614753665267407398
+15.076324728499975,0.0373404395957619245895857296323151422
+15.169300165939095,0.0371125601096022378208417652254744821
+15.174210914590237,0.0371006011827471148469853808375399995
+15.324884593582697,0.0367373739127383954268656113459909676
+15.338681123717672,0.0367044691539919316310867801262711081
+15.498722934595913,0.0363270237599851031808189920965107399
+16.030319290251523,0.03512707085743264466849354716937833
+16.243224346815804,0.034668389341454326468023404199714996
+16.384957002009049,0.034369613431328046969858122955653847
+16.990080805787244,0.033149775921893896580760882831946275
+17.109000300719437,0.0329201450487702480841027430228142701
+17.610619536466746,0.0319854935483855471056326759997100959
+17.617282763638393,0.0319734346365190390823361056043347082
+17.685984915049477,0.0318496268210535850432462199153292635
+17.87700068777097,0.0315103757751525210709946237483961635
+18.307820811031515,0.0307710948779488457870300074727223938
+19.146680992853973,0.029426677764260666554860244341845984
+19.424124176213024,0.0290074784112606675301276733105739373
+19.548373441630105,0.0288235880323518170959507738653839633
+20.269812984778145,0.0278002312329040578266238912065002843
+21.232117526485741,0.0265430846737062556035017715025548501
+21.458739739865905,0.0262633762092144730374347766001433944
+21.508189471825215,0.0262031237476389923252663417971666377
+22.389136616216938,0.0251741955277826898134871742683261128
+23.234983897552912,0.0242594745184921319118611355509203041
+23.404143580315768,0.0240844525143627815661619135704578663
+23.448237929584103,0.0240392438436899061569684360270428023
+23.513419812676538,0.0239727244719850404974853923886094863
+23.906931217012033,0.0235788232164083801856053672073901876
+24.004495992227199,0.0234831544974820671383979048723088595
+24.078974296266843,0.0234106440471686334645654484457097512
+24.663815152601906,0.0228564388321371636642864706188166249
+25.821901496471639,0.0218329179055966099102936140958899594
+26.131176424203982,0.0215748942075844803211760024187652612
+26.217524672162412,0.0215039397830971488603543531755191839
+26.355760605591225,0.0213913138594155476533753741164470767
+26.512467411235665,0.0212650563420644336261934656588047595
+26.514986898742361,0.0212630385736684332038245010707738611
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_data.csv
new file mode 100644
index 0000000..9722731
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_data.csv
@@ -0,0 +1,224 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {} and 26.6287357137515 <= z < 0
+# z, erfcx(z)
+-26.354320001254131,8.7164924746528685393603705422769335e+301
+-25.602784805010248,9.59815163499523666432954593143597072e+284
+-24.951371122174105,4.78790501150267769326999114578951219e+270
+-24.717599283268555,4.3397288333962358898688486641947493e+265
+-24.257319513369371,7.0392275473966818085713725969000719e+255
+-24.114960828798772,7.19250506435620823842652504598565395e+252
+-23.379006385757258,4.75130694373242465461730809051757023e+237
+-23.086141769762392,5.84702223799405327407293729788818949e+231
+-21.896048733419622,3.29497300131232109350332976163294294e+208
+-21.808169691267835,7.07723508645853759883224654264220309e+206
+-20.630063750521732,1.36948578128289609132770617298295359e+185
+-20.524976736881865,1.81256906562168955560324165805578287e+183
+-19.850066622023085,2.65445982256592787324619798290357638e+171
+-19.808848045422167,5.17656784351765510089356354527927673e+170
+-19.23586487666914,9.95455121352968557993747816239907148e+160
+-18.823504828466572,1.52101349665959996573231971168388956e+154
+-18.653075771844005,2.56006817401851846194170891880038231e+151
+-18.492800739334527,6.64744521178184892777587208113911191e+148
+-18.478853052279085,3.96919595978231988593464344962918341e+148
+-17.926950018112745,7.4585140569608445378868362176362497e+139
+-17.859589898926146,6.69496469108703274324793279514953594e+138
+-17.375746254685239,2.64073663210036219789153002488403053e+131
+-17.298709859528056,1.82658462044300368996853647669313752e+130
+-16.670218009699227,9.76792943003489911120443760993524828e+120
+-16.035362466105859,9.38442384981449351846669385559877968e+111
+-15.952707809371907,6.67035713792123039065313046649121503e+110
+-15.894488831891287,1.04452493911114283644431192574050367e+110
+-14.880553504413646,2.93248694836098211978173881604761557e+96
+-14.737908755923831,4.28921158811351311170247500796058222e+94
+-14.094992258209791,3.81765340533157399286310407019144242e+86
+-13.839545314620327,3.03921414626993129542230961854551633e+83
+-12.158128878546306,3.15124954862340860155511058455737602e+64
+-11.985028575296656,4.8248582957659725388345355519997827e+62
+-8.7931880396503246,7598835504086874310060194235875831
+-8.26897425987441,991565473114127928087760830169.060913
+-7.9364272233839817,4527757309734905032120769328.39973354
+-6.9343701866919698,1528596682851050242746.46805813208471
+-5.5845037087088709,70021878079780.9726578712123349328568
+-5.3730450024236882,6901499195423.57617709674466950849977
+-5.1321717621494276,549532732477.366877497632574125873204
+-5.0537499647038855,247217879083.485947838467967407183285
+-4.9995344536629807,143340955566.421315746293514754776837
+-4.5643383149582846,2232374008.37056637425520615412857949
+-4.5241156874135617,1548836643.64161501701338908559468659
+-4.3258964299716673,268007923.390227686916135584442599354
+-3.7501196240808912,2562629.19486357264466643764204737452
+-3.4072520456327835,220248.770197853076137221395337048447
+-3.3829282740590614,186717.121181922005947923907281874728
+-3.3056997613918226,111390.421853656505030140770484007164
+-2.9020097701268797,9088.7038686634519511020956865039776
+-2.6671634226970347,2457.32074812912579671217279765033314
+-2.3408769039636841,479.328470293785162201020363356014628
+-2.3223517992287923,439.638919121646110232109834916074487
+-2.297179405775692,391.349323278939249905176751310065742
+-2.0271516501453175,121.560949963262890438313467495415501
+-1.945930918968156,87.9552318439909060426611138565747565
+-1.8546325275229476,62.080971983588083841875581456903173
+-1.6995061553090087,35.6345237099509022482158528300576626
+-1.6874204217646323,34.1919664620713191779938464977004667
+-1.5919669368148412,24.9095288472223203349602740314725289
+-1.5395132110908716,21.0817069469802973950015962768256284
+-1.4480395156384798,15.950162398960309399409816381395009
+-1.229677901589775,8.7004529255688991689762903563225578
+-1.1051512925983979,6.38311656637990901089912254040599217
+-1.0286440409318671,5.34195101807134045926686236523113382
+-0.96855515181201302,4.67390962593064647809953800682954059
+-0.84950043034895095,3.64316656424141516053151348585454157
+-0.83068677029232729,3.50890733748378312102922384925255015
+-0.82466092629878363,3.46731476066496900911616242251324697
+-0.82172094507447579,3.44726295630144034525054131933620765
+-0.72121259203927446,2.84682670774651943625758010260224525
+-0.69663518300320715,2.72207409124760502808522776284394546
+-0.65411145376679269,2.52348214847973227468047691007138653
+-0.58044548543370633,2.22458375134394586205229999877298678
+-0.54031245946590134,2.08244645200826633016677902593499107
+-0.49810895660654636,1.94654714524031431141631835074933967
+-0.47714075194912853,1.88372445239178992447299630001197327
+-0.44344996669054459,1.78875710571884157119556712649470668
+-0.44077650476855079,1.78152045543239406567913115168133043
+-0.43969305924314167,1.77859984603419096940988038181893314
+-0.3846524160765738,1.63895422536005643137110992969159711
+-0.36620367604116477,1.59573255681351016011415177785869915
+-0.34909449825114397,1.55713380962637972095537406192192395
+-0.33706097484284042,1.53080689505478445657344224273457902
+-0.30103649929409221,1.45582509163787511690608021456982859
+-0.24896070632193912,1.35676559251725250207021945837355577
+-0.24229621793719963,1.34482300945309098290628748980721443
+-0.22707780528048166,1.31813938021535540734358791020285278
+-0.22102126887079779,1.30774204827025502706813892531667737
+-0.21939622405165579,1.30497342302745790562505741937325972
+-0.20319813338659917,1.27785512453922754715560677411345206
+-0.19333047640636711,1.26175200788435204180514389710103795
+-0.18570855269370373,1.24952396679921245890130216042394119
+-0.17679288032334878,1.23544794176886089143770148194843369
+-0.16285234824254491,1.21391859305585054205037601106804608
+-0.11516226882286781,1.1444524386284784280473436853734682
+-0.11158484882359844,1.13948941190873768169529747831249708
+-0.11057918894409124,1.13810021486679835280268700755567214
+-0.10660773229359105,1.13263958293942487462337141087054416
+-0.098039901360968587,1.12099595883737931046659347579335258
+-0.097325694275057259,1.12003371526583416041383483484337983
+-0.089254253400526395,1.10924735856882694468172869938268436
+-0.082118933514693224,1.09984530308677436133711384167231156
+-0.081993155604819692,1.09968067696239702726593622928260647
+-0.076914822849206282,1.09306560828373134553499264232905839
+-0.0585174061028031,1.06961092171142846590028020413683924
+-0.056510017035996549,1.0670991359028328235276624630144921
+-0.055575842048012067,1.06593335957928661351029398623267093
+-0.050376094557346748,1.05948057651316601190959069584982948
+-0.049840112275043619,1.05881889395636354924183603934175015
+-0.041833285114898477,1.04901047376947564476914739053410372
+-0.038656069487083299,1.04515759090417841949025044935645626
+-0.034671297172907442,1.04035655880172860038735139171430306
+-0.033505411360789397,1.03895835876265547461960517211097507
+-0.031783273590213552,1.03689843278947878541002985590480231
+-0.0019185910235513721,1.00216858445209794923189595074821374
+-0.0018384910828499357,1.00207789976660143895814628705222452
+-0.0016695988165623106,1.00188673158717874241472525949381525
+-0.0013148471943809797,1.00148537671666822293778681499072944
+-0.0013000354298222335,1.00146862464188006915448267579461353
+-0.0012930324160554019,1.00146070440115153811987854021236535
+-0.0012208184635366384,1.00137903788862039940655272410602939
+-0.0011486215601484151,1.00129740111168090710653001840405085
+-0.0010902319265832562,1.00123138457443069697415171089066879
+-0.0010626079789757719,1.0012001547451950062853494847176957
+-5.9471673705783781e-05,1.00006711013468012000791856155577369
+-5.4968725380536947e-05,1.0000620285862469094440743618464594
+-5.2293359872585943e-05,1.00005900947256071796863492941559647
+-4.6949812708258208e-05,1.00005297939492180169333451341997214
+-4.6010938186391688e-05,1.00005191990118775232158173734797876
+-4.5161053582992898e-05,1.00005096083161718382189775615459861
+-4.3295773679352915e-05,1.00004885592362813636780811082742956
+-3.5261077560992663e-05,1.00003978910870573469550498919799424
+-3.3394319722376049e-05,1.00003768256988266069449807551121501
+-3.1132098805295345e-05,1.00003512978095012892993141080891956
+-1.8269773671121969e-06,1.00000206152653765530057984986351149
+-1.777308151121805e-06,1.00000200548065006337502938763649984
+-1.6680119418514851e-06,1.00000188215270791907659702782722484
+-1.6310236250373391e-06,1.0000018404157397740656807787510825
+-1.5052246291208291e-06,1.00000169846637900276258256161511714
+-1.4926257953304034e-06,1.00000168425007965446408840583402719
+-1.259087464229756e-06,1.00000142072964949071714311910558436
+-1.2280373694014103e-06,1.00000138569329212450139883831322078
+-9.955650885463581e-07,1.00000112337589655389759713548046573
+-9.7258921268477537e-07,1.00000109745035166579587099579392164
+-5.6534860854663627e-08,1.00000006379276239923666925753268726
+-5.4990508537426187e-08,1.00000006205014724557578837727745694
+-5.4141300608083257e-08,1.00000006109191861689730452275417153
+-5.3806633977442245e-08,1.0000000607142877268333639175139786
+-5.334304542138311e-08,1.00000006019118400839897789731401629
+-4.9830138917996131e-08,1.00000005622729313158499840709319279
+-4.7159411329586642e-08,1.0000000532136995008038100007968121
+-4.2817291154459233e-08,1.00000004831414116347524813276693574
+-3.4579654378482913e-08,1.00000003901896280179577192106634047
+-3.2374303273838893e-08,1.00000003653049041152739372359922667
+-1.8553193093353633e-09,1.00000000209350366040626858536538953
+-1.8316782140403828e-09,1.00000000206682754090092828513222194
+-1.831237742165301e-09,1.00000000206633052161178103397156855
+-1.7479525745407764e-09,1.00000000197235327323811628525768879
+-1.6129548262003102e-09,1.00000000182002462595221653059413353
+-1.4989929210155286e-09,1.00000000169143238594455140167918619
+-1.4290361268023183e-09,1.00000000161249459655274142556045085
+-1.305065080160998e-09,1.00000000147260824986070015581168417
+-1.2061051127904448e-09,1.00000000136094388405481090150361155
+-1.0211922746974713e-09,1.00000000115229208941033817644573668
+-5.4251940842648291e-11,1.00000000006121675982428577225265695
+-5.3501520526789923e-11,1.0000000000603700011732250947121286
+-5.2123988242707915e-11,1.00000000005881562244171995751408285
+-5.0475833543026871e-11,1.00000000005695587901428020580501729
+-3.9508555523154153e-11,1.00000000004458063097592442215968676
+-3.4979841178408127e-11,1.0000000000394705240552490652427104
+-3.4410685478634822e-11,1.00000000003882830062075170507388084
+-3.3285210191298981e-11,1.00000000003755833775336491574844668
+-3.303493510154625e-11,1.00000000003727593255602837610665762
+-3.1472565945961987e-11,1.00000000003551298774945370245651392
+-1.8105854370821953e-12,1.00000000000204302688745335032385956
+-1.7787148366287605e-12,1.00000000000200706476585875529177817
+-1.7329925952500936e-12,1.0000000000019554727412139946295637
+-1.6435752897681218e-12,1.0000000000018545761165300203731797
+-1.4765757716973456e-12,1.00000000000166613733942344487113318
+-1.2141266144826351e-12,1.0000000000013699951779998843482096
+-1.131690664434479e-12,1.00000000000127697616934562531641405
+-1.0612546721218251e-12,1.00000000000119749766300617253091687
+-1.031133347255196e-12,1.00000000000116350938754128923737825
+-9.5336179401372735e-13,1.00000000000107575358707080218849031
+-5.5725599358780689e-14,1.00000000000006287960539036228887515
+-4.9778127964080039e-14,1.00000000000005616860257168495510272
+-4.5767013505456685e-14,1.00000000000005164254457973838395165
+-4.0331402848316175e-14,1.00000000000004550911475377821547173
+-3.9219553256102797e-14,1.00000000000004425452683698091089095
+-3.8632836657845317e-14,1.00000000000004359248805051797698162
+-3.5799102157158126e-14,1.00000000000004039496107486253493246
+-3.544302299452895e-14,1.00000000000003999316876591493262104
+-3.4876113326451448e-14,1.00000000000003935347970683120729958
+-3.4726278789319185e-14,1.00000000000003918440953661975240075
+-1.755079319399133e-15,1.00000000000000198039494061015582333
+-1.7331897175580368e-15,1.00000000000000195569516991664726561
+-1.3972215628622559e-15,1.00000000000000157659570335040467265
+-1.3708735849418342e-15,1.000000000000001546865193969908165
+-1.3427539721852414e-15,1.00000000000000151513560874857554504
+-1.3051603897449493e-15,1.00000000000000147271579350646211909
+-1.0312853161576353e-15,1.00000000000000116368086608378597178
+-9.9546619144414782e-16,1.00000000000000112326331197349057014
+-9.3117572348745729e-16,1.00000000000000105071928728833924528
+-9.1243191510682179e-16,1.00000000000000102956916439959984418
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_medium_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_medium_data.csv
new file mode 100755
index 0000000..5822867
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_medium_data.csv
@@ -0,0 +1,188 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {-50:5:-5} {-4:1:-1} {0,0,0} {1,1,1} {2,2,2} {3,3,3}
+# {4,4,4,4} {5,5,5,5} {6,6,6,6} {8:2:28}
+# An additional 10 positive test points generated in the range
+# [26.3, 27.3] where erfc(x) transitions to sub-normal.
+# Reference values from customized Boost C++ 128-bit implementation
+# of erfc modifed to remove scaling by exp(-x^2). Values for large x
+# generated using the upper_gamma_fraction(...) continued fraction
+# See: https://mathworld.wolfram.com/Erfc.html Eq.3
+
+# Partition: z < -0.5
+# z, erfcx(z)
+-26.512467411235665,3.72706868444272439178148793455920185e+305
+-26.217524672162412,6.56261665512711471665257448711949528e+298
+-26.131176424203982,7.14448669173468457991853641410719605e+296
+-25.821901496471639,7.51313031695515914758800947322264222e+289
+-24.663815152601906,3.04792341698378030044858745202678397e+264
+-24.078974296266843,1.26960636846880185676293421382289851e+252
+-24.004495992227199,3.53495925423982273317707952780761014e+250
+-23.906931217012033,3.29829059576827169826194647843572168e+248
+-23.513419812676538,2.5951287996394305122495982708111464e+240
+-23.448237929584103,1.21551998613921203402144526092896131e+239
+-23.404143580315768,1.54007601564051063243435346887857847e+238
+-23.234983897552912,5.77023114492318378070542389696532056e+234
+-22.389136616216938,1.00303993875486952609229964169845215e+218
+-21.508189471825215,1.60923328438737387623309638123721339e+201
+-21.458739739865905,1.92252572832330706865408246241080733e+200
+-21.232117526485741,1.20838361626085051307722466528642972e+196
+-20.269812984778145,5.46475377380758116543030470640019453e+178
+-19.548373441630105,1.82745804900516452677385739350771618e+166
+-19.424124176213024,1.44165526422985285610165904441024924e+164
+-19.146680992853973,3.2462823088776987009127120276560746e+159
+-18.307820811031515,7.34934758443083330901305116938314488e+145
+-17.87700068777097,1.24728955989547025477307935431202884e+139
+-17.685984915049477,1.39883108520681909630850296467463973e+136
+-17.617282763638393,1.23715155037232209063164824500233811e+135
+-17.610619536466746,9.78318580115360943825289201602955979e+134
+-17.109000300719437,2.67174458145885970717695561020345656e+127
+-16.990080805787244,4.63138677868085016003599955451966742e+125
+-16.384957002009049,7.84669442643328227737145887965594532e+116
+-16.243224346815804,7.69663915521290183520538810000320532e+114
+-16.030319290251523,7.98319259193707000257782034313125511e+111
+-15.498722934595913,4.19842776084022232384732452870103347e+104
+-15.338681123717672,3.01803606505729745555375022121358824e+102
+-15.324884593582697,1.9769504918091438606854527158152932e+102
+-15.174210914590237,1.99633851783896044461230860075962442e+100
+-15.169300165939095,1.71996751757330546671089073810337807e+100
+-15.076324728499975,1.03333381952325521680177063931303038e+99
+-14.756408364726303,7.40189660751419947875162745710219096e+94
+-14.596889226128184,6.85167881662185162863925675255031989e+92
+-14.419538350699847,3.98913756493667082429236208000150024e+90
+-14.23628793286202,2.09081324856354151242458664524442507e+88
+-14.04190868068345,8.57296521960398614362578431823961661e+85
+-13.893913834000395,1.37278427595114831296060129106441128e+84
+-13.856758206308093,4.89557849668622712400479134691772257e+83
+-13.734089492140344,1.65927993334591701374270075535712289e+82
+-13.599244463681334,4.16114269979291317907512233991652809e+80
+-12.920440327408498,6.32682631957608098687344235396482336e+72
+-12.657867335945133,7.66282916581185547235683179978058235e+69
+-12.325777152959697,1.9104015725655788930732807783738175e+66
+-11.958198256743131,2.53800150557091923391824056655903414e+62
+-11.406282930682051,6.37046374063664721993042699362740422e+56
+-11.362970587169238,2.37615239265542022900083329668452167e+56
+-11.174118247717292,3.3685108850944781136082983955287785e+54
+-11.01859375670111,1.06774145413558981504004422598172981e+53
+-10.822976516307712,1.48903477854728201423797096794399947e+51
+-10.571059970042631,6.79625419740248317135572851895107497e+48
+-10.147235214960496,1.04414722910274911266925606487670403e+45
+-9.2687820749465111,4.087035508205876477261820151855582e+37
+-9.0493795162651178,734440321024638371491812030047755520
+-8.9422191026984095,106817480948031447417677387538367840
+-8.6170247697505733,353792390377299460152008325040440.25
+-7.9522792530622457,5824627147585714054122006446.13316727
+-7.8790583805829195,1827430047769074211564610047.34696174
+-7.7961546523734224,498265123778045301717080359.312659323
+-7.7825553527577691,403135513593323125553096701.533722162
+-7.6856243177305039,90010479459733814210154347.5755294114
+-7.5635547049355738,13991705968759587602076840.4186848961
+-7.3259954362308237,407104276140163367594802.054074391839
+-7.2836569121227264,219317015220367762038647.783166919486
+-6.9210135261055177,1270344922633264478822.34063682787132
+-6.8088367930213387,272291717029153840531.576029079396079
+-6.6595922388117899,36480734302483713190.6522966920283153
+-6.6320390848000734,25293765159582922697.7589892718626174
+-6.3711747396802094,850852126592471769.99798701415063984
+-6.2997549063540061,344220577580577651.79235173457844188
+-6.2476077512616222,178926194444466643.824924049830566164
+-6.1298723347413677,41666840718807493.846928761183548387
+-6.0425371320367782,14391327636495475.7520223707850115756
+-5.9808824836913006,6857384284401566.22144033432525498262
+-5.8542928518078998,1532829816536126.06117876603565769716
+-5.5572281425607875,51671723264671.2653691362448735350485
+-5.3804436982203416,7473029364480.459432880130764527377
+-5.337660316529818,4724414884401.63104002966449976737568
+-5.2335751179856116,1572135018939.69962277171212719801886
+-5.1871868587695751,969508121266.46794746534495302401947
+-5.0180240653409269,172508560953.100722079315654588912368
+-4.7428964880789337,11762875645.2421970645344840871114571
+-4.6135526350842984,3506958930.16560520421120201607888165
+-4.4066515359121192,542514265.717306072557318734377884344
+-4.2712963812676676,167604895.736201241853746572347923766
+-4.2117870707509484,101168450.131297280176631015985920445
+-3.9386318024797702,10918483.4816794255794507964424856196
+-3.9112541370605163,8806988.30040545215281909639742389279
+-3.8791092267731346,6856005.58055924113925953312445805067
+-3.8485615582680981,5414403.21151798989239940912693577284
+-3.8133943424770194,4135519.68100396042375523486737779228
+-3.6915993751032397,1657884.64539002543201667350192804173
+-3.6465854622319203,1191510.73899641802532435688146016372
+-3.5259294263701229,501483.102930368645600475528856724681
+-3.5051620394971059,433352.925671362502352985008772803892
+-3.4543243727359396,304219.127810767749467040290387046568
+-3.4186409598129783,238053.930541776187905568257752322868
+-3.3028486118872755,109311.25413669374064212916945630867
+-3.0420748695427169,20896.9445762986825900111985417195257
+-2.8891293674261802,8435.41103749697379598544597882287347
+-2.8698277312967586,7547.96823681187000107430087671002884
+-2.7324671187216651,3496.32616125221372052002303623457499
+-2.7184327970885436,3238.81771079261820396157632388274032
+-2.7113670089730157,3116.90348012250448340438574999184801
+-2.7080347608399498,3061.1174405189106835506975087286862
+-2.6506114484046748,2250.25605336804008460654346309248616
+-2.615752016674743,1872.81450458697621129938151395878599
+-2.5589857997322789,1396.05767068695059447710441487113362
+-2.5213316275648916,1152.94970469537718806399305711701062
+-2.3655738372441082,538.439905958306624954084699921339579
+-2.3360770027068241,468.682590468469170136596833172617014
+-2.2752851373245684,354.044779710065959531171826877043075
+-2.2456996798793463,309.688541890376427293583468924309287
+-2.1435199207229738,197.671578030089270946001873157178133
+-2.1410801253923579,195.613233091873432346366043784247753
+-2.0120352107757378,114.344172153267159842910917424034219
+-1.9784979437254471,99.9856950419383125132214263715981438
+-1.9243403095262654,80.880882759409465754164692131614491
+-1.8766249592041646,67.4160207879344028032865140450398505
+-1.8628683203662006,64.0205109243595902810351015402779911
+-1.8388391554356451,58.5459260749665525951090113243447684
+-1.8379884926627637,58.3621373179015149630448858848425464
+-1.8006834097726212,50.9147877402220012251985042829761533
+-1.7957583748971977,50.0153859666472654798037132711384379
+-1.793697215584324,49.6443984294084010495403124572922075
+-1.7885082275902064,48.7243297540209211512034022394255035
+-1.7144757288993642,37.5203257610804570694519124459357434
+-1.7116795703031733,37.1594544945226843222537412146284788
+-1.7065761506368489,36.511128268025299107874422260997152
+-1.6143448240051026,26.7886606267151027225508759613758337
+-1.5563878050406603,22.2318830672154019894607737421348465
+-1.5381418591776743,20.991373943404360469668108082725723
+-1.5074317525603771,19.0839841860215004207018096575020583
+-1.4284789392205259,15.0560225608644123422543657265676063
+-1.3979646689308758,13.7789156033549125115450001010794294
+-1.3807492493931359,13.1163253374207663715153309448300922
+-1.3213988658807776,11.1109091451182966103085406883807689
+-1.2413197201556581,8.96770022878378420042690342477768517
+-1.1957458462633295,7.97632005447338770480532445559263202
+-1.1802578729790929,7.67097139621260784344422639600581827
+-1.1640256885706264,7.36658046202805459170521712911781295
+-1.1389544572755494,6.92579945916722461043461057827331535
+-1.0904038948451795,6.16337480334522002054045393779775052
+-1.0855434360313514,6.0930782453808443369540666617474556
+-1.0628883580866717,5.77865873842780465304449536807447389
+-1.0607941526297278,5.75065782525853698649098823915487125
+-0.99763469867113208,4.98270577258088174003341665683582279
+-0.97958540214394363,4.78801294990148631945615542913648491
+-0.81823064092249786,3.4236602850059528178636158282236321
+-0.77700646313401278,3.16072313429650469728386834881952707
+-0.76803744930339701,3.10717464704435792539737999373480333
+-0.72616712792127935,2.8729256569451055084200945154385338
+-0.71336092556618846,2.80613052067007798136513102648283129
+-0.65087891040211709,2.50921955877041784648640900673805545
+-0.62052732904945163,2.3806344124620575103754438508601086
+-0.55076013518044176,2.11817703537891150286453724232622494
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_small_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_small_data.csv
new file mode 100755
index 0000000..c7d5a4a
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_neg_small_data.csv
@@ -0,0 +1,158 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {-50:5:-5} {-4:1:-1} {0,0,0} {1,1,1} {2,2,2} {3,3,3}
+# {4,4,4,4} {5,5,5,5} {6,6,6,6} {8:2:28}
+# An additional 10 positive test points generated in the range
+# [26.3, 27.3] where erfc(x) transitions to sub-normal.
+# Reference values from customized Boost C++ 128-bit implementation
+# of erfc modifed to remove scaling by exp(-x^2). Values for large x
+# generated using the upper_gamma_fraction(...) continued fraction
+# See: https://mathworld.wolfram.com/Erfc.html Eq.3
+
+# Partition: -0.5 <= z < 0
+# z, erfcx(z)
+-0.44339406809384158,1.78860536000923833195625207771381162
+-0.44151642826440357,1.78351905076719116034253116995759595
+-0.42802139246552195,1.74757377820787398658912903910977675
+-0.37158200250016749,1.60815796377019518453493384903523545
+-0.36869368606454545,1.60146751463217470001512924645329972
+-0.36269830551500243,1.58771020403182071610426962483668119
+-0.31904908307003327,1.49261691331463007631645203065649092
+-0.31495598275489722,1.48413593027536219973214657998983671
+-0.29428656549804993,1.44238549514402540674571850352912335
+-0.27842971541905986,1.41153351925458144518219653299761961
+-0.24783561853006128,1.35473828339329098446567793606213407
+-0.22920854202483132,1.3218269827793603261644042700776115
+-0.21082223745238751,1.29051164659268068831500155463246637
+-0.20315239753032366,1.27777976918355801488765158352035725
+-0.19498190333012316,1.26442542466967472533156329157873913
+-0.18231488553503583,1.24413738882912666300018692881582074
+-0.17381854594563056,1.23080581166425063078979026700961229
+-0.16918701508014028,1.22363006301024604499232355548166927
+-0.16306126820866274,1.21423700038407948119513821798978951
+-0.12696236352166745,1.16106125155739316512868590846618232
+-0.12329818805344439,1.15586435466849487238899728747386601
+-0.11286853951408039,1.14126647776972523008928942593837565
+-0.10900321071033534,1.13592844128458741402839842077024861
+-0.10793159816244537,1.13445535765287138183089168697984881
+-0.098482859484223431,1.12159339379056837785922775543744024
+-0.095814414502602238,1.11800178933886895634780353594278655
+-0.094710738081586698,1.11652148793554021749851256194664123
+-0.08362350238360583,1.10181754321721509712290456337256772
+-0.076391313805872912,1.09238719245336763447147472287868562
+-0.071509116119581842,1.08609168360966920918213226777468007
+-0.060960185959534799,1.07267992810896872223921633254863347
+-0.060276548898484723,1.07181965610486262686667698924853726
+-0.054366711972479637,1.0644274024687843143046902604085695
+-0.052088988030571284,1.06159950802474989951004136946986623
+-0.04708598449631541,1.05542899372590037663706597040968175
+-0.046452549983506057,1.05465172766346561634240531451699375
+-0.045405708030174484,1.05336913801761751605858147332116526
+-0.041268320505285373,1.04832374507906971006141209571609457
+-0.032132709185194161,1.03731589193321356745281499135854962
+-0.031973370147413402,1.03712550228615101856836342857233527
+-0.0019129907261118428,1.00216224368867470137744137732195405
+-0.001668132561107837,1.00188507219187389421519041772407783
+-0.001613366949139244,1.00182309576969194919428969430662342
+-0.0015757736604611334,1.00178055617960997127634996023328052
+-0.0015319489600986644,1.00173096886656217415198464979765967
+-0.0014193323188994612,1.00160356167697331679053409075065633
+-0.0012859311710498368,1.0014526731636968743690152650236767
+-0.0011600175307826647,1.00131028643102005501213287462731092
+-0.0011550491574421628,1.00130466870489388344995635257296528
+-0.001031024069980071,1.00116444991699894584762523373537121
+-5.9214995792548157e-05,1.00006682047420388467421413106378568
+-4.8319169421578027e-05,1.00005452467897366723349667081368159
+-4.5225776013328447e-05,1.00005103386890957186562218590164463
+-4.1610928639888013e-05,1.00004695463652432976338791901384992
+-4.0337749351856421e-05,1.00004551790319955345226107426219964
+-3.8865175848419506e-05,1.00004385616529891679602076395892638
+-3.7889625755461427e-05,1.00004275530001616814116593735445197
+-3.5853733531950029e-05,1.00004045789150492627735635720148
+-3.4233643453352445e-05,1.00003862970205906362981128342512803
+-3.3736643558676114e-05,1.0000380688639493411993203377969681
+-1.7879828998727808e-06,1.00000201752585222661777968839790972
+-1.7534905820760669e-06,1.00000197860531724609511088316913501
+-1.6745173878524748e-06,1.0000018894933394039432248917328281
+-1.5995529991920228e-06,1.00000180490483952629961847488115008
+-1.5404200081015417e-06,1.00000173818021861543142393667443693
+-1.402391679373127e-06,1.00000158243152181722333815739647969
+-1.3723189328671733e-06,1.00000154849797771926131119845616751
+-1.3536183688504579e-06,1.00000152739659989322024598326669269
+-1.3452503784317747e-06,1.00000151795431125018102998041834112
+-1.2677395125524943e-06,1.00000143049246243305901507533363145
+-5.8427083734669713e-08,1.00000006592790749407064494899476296
+-5.7298657952752455e-08,1.00000006465461521955382770498755236
+-5.7024573898052173e-08,1.00000006434534445086278496164521842
+-5.1748760544613365e-08,1.0000000583922259994902743159292251
+-5.0150486191388522e-08,1.00000005658876635314534549321089274
+-4.9208092871353701e-08,1.00000005552538926997321245151691922
+-4.2324579521807829e-08,1.00000004775817557985539522853532974
+-3.755432600196346e-08,1.00000004237552050525632110719227895
+-3.4529718393982316e-08,1.0000000389626160737458488212876639
+-3.044205855933345e-08,1.00000003435018560857244787269135679
+-1.6027642128470302e-09,1.00000000180852575011167994103257091
+-1.5339857339164971e-09,1.00000000173091754712620783371318667
+-1.5025450726826883e-09,1.00000000169544055989479990758671376
+-1.3018063391568632e-09,1.00000000146893115439217938234271357
+-1.2890245063319687e-09,1.00000000145450840048215528109549269
+-1.2264039502845777e-09,1.00000000138384866944882482159033699
+-1.1885233888961227e-09,1.00000000134110503304873071903183784
+-1.1214356532313962e-09,1.00000000126540462960207286371460106
+-1.0374033296072748e-09,1.0000000011705843060805739182193658
+-9.7488075313988422e-10,1.00000000110003513319582103951684678
+-5.8075161093498493e-11,1.00000000006553080190699227063522445
+-5.795356807287729e-11,1.00000000006539359887564498191274819
+-5.3908218827052144e-11,1.0000000000608289110625778243712881
+-5.2087911546279493e-11,1.00000000005877491424904873693932524
+-5.1039268331692217e-11,1.00000000005759164709188424188492774
+-4.3729942373907091e-11,1.00000000004934395595491635328111354
+-4.0507605627834051e-11,1.00000000004570793830100975007979556
+-4.0176921088948473e-11,1.00000000004533480075642399707563392
+-3.6291265220543901e-11,1.00000000004095030762371672669863289
+-3.2275371152958259e-11,1.0000000000364188564203152728633643
+-1.7835577719932488e-12,1.00000000000201252943323165129653704
+-1.617026307833392e-12,1.00000000000182461879840718959479314
+-1.4947297928399465e-12,1.00000000000168662195867982115749608
+-1.3936095882125118e-12,1.00000000000157252002640549648366134
+-1.2488783745360065e-12,1.00000000000140920834006409631361723
+-1.2415854396153092e-12,1.00000000000140097914423257994177871
+-1.1792849811604717e-12,1.00000000000133068060481149098557765
+-1.1474191709940977e-12,1.00000000000129472388847706003192509
+-1.1256080476374526e-12,1.00000000000127011267127042178572774
+-1.0779503781223706e-12,1.00000000000121633674983717536974272
+-5.314947190542534e-14,1.00000000000005997275684021301595382
+-5.0470775448292623e-14,1.00000000000005695017156301162302006
+-4.9360903224353467e-14,1.00000000000005569781486738060221771
+-4.5915579178747477e-14,1.00000000000005181018299042524592601
+-4.5606945008011717e-14,1.00000000000005146192662191318658695
+-4.3168489571610538e-14,1.00000000000004871042430758708278518
+-4.2005260464830972e-14,1.00000000000004739786081693779995829
+-3.5952284670706391e-14,1.00000000000004056780903191373513621
+-3.1184441287173997e-14,1.0000000000000351878738859612812657
+-3.1137191149454793e-14,1.00000000000003513455781491653416215
+-1.6532726520226451e-15,1.00000000000000186551841807110424511
+-1.6059624858203385e-15,1.00000000000000181213461213659510371
+-1.4150002112616263e-15,1.00000000000000159665675982337022911
+-1.4111411474815001e-15,1.00000000000000159230227264938295399
+-1.3978318900870213e-15,1.00000000000000157728438387594118207
+-1.161802431919612e-15,1.0000000000000013109536604589940656
+-1.1510986791027261e-15,1.00000000000000129887576877068009366
+-1.0820188427936712e-15,1.00000000000000122092752061317424959
+-9.9453296189851591e-16,1.00000000000000112221027519608151761
+-9.7130154481995625e-16,1.00000000000000109599642814252785014
diff --git a/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_small_data.csv b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_small_data.csv
new file mode 100644
index 0000000..59b9987
--- /dev/null
+++ b/commons-numbers-gamma/src/test/resources/org/apache/commons/numbers/gamma/erfcx_small_data.csv
@@ -0,0 +1,158 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Random data using 52-bit mantissa scaled with 2^b.
+# Generated in blocks of 10 with b:
+# {-50:5:-5} {-4:1:-1} {0,0,0} {1,1,1} {2,2,2} {3,3,3}
+# {4,4,4,4} {5,5,5,5} {6,6,6,6} {8:2:28}
+# An additional 10 positive test points generated in the range
+# [26.3, 27.3] where erfc(x) transitions to sub-normal.
+# Reference values from customized Boost C++ 128-bit implementation
+# of erfc modifed to remove scaling by exp(-x^2). Values for large x
+# generated using the upper_gamma_fraction(...) continued fraction
+# See: https://mathworld.wolfram.com/Erfc.html Eq.3
+
+# Partition: 0 <= z < 0.5
+# z, erfcx(z)
+9.7130154481995625e-16,0.99999999999999890400357185747403679
+9.9453296189851591e-16,0.999999999999998877789724803920460608
+1.0820188427936712e-15,0.999999999999998779072479386828091861
+1.1510986791027261e-15,0.999999999999998701124231229322556516
+1.161802431919612e-15,0.999999999999998689046339541008633878
+1.3978318900870213e-15,0.999999999999998422715616124062725738
+1.4111411474815001e-15,0.999999999999998407697727350621028742
+1.4150002112616263e-15,0.999999999999998403343240176633775382
+1.6059624858203385e-15,0.999999999999998187865387863410054508
+1.6532726520226451e-15,0.999999999999998134481581928901221641
+3.1137191149454793e-14,0.999999999999964865442185085404887133
+3.1184441287173997e-14,0.999999999999964812126114040663673078
+3.5952284670706391e-14,0.999999999999959432190968088849997377
+4.2005260464830972e-14,0.999999999999952602139183065728925459
+4.3168489571610538e-14,0.999999999999951289575692416644251822
+4.5606945008011717e-14,0.999999999999948538073378090973399966
+4.5915579178747477e-14,0.999999999999948189817009578970554788
+4.9360903224353467e-14,0.999999999999944302185132624270779868
+5.0470775448292623e-14,0.99999999999994304982843699347157819
+5.314947190542534e-14,0.999999999999940027243159792633779007
+1.0779503781223706e-12,0.99999999999878366325016514858429261
+1.1256080476374526e-12,0.999999999998729887328732112201226099
+1.1474191709940977e-12,0.9999999999987052761115255731095828
+1.1792849811604717e-12,0.999999999998669319395191290440556003
+1.2415854396153092e-12,0.999999999998599020855770503127028922
+1.2488783745360065e-12,0.999999999998590791659939023080771571
+1.3936095882125118e-12,0.999999999998427479973598387811707354
+1.4947297928399465e-12,0.999999999998313378041324647276811152
+1.617026307833392e-12,0.999999999998175381201598039953367394
+1.7835577719932488e-12,0.999999999997987470566774710860115022
+3.2275371152958259e-11,0.999999999963581143581768126302758111
+3.6291265220543901e-11,0.999999999959049692378917385163982842
+4.0176921088948473e-11,0.999999999954665199246804372900741257
+4.0507605627834051e-11,0.999999999954292061702271982147604729
+4.3729942373907091e-11,0.999999999950656044048908262438937031
+5.1039268331692217e-11,0.999999999942408352913325771938741247
+5.2087911546279493e-11,0.999999999941225085756377564119180872
+5.3908218827052144e-11,0.999999999939171088943234367742922674
+5.795356807287729e-11,0.999999999934606401131072250192006968
+5.8075161093498493e-11,0.999999999934469198099753178036847089
+9.7488075313988422e-10,0.999999998899964868704963926168329032
+1.0374033296072748e-09,0.999999998829415696071837418341154379
+1.1214356532313962e-09,0.999999998734595372913162984962455723
+1.1885233888961227e-09,0.999999998658894969776444972874410244
+1.2264039502845777e-09,0.999999998616151333559308476956896845
+1.2890245063319687e-09,0.999999998545491602841013074753258413
+1.3018063391568632e-09,0.999999998531068848997220106995274224
+1.5025450726826883e-09,0.999999998304559444620483483299336224
+1.5339857339164971e-09,0.999999998269082457580016630005482053
+1.6027642128470302e-09,0.999999998191474255026026302933749949
+3.044205855933345e-08,0.99999996564981624486541078708338599
+3.4529718393982316e-08,0.999999961037386310857055914155100813
+3.755432600196346e-08,0.999999957624482315398481816307392006
+4.2324579521807829e-08,0.999999952241828002884668167137230966
+4.9208092871353701e-08,0.999999944474615572899595620030774791
+5.0150486191388522e-08,0.99999994341123867699718497209713747
+5.1748760544613365e-08,0.999999941607779356378161491543759674
+5.7024573898052173e-08,0.999999935654662052741271547191654797
+5.7298657952752455e-08,0.999999935345391346718578668067577203
+5.8427083734669713e-08,0.999999934072099333377582527229216563
+1.2677395125524943e-06,0.999998569510751893884361179403245806
+1.3452503784317747e-06,0.999998482049308146980314960535926325
+1.3536183688504579e-06,0.99999847260706467215673612258928612
+1.3723189328671733e-06,0.999998451505788799245703742874252364
+1.402391679373127e-06,0.999998417572411587621415669489757148
+1.5404200081015417e-06,0.999998261824527172171300801721681715
+1.5995529991920228e-06,0.999998195100277613294836461762900072
+1.6745173878524748e-06,0.999998110512268613021223521785721293
+1.7534905820760669e-06,0.999998021400832212347757498617224681
+1.7879828998727808e-06,0.999997982480541539082705488819491274
+3.3736643558676114e-05,0.999961933412372897306415471574710538
+3.4233643453352445e-05,0.999961372641825625926158978931229006
+3.5853733531950029e-05,0.999959544679475491735284496678270309
+3.7889625755461427e-05,0.999957247571231313697701443820994058
+3.8865175848419506e-05,0.999956146855704872942737011171223544
+4.0337749351856421e-05,0.999954485351068494741690360074721902
+4.1610928639888013e-05,0.999953048826414437782303209588025718
+4.5225776013328447e-05,0.999948970221832064333429063792097081
+4.8319169421578027e-05,0.999945479990510605399846225037923173
+5.9214995792548157e-05,0.999933186538627581043729021327510778
+0.001031024069980071,0.998837676105396802698904099920053324
+0.0011550491574421628,0.998697999573998258729002647432961477
+0.0011600175307826647,0.998692404852134140838504284947912288
+0.0012859311710498368,0.998550634076990938067322924437214984
+0.0014193323188994612,0.998400467335547858277053711767479454
+0.0015319489600986644,0.998273724874178312523901726056243876
+0.0015757736604611334,0.998224409951813640005146167748388851
+0.001613366949139244,0.998182110142908570293026998400223124
+0.001668132561107837,0.998120493148352200761126430980842165
+0.0019129907261118428,0.99784507539175388036075240556138145
+0.031973370147413402,0.964920135957164143645805637300440817
+0.032132709185194161,0.96475019651191869144032823927374343
+0.041268320505285373,0.955085305584846997429016444055780921
+0.045405708030174484,0.95075847206590043611752496492889385
+0.046452549983506057,0.949668610758319806919857059086291564
+0.04708598449631541,0.949010105268565616747887179916393077
+0.052088988030571284,0.943834385780365869091488547164752381
+0.054366711972479637,0.941492821281706893747205219293384403
+0.060276548898484723,0.935460085186250285526438460621634031
+0.060960185959534799,0.934766187285943749790064732583085728
+0.071509116119581842,0.924161616825566449687094327852389924
+0.076391313805872912,0.919318194147231976401163169435912156
+0.08362350238360583,0.912217251782104487679272691840918113
+0.094710738081586698,0.901499464131858187415918728519896555
+0.095814414502602238,0.900443552995888891417230254324310467
+0.098482859484223431,0.897898726440353350101609958165311487
+0.10793159816244537,0.888979335157188341956693516898610341
+0.10900321071033534,0.887976694196316836898255189894949857
+0.11286853951408039,0.884375117956876268052665225845430583
+0.12329818805344439,0.874772821596536026547568765484789812
+0.12696236352166745,0.87143887013067151046750948513516839
+0.16306126820866274,0.839654235479616665649586479590044821
+0.16918701508014028,0.834445650596847075458238374446832557
+0.17381854594563056,0.830542043520008418374575656787822261
+0.18231488553503583,0.82345720173230308784124716055207687
+0.19498190333012316,0.813074316554275126294353845412746144
+0.20315239753032366,0.806488986803297076784636959469838869
+0.21082223745238751,0.800385428384821321427117186565552123
+0.22920854202483132,0.786055195156164306605145441591007349
+0.24783561853006128,0.771957871164793555112509150326610945
+0.27842971541905986,0.749680883031309823715498906502891549
+0.29428656549804993,0.738545315850769536287916840944281174
+0.31495598275489722,0.724432312498316498663840973789324776
+0.31904908307003327,0.721690109361788029354639355162270207
+0.36269830551500243,0.693479806804937902002655508449952901
+0.36869368606454545,0.689747416982706873902741329242100385
+0.37158200250016749,0.687961171148514966625550176914506152
+0.42802139246552195,0.654540966416027445630871455641722741
+0.44151642826440357,0.646949205855789719368857037328500884
+0.44339406809384158,0.645904581389513460342365230534290286
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4b7d6e7..3f6fbb6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -72,6 +72,9 @@ N.B. the Performance testing module requires Java 9+.
 (The unit tests require Java 8+)
 
 ">
+      <action dev="aherbert" type="add" issue="NUMBERS-177">
+        "Erfcx": Compute a scaled complementary error function: erfcx(z) = erfc(z) * exp(z*z).
+      </action>
       <action dev="aherbert" type="update" issue="NUMBERS-178">
         "Factorial/FactorialDouble": Tabulate all factorials with exact 64-bit double
         representations of n! up to n=170. This change deprecates the FactorialDouble