001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.numbers.gamma; 018 019/** 020 * Scaled complementary error function. 021 * 022 * <p>\[ \operatorname{erfcx}(z) = \operatorname{erfc}(z)\ e^{z^2} \] 023 * 024 * <p>For large z the value is approximately: 025 * 026 * <p>\[ \operatorname{erfcx}(z) = \frac{1}{z \sqrt{\pi}} \] 027 * 028 * @see Erfc 029 * @since 1.1 030 */ 031public final class Erfcx { 032 /** Private constructor. */ 033 private Erfcx() { 034 // intentionally empty. 035 } 036 037 /** 038 * Returns the scaled complementary error function. 039 * 040 * <p>Special cases: 041 * <ul> 042 * <li>If the argument is 0, then the result is 1. 043 * <li>If the argument is +infinity, then the result is 0. 044 * <li>If the argument is negative and {@code exp(x*x)} is infinite, then the result is +infinity. 045 * <li>If the argument is nan, then the result is nan. 046 * </ul> 047 * 048 * @param x Value. 049 * @return the scaled complementary error function. 050 */ 051 public static double value(double x) { 052 return BoostErf.erfcx(x); 053 } 054}