Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/ninja-fo.../includes/Librarie.../EOS
File: Parser.php
[500] Fix | Delete
[501] Fix | Delete
} //end function solveIF
[502] Fix | Delete
[503] Fix | Delete
/**
[504] Fix | Delete
* Solve factorial (!)
[505] Fix | Delete
*
[506] Fix | Delete
* Will take any real positive number and solve for it's factorial. Eg.
[507] Fix | Delete
* `5!` will become `1*2*3*4*5` = `120` For integers
[508] Fix | Delete
* and
[509] Fix | Delete
* 5.2! will become gamma(6.2) for non-integers
[510] Fix | Delete
* DONE:
[511] Fix | Delete
* Solve for non-integer factorials 2015/07/02
[512] Fix | Delete
*
[513] Fix | Delete
* @param Float $num Non-negative real number to get factorial of
[514] Fix | Delete
* @throws Exception if number is at or less than 0
[515] Fix | Delete
* @return Float Solved factorial
[516] Fix | Delete
*/
[517] Fix | Delete
protected function factorial($num) {
[518] Fix | Delete
if($num < 0) {
[519] Fix | Delete
throw new Exception("Factorial Error: Factorials don't exist for numbers < 0", NF_EOS_Parser::E_NAN);
[520] Fix | Delete
}
[521] Fix | Delete
//A non-integer! Gamma that sucker up!
[522] Fix | Delete
if(intval($num) != $num) {
[523] Fix | Delete
return $this->gamma($num + 1);
[524] Fix | Delete
}
[525] Fix | Delete
[526] Fix | Delete
$tot = 1;
[527] Fix | Delete
for($i=1;$i<=$num;$i++) {
[528] Fix | Delete
$tot *= $i;
[529] Fix | Delete
}
[530] Fix | Delete
return $tot;
[531] Fix | Delete
} //end function factorial
[532] Fix | Delete
[533] Fix | Delete
/**
[534] Fix | Delete
* Gamma Function
[535] Fix | Delete
*
[536] Fix | Delete
* Because we can. This function exists as a catch-all for different
[537] Fix | Delete
* numerical approx. of gamma if I decide to add any past Lanczos'.
[538] Fix | Delete
* This method is public because a function doesn't currently exist
[539] Fix | Delete
* within this parser to use it. That will change in the future.
[540] Fix | Delete
*
[541] Fix | Delete
* @param $z Number to compute gamma from
[542] Fix | Delete
* @return Float The gamma (hopefully, I'll test it after writing the code)
[543] Fix | Delete
*/
[544] Fix | Delete
public function gamma($z)
[545] Fix | Delete
{
[546] Fix | Delete
return $this->laGamma($z);
[547] Fix | Delete
}
[548] Fix | Delete
[549] Fix | Delete
/**
[550] Fix | Delete
* Lanczos Approximation
[551] Fix | Delete
*
[552] Fix | Delete
* The Lanczos Approximation method of finding gamma values
[553] Fix | Delete
*
[554] Fix | Delete
* @link http://www.rskey.org/CMS/index.php/the-library/11
[555] Fix | Delete
* @link http://algolist.manual.ru/maths/count_fast/gamma_function.php
[556] Fix | Delete
* @link https://en.wikipedia.org/wiki/Lanczos_approximation
[557] Fix | Delete
* @param float $z Number to obtain the gamma of
[558] Fix | Delete
* @return float Gamma of inputted number
[559] Fix | Delete
* @throws Exception if Number is less than or equal to 0
[560] Fix | Delete
*/
[561] Fix | Delete
protected function laGamma($z)
[562] Fix | Delete
{
[563] Fix | Delete
//check validity of $z, throw error if not a valid number to be used with gamma
[564] Fix | Delete
if($z <= 0) {
[565] Fix | Delete
throw new Exception("Gamma cannot be calculated on numbers less than or equal to 0", NF_EOS_Parser::E_NAN);
[566] Fix | Delete
}
[567] Fix | Delete
// Set up coefficients
[568] Fix | Delete
$p = array(
[569] Fix | Delete
0 => 1.000000000190015,
[570] Fix | Delete
1 => 76.18009172947146,
[571] Fix | Delete
2 => -86.50532032941677,
[572] Fix | Delete
3 => 24.01409824083091,
[573] Fix | Delete
4 => -1.231739572450155,
[574] Fix | Delete
5 => 1.208650973866179E-3,
[575] Fix | Delete
6 => -5.395239384953E-6
[576] Fix | Delete
);
[577] Fix | Delete
//formula:
[578] Fix | Delete
// ((sqrt(2pi)/z)(p[0]+sum(p[n]/(z+n), 1, 6)))(z+5.5)^(z+0.5)*e^(-(z+5.5))
[579] Fix | Delete
// Break it down now...
[580] Fix | Delete
$g1 = sqrt(2*pi())/$z;
[581] Fix | Delete
//Next comes our summation
[582] Fix | Delete
$g2 =0;
[583] Fix | Delete
for($n=1;$n<=6;$n++) {
[584] Fix | Delete
$g2 += $p[$n]/($z+$n);
[585] Fix | Delete
}
[586] Fix | Delete
// Don't forget to add p[0] to it...
[587] Fix | Delete
$g2 += $p[0];
[588] Fix | Delete
$g3 = pow($z+5.5, $z + .5);
[589] Fix | Delete
$g4 = exp(-($z+5.5));
[590] Fix | Delete
//now just multiply them all together
[591] Fix | Delete
$gamma = $g1 * $g2 * $g3 * $g4;
[592] Fix | Delete
return $gamma;
[593] Fix | Delete
}
[594] Fix | Delete
[595] Fix | Delete
} //end class 'Parser'
[596] Fix | Delete
[597] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function