You are here

private static function PHPExcel_Calculation_Engineering::_erfcVal in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php \PHPExcel_Calculation_Engineering::_erfcVal()
2 calls to PHPExcel_Calculation_Engineering::_erfcVal()
PHPExcel_Calculation_Engineering::ERFC in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
* ERFC * * Returns the complementary ERF function integrated between x and infinity * * Note: In Excel 2007 or earlier, if you input a negative value for the lower bound argument, * the function would return a #NUM! error. However, in Excel…
PHPExcel_Calculation_Engineering::_erfVal in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php, line 2289

Class

PHPExcel_Calculation_Engineering
PHPExcel_Calculation_Engineering

Code

private static function _erfcVal($x) {
  if (abs($x) < 2.2) {
    return 1 - self::_erfVal($x);
  }
  if ($x < 0) {
    return 2 - self::ERFC(-$x);
  }
  $a = $n = 1;
  $b = $c = $x;
  $d = $x * $x + 0.5;
  $q1 = $q2 = $b / $d;
  $t = 0;
  do {
    $t = $a * $n + $b * $x;
    $a = $b;
    $b = $t;
    $t = $c * $n + $d * $x;
    $c = $d;
    $d = $t;
    $n += 0.5;
    $q1 = $q2;
    $q2 = $b / $d;
  } while (abs($q1 - $q2) / $q2 > PRECISION);
  return self::$_one_sqrtpi * exp(-$x * $x) * $q2;
}