public static function toMercatorCoords($lat, $lng) { if ($lng > 180) { $lng -= 360; } $lng /= 360; $lat = asinh(tan(deg2rad($lat))) / M_PI / 2; return new GoogleMapPoint($lng, $lat); }
/** * This method returns the inverse hyperbolic sine of this object's value. * * @access public * @static * @param IReal\Type $x the operand * @return IDouble\Type the result */ public static function asinh(IReal\Type $x) : IDouble\Type { return IDouble\Type::box(asinh($x->unbox())); }
public function asinhHook(&$parser, $expr = '') { try { $res = $this->exprParser->doExpression($expr); } catch (ExprError $e) { return $e->getMessage(); } if (function_exists('asinh')) { $result = asinh($res); } else { $result = log($res + sqrt($res ^ 2 + 1)); } $result = asinh($res); return $this->check($result); }
/** * @return $this * @desc 反双曲正弦。 */ public function asinh() { $this->current = asinh($this->toDouble()); return $this; }
<?php /* * proto float asinh(float number) * Function is implemented in ext/standard/math.c */ $file_path = dirname(__FILE__); require $file_path . "/allowed_rounding_error.inc"; echo "asinh 0.52109530549375= "; var_dump(asinh(0.52109530549375)); if (allowed_rounding_error(asinh(0.52109530549375), 0.5)) { echo "Pass\n"; } else { echo "Fail\n"; } echo "asinh 10.01787492741= "; var_dump(asinh(10.01787492741)); if (allowed_rounding_error(asinh(10.01787492741), 3.0)) { echo "Pass\n"; } else { echo "Fail\n"; }
/** * Inverse hyperbolic sine. * @link http://php.net/manual/en/function.asinh.php * @param float $number <p>The argument to process</p> * @return float The inverse hyperbolic sine of <i>number</i> */ public static function asinh($number) { return asinh($number); }
/** * @param float $x A number * @return float The hyperbolic arcsine (in radians) of the given value */ public function asinh($x) { return asinh($x); }
echo trim("\t\tThese are a few words :) ... "); echo trim("\t\tThese are a few words :) ... ", " \t."); echo trim("\tExample string\n", ".."); echo ltrim("\t\tThese are a few words :) ... "); echo ltrim("\t\tThese are a few words :) ... ", " \t."); echo ltrim("\tExample string\n", ".."); echo rtrim("\t\tThese are a few words :) ... "); echo rtrim("\t\tThese are a few words :) ... ", " \t."); echo rtrim("\tExample string\n", ".."); echo chop("\t\tThese are a few words :) ... "); echo chop("\t\tThese are a few words :) ... ", " \t."); echo chop("\tExample string\n", ".."); echo acos(0.5); echo acosh(0.5); echo asin(0.5); echo asinh(0.5); echo atan(0.5); echo atan2(0.5, 0.5); echo atanh(0.5); echo cos(0.5); echo cosh(0.5); echo sin(0.5); echo sinh(0.5); echo tan(0.5); echo tanh(0.5); echo exp(5.7); echo exp(12); echo log10(12); echo log(12); echo sqrt(2); echo ceil(7.9);
VC(pow("2", "8"), 256); VC(pow("-1", "20"), 1); var_dump(pow("0", "0")); var_dump(is_int(pow("2", "32"))); VC(exp(12), 162754.791419); VC(exp(5.7), 298.86740096706); VC(expm1(5.7), 297.8674); var_dump(log10(10)); var_dump(log10(100)); VC(log1p(9), 2.302585092994); VC(log1p(99), 4.6051701859881); VC(log(8), 2.0794415416798); var_dump(log(8, 2)); VC(cos(M_PI), -1); VC(cosh(1.23), 1.8567610569853); VC(sin(deg2rad(90)), 1); VC(sinh(1.23), 1.5644684793044); VC(tan(deg2rad(45)), 1); VC(tanh(1.23), 0.84257932565893); VC(acos(-1), M_PI); VC(acosh(1.8567610569853), 1.23); VC(asin(1), deg2rad(90)); VC(asinh(1.5644684793044), 1.23); VC(atan(1), deg2rad(45)); VC(atanh(0.84257932565893), 1.23); VC(atan2(3, 4), 0.64350110879328); var_dump(hypot(3, 4)); var_dump(fmod(5.7, 1.3)); var_dump(sqrt(9)); var_dump(getrandmax()); var_dump(mt_getrandmax());
private function func(Token $func, &$args) { $functions = array("abs" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return abs($a); }), "acos" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return acos($a); }), "acosh" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return acosh($a); }), "addMonths" => array(2, array(Token::T_NUMBER, Token::T_DATE), Token::T_DATE, function ($a, $b) { return Expression::addMonths($a, $b); }), "asin" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return asin($a); }), "asinh" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return asinh($a); }), "atan" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return atan($a); }), "atan2" => array(2, array(Token::T_NUMBER, Token::T_NUMBER), Token::T_NUMBER, function ($a, $b) { return atan2($a, $b); }), "atanh" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return atanh($a); }), "ceil" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return ceil($a); }), "concat" => array(-1, array(Token::T_TEXT), Token::T_TEXT, function ($a) { $s = ''; foreach ($a as $v) { $s .= isset($v) ? $v : ''; } return $s; }), "cos" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return cos($a); }), "cosh" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return cosh($a); }), "count" => array(-1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { $c = 0; foreach ($a as $v) { if (isset($v)) { $c += 1; } } return $c; }), "day" => array(1, array(Token::T_DATE), Token::T_NUMBER, function ($a) { return (double) $a->format('d'); }), "exp" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return exp($a); }), "firstDayOfMonth" => array(1, array(Token::T_DATE), Token::T_DATE, function ($a) { return Expression::firstDayOfMonth($a); }), "floor" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return floor($a); }), "fullmonth" => array(1, array(Token::T_DATE), Token::T_TEXT, function ($a) { $months = array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"); return $months[(int) $a->format('m') - 1] . ' ' . $a->format('Y'); }), "get" => array(2, array(Token::T_ARRAY, Token::T_NUMBER), Token::T_TEXT, function ($a, $b) { return isset($a[$b - 1]) ? $a[$b - 1] : ""; }), "lastday" => array(2, array(Token::T_NUMBER, Token::T_NUMBER), Token::T_NUMBER, function ($a, $b) { return Expression::lastDay($b, $a); }), "lastDayOfMonth" => array(1, array(Token::T_DATE), Token::T_DATE, function ($a) { return Expression::lastDayOfMonth($a); }), "length" => array(1, array(Token::T_TEXT), Token::T_NUMBER, function ($a) { return mb_strlen($a, 'utf8'); }), "log" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return log($a); }), "log10" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return log10($a); }), "lower" => array(1, array(Token::T_TEXT), Token::T_TEXT, function ($a) { return strtolower($a); }), "match" => array(2, array(Token::T_TEXT, Token::T_TEXT), Token::T_BOOLEAN, function ($a, $b) { return preg_match($a, $b); }), "max" => array(2, array(Token::T_NUMBER, Token::T_NUMBER), Token::T_NUMBER, function ($a, $b) { return max($a, $b); }), "min" => array(2, array(Token::T_NUMBER, Token::T_NUMBER), Token::T_NUMBER, function ($a, $b) { return min($a, $b); }), "money" => array(1, array(Token::T_NUMBER), Token::T_TEXT, function ($a) { return (string) number_format($a, 2, ",", " "); }), "month" => array(1, array(Token::T_DATE), Token::T_NUMBER, function ($a) { return (double) $a->format('m'); }), "nextWorkDay" => array(1, array(Token::T_DATE), Token::T_DATE, function ($a) { return Expression::nextWorkingDay($a); }), "pow" => array(2, array(Token::T_NUMBER, Token::T_NUMBER), Token::T_NUMBER, function ($a, $b) { return pow($a, $b); }), "rand" => array(0, array(), Token::T_NUMBER, function () { return rand(); }), "replace" => array(3, array(Token::T_TEXT, Token::T_TEXT, Token::T_TEXT), Token::T_TEXT, function ($a, $b, $c) { return str_replace($a, $b, $c); }), "round" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return round($a); }), "sin" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return sin($a); }), "sinh" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return sinh($a); }), "size" => array(1, array(Token::T_ARRAY), Token::T_NUMBER, function ($a) { return count($a); }), "split" => array(2, array(Token::T_TEXT, Token::T_TEXT), Token::T_ARRAY, function ($a, $b) { return explode($a, $b); }), "sqrt" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return sqrt($a); }), "substr" => array(3, array(Token::T_TEXT, Token::T_NUMBER, Token::T_NUMBER), Token::T_TEXT, function ($a, $b, $c) { return substr($a, $b - 1, $c); }), "sum" => array(-1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { $s = 0; foreach ($a as $v) { if (isset($v)) { $s += $v; } } return $s; }), "tan" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return tan($a); }), "tanh" => array(1, array(Token::T_NUMBER), Token::T_NUMBER, function ($a) { return tanh($a); }), "upper" => array(1, array(Token::T_TEXT), Token::T_TEXT, function ($a) { return strtoupper($a); }), "workdays" => array(2, array(Token::T_DATE, Token::T_DATE), Token::T_NUMBER, function ($a, $b) { return Expression::workdays($a, $b); }), "year" => array(1, array(Token::T_DATE), Token::T_NUMBER, function ($a) { return (double) $a->format('Y'); })); if ($func->value == "defined") { if (count($args) < 1) { throw new \Exception("Illegal number (" . count($args) . ") of operands for function" . $func); } $arg = array_pop($args); if ($arg->isVariable()) { return new Token(Token::T_BOOLEAN, false); } if ($arg->value === null || $arg->value == "") { return new Token(Token::T_BOOLEAN, false); } return new Token(Token::T_BOOLEAN, true); } if (!isset($functions[$func->value])) { throw new \Exception("Unknown function : " . $func); } $argc = $functions[$func->value][0]; $variableArgsCount = false; if ($argc == -1) { $argc = count($args); $variableArgsCount = true; } if (count($args) < $argc) { throw new \Exception("Illegal number (" . count($args) . ") of operands for function" . $func); } $argv = array(); for (; $argc > 0; --$argc) { $arg = array_pop($args); if (!$variableArgsCount) { if ($arg->isVariable()) { return new Token(Token::T_UNDEFINED, array($arg)); } $type = $functions[$func->value][1][$argc - 1]; if ($arg->type != $type) { $expected = ""; switch ($type) { case Token::T_NUMBER: $expected = "number"; break; case Token::T_DATE: $expected = "date"; break; case Token::T_BOOLEAN: $expected = "boolean"; break; case Token::T_TEXT: $expected = "text"; break; case Token::T_ARRAY: $expected = "array"; break; } throw new \Exception("Illegal type for argument '" . $arg . "' : operand must be a " . $expected . " for " . $func); } array_unshift($argv, $arg->value); } else { if ($arg->isVariable()) { unset($arg->value); } else { array_unshift($argv, $arg->value); } } } if ($variableArgsCount) { $argv = array($argv); } return new Token($functions[$func->value][2], call_user_func_array($functions[$func->value][3], $argv)); }
<?php /* * proto float asinh(float number) * Function is implemented in ext/standard/math.c */ //Test asinh with a different input values $values = array(23, -23, 23.45, -23.45, 0x17, 027, "23", "23.45", "2.345e1", "nonsense", "1000", "1000ABC", null, true, false); for ($i = 0; $i < count($values); $i++) { $res = asinh($values[$i]); var_dump($res); }
public static function arcSinH($x) { return asinh($x); }
/** * Inverse hyperbolic cosecant. * * @param float $arg The hyperbolic cosecant of the angle. * * @return float The angle in radians corresponding to `$arg`. */ public static function arcsch($arg) { return asinh(1 / $arg); }
<?php /* * proto float asinh(float number) * Function is implemented in ext/standard/math.c */ $arg_0 = 1.0; $extra_arg = 1; echo "\nToo many arguments\n"; var_dump(asinh($arg_0, $extra_arg)); echo "\nToo few arguments\n"; var_dump(asinh());
public function testCanEvaluateHyperbolicFunctions() { $x = $this->variables['x']; $this->assertResult('sinh(0)', 0); $this->assertResult('sinh(x)', sinh($x)); $this->assertResult('cosh(0)', 1); $this->assertResult('cosh(x)', cosh($x)); $this->assertResult('tanh(0)', 0); $this->assertResult('tanh(x)', tanh($x)); $this->assertResult('coth(x)', 1 / tanh($x)); $this->assertResult('arsinh(0)', 0); $this->assertResult('arsinh(x)', asinh($x)); $this->assertResult('arcosh(1)', 0); $this->assertResult('arcosh(3)', acosh(3)); $this->assertResult('artanh(0)', 0); $this->assertResult('artanh(x)', atanh($x)); $this->assertResult('arcoth(3)', atanh(1 / 3)); }
public static function asinh($self, $a) { return asinh($a); }
/** * Seno Hiperbólico Inverso * @return Number */ public function asinh() { $this->num = asinh($this->num); return $this; }
/** * */ public function getInverseHiperbolicSinOf() { $this->lastOutputValue = asinh($this->calcLeftNumber); return $this->lastOutputValue; }
/** * Evaluate a FunctionNode * * Computes the value of a FunctionNode `f(x)`, where f is * an elementary function recognized by StdMathLexer and StdMathParser. * * @see \MathParser\Lexer\StdMathLexer StdMathLexer * @see \MathParser\StdMathParser StdMathParser * @throws UnknownFunctionException if the function respresented by the * FunctionNode is *not* recognized. * * @param FunctionNode $node AST to be evaluated * @retval float */ public function visitFunctionNode(FunctionNode $node) { $inner = $node->getOperand()->accept($this); switch ($node->getName()) { // Trigonometric functions case 'sin': return sin($inner); case 'cos': return cos($inner); case 'tan': return tan($inner); case 'cot': return 1 / tan($inner); // Inverse trigonometric functions // Inverse trigonometric functions case 'arcsin': return asin($inner); case 'arccos': return acos($inner); case 'arctan': return atan($inner); case 'arccot': return pi() / 2 - atan($inner); // Exponentials and logarithms // Exponentials and logarithms case 'exp': return exp($inner); case 'log': return log($inner); case 'lg': return log10($inner); // Powers // Powers case 'sqrt': return sqrt($inner); // Hyperbolic functions // Hyperbolic functions case 'sinh': return sinh($inner); case 'cosh': return cosh($inner); case 'tanh': return tanh($inner); case 'coth': return 1 / tanh($inner); // Inverse hyperbolic functions // Inverse hyperbolic functions case 'arsinh': return asinh($inner); case 'arcosh': return acosh($inner); case 'artanh': return atanh($inner); case 'arcoth': return atanh(1 / $inner); default: throw new UnknownFunctionException($node->getName()); } }
/** * @param int|float $number * * @return float */ function inverseHyperbolicSine($number) { return (double) \asinh($number); }
<?php define("MAX_64Bit", 9223372036854775807); define("MAX_32Bit", 2147483647); define("MIN_64Bit", -9223372036854775807 - 1); define("MIN_32Bit", -2147483647 - 1); $longVals = array(MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, MAX_32Bit * 2 + 1, MAX_32Bit * 2 - 1, MAX_64Bit - 1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1); foreach ($longVals as $longVal) { echo "--- testing: {$longVal} ---\n"; var_dump(asinh($longVal)); } ?> ===DONE===
private function _asinh($num) { $num = (double) $num; if (function_exists('asinh')) { return asinh($num); } return log($num + sqrt(pow($num, 2) + 1)); }
echo M_2_SQRTPI . "\n"; echo M_SQRT2 . "\n"; echo M_SQRT1_2 . "\n"; echo "abs\n"; echo abs(-2354) . " " . abs("foo") . " " . abs(0) . " " . abs(5) . abs(1.2345) . "\n"; echo "acos\n"; echo acos(-2354) . " " . acos("foo") . " " . acos(0) . " " . acos(5) . acos(1.2345) . "\n"; if (PHP_OS != 'WINNT') { echo "acosh\n"; echo acosh(-2354) . " " . acosh("foo") . " " . acosh(0) . " " . acosh(5) . acosh(1.2345) . "\n"; } echo "asin\n"; echo asin(-2354) . " " . asin("foo") . " " . asin(0) . " " . asin(5) . asin(1.2345) . "\n"; if (PHP_OS != 'WINNT') { echo "asinh\n"; echo asinh(-2354) . " " . asinh("foo") . " " . asinh(0) . " " . asinh(5) . asinh(1.2345) . "\n"; } echo "atan\n"; echo atan(-2354) . " " . atan("foo") . " " . atan(0) . " " . atan(5) . atan(1.2345) . "\n"; if (PHP_OS != 'WINNT') { echo "atanh\n"; echo atanh(-2354) . " " . atanh("foo") . " " . atanh(0) . " " . atanh(5) . atanh(1.2345) . "\n"; } echo "atan2\n"; echo atan2(-2354, 3) . " " . atan2("foo", 12) . " " . atan2(0, 3) . " " . atan2(5, 2.3) . atan2(1.2345, 3.22) . "\n"; echo "base_convert\n"; echo base_convert("-2354", 10, 2) . " " . base_convert("foo", 10, 10) . " " . base_convert(300, 4, 20) . " " . base_convert(5, 6, 7) . " " . base_convert(5, 4, 7) . " " . base_convert(1.2345, 8, 2) . "\n"; echo "bindec\n"; echo bindec("-2354") . " " . bindec("foo") . " " . bindec(0) . " " . bindec(5) . bindec("1.2345") . "\n"; echo "ceil\n"; echo ceil(-2354) . " " . ceil("foo") . " " . ceil(0) . " " . ceil(5) . ceil(1.2345) . "\n";
/** * Evaluate a FunctionNode * * Computes the value of a FunctionNode `f(x)`, where f is * an elementary function recognized by StdMathLexer and StdMathParser. * * @see \MathParser\Lexer\StdMathLexer StdMathLexer * @see \MathParser\StdMathParser StdMathParser * @throws UnknownFunctionException if the function respresented by the * FunctionNode is *not* recognized. * * @param FunctionNode $node AST to be evaluated * @retval float */ public function visitFunctionNode(FunctionNode $node) { $inner = $node->getOperand()->accept($this); switch ($node->getName()) { // Trigonometric functions case 'sin': return sin($inner); case 'cos': return cos($inner); case 'tan': return tan($inner); case 'cot': return 1 / tan($inner); // Trigonometric functions, argument in degrees // Trigonometric functions, argument in degrees case 'sind': return sin(deg2rad($inner)); case 'cosd': return cos(deg2rad($inner)); case 'tand': return tan(deg2rad($inner)); case 'cotd': return 1 / tan(deg2rad($inner)); // Inverse trigonometric functions // Inverse trigonometric functions case 'arcsin': return asin($inner); case 'arccos': return acos($inner); case 'arctan': return atan($inner); case 'arccot': return pi() / 2 - atan($inner); // Exponentials and logarithms // Exponentials and logarithms case 'exp': return exp($inner); case 'log': return log($inner); case 'lg': return log10($inner); // Powers // Powers case 'sqrt': return sqrt($inner); // Hyperbolic functions // Hyperbolic functions case 'sinh': return sinh($inner); case 'cosh': return cosh($inner); case 'tanh': return tanh($inner); case 'coth': return 1 / tanh($inner); // Inverse hyperbolic functions // Inverse hyperbolic functions case 'arsinh': return asinh($inner); case 'arcosh': return acosh($inner); case 'artanh': return atanh($inner); case 'arcoth': return atanh(1 / $inner); case 'abs': return abs($inner); case 'sgn': return $inner >= 0 ? 1 : 0; case '!': $logGamma = Math::logGamma(1 + $inner); return exp($logGamma); case '!!': if (round($inner) != $inner) { throw new \UnexpectedValueException("Expecting positive integer (semifactorial)"); } return Math::SemiFactorial($inner); default: throw new UnknownFunctionException($node->getName()); } }