1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.numbers.gamma; 18 19 /** 20 * Scaled complementary error function. 21 * 22 * <p>\[ \operatorname{erfcx}(z) = \operatorname{erfc}(z)\ e^{z^2} \] 23 * 24 * <p>For large z the value is approximately: 25 * 26 * <p>\[ \operatorname{erfcx}(z) = \frac{1}{z \sqrt{\pi}} \] 27 * 28 * @see Erfc 29 * @since 1.1 30 */ 31 public final class Erfcx { 32 /** Private constructor. */ 33 private Erfcx() { 34 // intentionally empty. 35 } 36 37 /** 38 * Returns the scaled complementary error function. 39 * 40 * <p>Special cases: 41 * <ul> 42 * <li>If the argument is 0, then the result is 1. 43 * <li>If the argument is +infinity, then the result is 0. 44 * <li>If the argument is negative and {@code exp(x*x)} is infinite, then the result is +infinity. 45 * <li>If the argument is nan, then the result is nan. 46 * </ul> 47 * 48 * @param x Value. 49 * @return the scaled complementary error function. 50 */ 51 public static double value(double x) { 52 return BoostErf.erfcx(x); 53 } 54 }