diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6b6c6d9..4967599 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - php: [8.1, 8.0, 7.4] + php: [8.2, 8.1, 8.0, 7.4] dependency-version: [prefer-lowest, prefer-stable] os: [ubuntu-latest, windows-latest] @@ -16,13 +16,14 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, bcmath, intl + ini-values: precision=16 coverage: none - name: Install dependencies @@ -32,8 +33,3 @@ jobs: - name: Execute tests run: vendor/bin/phpunit - - - name: PHP CS Fixer - if: matrix.os != 'windows-latest' - run: | - vendor/bin/php-cs-fixer fix --dry-run -v diff --git a/src/NXP/MathExecutor.php b/src/NXP/MathExecutor.php index 6709e21..e991586 100644 --- a/src/NXP/MathExecutor.php +++ b/src/NXP/MathExecutor.php @@ -74,7 +74,6 @@ public function __clone() /** * Add operator to executor * - * @return MathExecutor */ public function addOperator(Operator $operator) : self { @@ -119,7 +118,6 @@ public function execute(string $expression, bool $cache = true) * * @throws ReflectionException * @throws Exception\IncorrectNumberOfFunctionParametersException - * @return MathExecutor */ public function addFunction(string $name, ?callable $function = null) : self { @@ -161,7 +159,6 @@ public function getVar(string $variable) * Add variable to executor. To set a custom validator use setVarValidationHandler. * * @throws MathExecutorException if the value is invalid based on the default or custom validator - * @return MathExecutor */ public function setVar(string $variable, $value) : self { @@ -189,7 +186,6 @@ public function varExists(string $variable) : bool * @param array $variables * @param bool $clear Clear previous variables * @throws \Exception - * @return MathExecutor */ public function setVars(array $variables, bool $clear = true) : self { @@ -209,7 +205,6 @@ public function setVars(array $variables, bool $clear = true) : self * The first parameter will be the variable name, and the returned value will be used as the variable value. * * - * @return MathExecutor */ public function setVarNotFoundHandler(callable $handler) : self { @@ -225,7 +220,6 @@ public function setVarNotFoundHandler(callable $handler) : self * * @param ?callable $handler throws a MathExecutorException in case of an invalid variable * - * @return MathExecutor */ public function setVarValidationHandler(?callable $handler) : self { @@ -237,7 +231,6 @@ public function setVarValidationHandler(?callable $handler) : self /** * Remove variable from executor * - * @return MathExecutor */ public function removeVar(string $variable) : self { @@ -248,7 +241,6 @@ public function removeVar(string $variable) : self /** * Remove all variables and the variable not found handler - * @return MathExecutor */ public function removeVars() : self { @@ -296,7 +288,7 @@ public function removeOperator(string $operator) : self */ public function setDivisionByZeroIsZero() : self { - $this->addOperator(new Operator('/', false, 180, static fn($a, $b) => 0 == $b ? 0 : $a / $b)); + $this->addOperator(new Operator('/', false, 180, static fn ($a, $b) => 0 == $b ? 0 : $a / $b)); return $this; } @@ -323,10 +315,10 @@ public function clearCache() : self public function useBCMath(int $scale = 2) : self { \bcscale($scale); - $this->addOperator(new Operator('+', false, 170, static fn($a, $b) => \bcadd("{$a}", "{$b}"))); - $this->addOperator(new Operator('-', false, 170, static fn($a, $b) => \bcsub("{$a}", "{$b}"))); - $this->addOperator(new Operator('uNeg', false, 200, static fn($a) => \bcsub('0.0', "{$a}"))); - $this->addOperator(new Operator('*', false, 180, static fn($a, $b) => \bcmul("{$a}", "{$b}"))); + $this->addOperator(new Operator('+', false, 170, static fn ($a, $b) => \bcadd("{$a}", "{$b}"))); + $this->addOperator(new Operator('-', false, 170, static fn ($a, $b) => \bcsub("{$a}", "{$b}"))); + $this->addOperator(new Operator('uNeg', false, 200, static fn ($a) => \bcsub('0.0', "{$a}"))); + $this->addOperator(new Operator('*', false, 180, static fn ($a, $b) => \bcmul("{$a}", "{$b}"))); $this->addOperator(new Operator('/', false, 180, static function($a, $b) { /** @todo PHP8: Use throw as expression -> static fn($a, $b) => 0 == $b ? throw new DivisionByZeroException() : $a / $b */ if (0 == $b) { @@ -335,8 +327,8 @@ public function useBCMath(int $scale = 2) : self return \bcdiv("{$a}", "{$b}"); })); - $this->addOperator(new Operator('^', true, 220, static fn($a, $b) => \bcpow("{$a}", "{$b}"))); - $this->addOperator(new Operator('%', false, 180, static fn($a, $b) => \bcmod("{$a}", "{$b}"))); + $this->addOperator(new Operator('^', true, 220, static fn ($a, $b) => \bcpow("{$a}", "{$b}"))); + $this->addOperator(new Operator('%', false, 180, static fn ($a, $b) => \bcmod("{$a}", "{$b}"))); return $this; } @@ -370,13 +362,13 @@ protected function addDefaults() : self protected function defaultOperators() : array { return [ - '+' => [static fn($a, $b) => $a + $b, 170, false], - '-' => [static fn($a, $b) => $a - $b, 170, false], + '+' => [static fn ($a, $b) => $a + $b, 170, false], + '-' => [static fn ($a, $b) => $a - $b, 170, false], // unary positive token - 'uPos' => [static fn($a) => $a, 200, false], + 'uPos' => [static fn ($a) => $a, 200, false], // unary minus token - 'uNeg' => [static fn($a) => 0 - $a, 200, false], - '*' => [static fn($a, $b) => $a * $b, 180, false], + 'uNeg' => [static fn ($a) => 0 - $a, 200, false], + '*' => [static fn ($a, $b) => $a * $b, 180, false], '/' => [ static function($a, $b) { /** @todo PHP8: Use throw as expression -> static fn($a, $b) => 0 == $b ? throw new DivisionByZeroException() : $a / $b */ if (0 == $b) { @@ -388,16 +380,16 @@ static function($a, $b) { /** @todo PHP8: Use throw as expression -> static fn($ 180, false ], - '^' => [static fn($a, $b) => \pow($a, $b), 220, true], - '%' => [static fn($a, $b) => $a % $b, 180, false], - '&&' => [static fn($a, $b) => $a && $b, 100, false], - '||' => [static fn($a, $b) => $a || $b, 90, false], - '==' => [static fn($a, $b) => \is_string($a) || \is_string($b) ? 0 == \strcmp($a, $b) : $a == $b, 140, false], - '!=' => [static fn($a, $b) => \is_string($a) || \is_string($b) ? 0 != \strcmp($a, $b) : $a != $b, 140, false], - '>=' => [static fn($a, $b) => $a >= $b, 150, false], - '>' => [static fn($a, $b) => $a > $b, 150, false], - '<=' => [static fn($a, $b) => $a <= $b, 150, false], - '<' => [static fn($a, $b) => $a < $b, 150, false], + '^' => [static fn ($a, $b) => \pow($a, $b), 220, true], + '%' => [static fn ($a, $b) => $a % $b, 180, false], + '&&' => [static fn ($a, $b) => $a && $b, 100, false], + '||' => [static fn ($a, $b) => $a || $b, 90, false], + '==' => [static fn ($a, $b) => \is_string($a) || \is_string($b) ? 0 == \strcmp($a, $b) : $a == $b, 140, false], + '!=' => [static fn ($a, $b) => \is_string($a) || \is_string($b) ? 0 != \strcmp($a, $b) : $a != $b, 140, false], + '>=' => [static fn ($a, $b) => $a >= $b, 150, false], + '>' => [static fn ($a, $b) => $a > $b, 150, false], + '<=' => [static fn ($a, $b) => $a <= $b, 150, false], + '<' => [static fn ($a, $b) => $a < $b, 150, false], ]; } @@ -410,29 +402,29 @@ static function($a, $b) { /** @todo PHP8: Use throw as expression -> static fn($ protected function defaultFunctions() : array { return [ - 'abs' => static fn($arg) => \abs($arg), - 'acos' => static fn($arg) => \acos($arg), - 'acosh' => static fn($arg) => \acosh($arg), - 'arcsin' => static fn($arg) => \asin($arg), - 'arcctg' => static fn($arg) => M_PI / 2 - \atan($arg), - 'arccot' => static fn($arg) => M_PI / 2 - \atan($arg), - 'arccotan' => static fn($arg) => M_PI / 2 - \atan($arg), - 'arcsec' => static fn($arg) => \acos(1 / $arg), - 'arccosec' => static fn($arg) => \asin(1 / $arg), - 'arccsc' => static fn($arg) => \asin(1 / $arg), - 'arccos' => static fn($arg) => \acos($arg), - 'arctan' => static fn($arg) => \atan($arg), - 'arctg' => static fn($arg) => \atan($arg), - 'array' => static fn(...$args) => $args, - 'asin' => static fn($arg) => \asin($arg), - 'atan' => static fn($arg) => \atan($arg), - 'atan2' => static fn($arg1, $arg2) => \atan2($arg1, $arg2), - 'atanh' => static fn($arg) => \atanh($arg), - 'atn' => static fn($arg) => \atan($arg), + 'abs' => static fn ($arg) => \abs($arg), + 'acos' => static fn ($arg) => \acos($arg), + 'acosh' => static fn ($arg) => \acosh($arg), + 'arcsin' => static fn ($arg) => \asin($arg), + 'arcctg' => static fn ($arg) => M_PI / 2 - \atan($arg), + 'arccot' => static fn ($arg) => M_PI / 2 - \atan($arg), + 'arccotan' => static fn ($arg) => M_PI / 2 - \atan($arg), + 'arcsec' => static fn ($arg) => \acos(1 / $arg), + 'arccosec' => static fn ($arg) => \asin(1 / $arg), + 'arccsc' => static fn ($arg) => \asin(1 / $arg), + 'arccos' => static fn ($arg) => \acos($arg), + 'arctan' => static fn ($arg) => \atan($arg), + 'arctg' => static fn ($arg) => \atan($arg), + 'array' => static fn (...$args) => $args, + 'asin' => static fn ($arg) => \asin($arg), + 'atan' => static fn ($arg) => \atan($arg), + 'atan2' => static fn ($arg1, $arg2) => \atan2($arg1, $arg2), + 'atanh' => static fn ($arg) => \atanh($arg), + 'atn' => static fn ($arg) => \atan($arg), 'avg' => static function($arg1, ...$args) { if (\is_array($arg1)){ if (0 === \count($arg1)){ - throw new \InvalidArgumentException('Array must contain at least one element!'); + throw new \InvalidArgumentException('avg() must have at least one argument!'); } return \array_sum($arg1) / \count($arg1); @@ -442,27 +434,27 @@ protected function defaultFunctions() : array return \array_sum($args) / \count($args); }, - 'bindec' => static fn($arg) => \bindec($arg), - 'ceil' => static fn($arg) => \ceil($arg), - 'cos' => static fn($arg) => \cos($arg), - 'cosec' => static fn($arg) => 1 / \sin($arg), - 'csc' => static fn($arg) => 1 / \sin($arg), - 'cosh' => static fn($arg) => \cosh($arg), - 'ctg' => static fn($arg) => \cos($arg) / \sin($arg), - 'cot' => static fn($arg) => \cos($arg) / \sin($arg), - 'cotan' => static fn($arg) => \cos($arg) / \sin($arg), - 'cotg' => static fn($arg) => \cos($arg) / \sin($arg), - 'ctn' => static fn($arg) => \cos($arg) / \sin($arg), - 'decbin' => static fn($arg) => \decbin($arg), - 'dechex' => static fn($arg) => \dechex($arg), - 'decoct' => static fn($arg) => \decoct($arg), - 'deg2rad' => static fn($arg) => \deg2rad($arg), - 'exp' => static fn($arg) => \exp($arg), - 'expm1' => static fn($arg) => \expm1($arg), - 'floor' => static fn($arg) => \floor($arg), - 'fmod' => static fn($arg1, $arg2) => \fmod($arg1, $arg2), - 'hexdec' => static fn($arg) => \hexdec($arg), - 'hypot' => static fn($arg1, $arg2) => \hypot($arg1, $arg2), + 'bindec' => static fn ($arg) => \bindec($arg), + 'ceil' => static fn ($arg) => \ceil($arg), + 'cos' => static fn ($arg) => \cos($arg), + 'cosec' => static fn ($arg) => 1 / \sin($arg), + 'csc' => static fn ($arg) => 1 / \sin($arg), + 'cosh' => static fn ($arg) => \cosh($arg), + 'ctg' => static fn ($arg) => \cos($arg) / \sin($arg), + 'cot' => static fn ($arg) => \cos($arg) / \sin($arg), + 'cotan' => static fn ($arg) => \cos($arg) / \sin($arg), + 'cotg' => static fn ($arg) => \cos($arg) / \sin($arg), + 'ctn' => static fn ($arg) => \cos($arg) / \sin($arg), + 'decbin' => static fn ($arg) => \decbin($arg), + 'dechex' => static fn ($arg) => \dechex($arg), + 'decoct' => static fn ($arg) => \decoct($arg), + 'deg2rad' => static fn ($arg) => \deg2rad($arg), + 'exp' => static fn ($arg) => \exp($arg), + 'expm1' => static fn ($arg) => \expm1($arg), + 'floor' => static fn ($arg) => \floor($arg), + 'fmod' => static fn ($arg1, $arg2) => \fmod($arg1, $arg2), + 'hexdec' => static fn ($arg) => \hexdec($arg), + 'hypot' => static fn ($arg1, $arg2) => \hypot($arg1, $arg2), 'if' => function($expr, $trueval, $falseval) { if (true === $expr || false === $expr) { $exres = $expr; @@ -476,39 +468,39 @@ protected function defaultFunctions() : array return $this->execute($falseval); }, - 'intdiv' => static fn($arg1, $arg2) => \intdiv($arg1, $arg2), - 'ln' => static fn($arg) => \log($arg), - 'lg' => static fn($arg) => \log10($arg), - 'log' => static fn($arg) => \log($arg), - 'log10' => static fn($arg) => \log10($arg), - 'log1p' => static fn($arg) => \log1p($arg), + 'intdiv' => static fn ($arg1, $arg2) => \intdiv($arg1, $arg2), + 'ln' => static fn ($arg) => \log($arg), + 'lg' => static fn ($arg) => \log10($arg), + 'log' => static fn ($arg) => \log($arg), + 'log10' => static fn ($arg) => \log10($arg), + 'log1p' => static fn ($arg) => \log1p($arg), 'max' => static function($arg1, ...$args) { if (\is_array($arg1) && 0 === \count($arg1)){ - throw new \InvalidArgumentException('Array must contain at least one element!'); + throw new \InvalidArgumentException('max() must have at least one argument!'); } return \max(\is_array($arg1) ? $arg1 : [$arg1, ...$args]); }, 'min' => static function($arg1, ...$args) { if (\is_array($arg1) && 0 === \count($arg1)){ - throw new \InvalidArgumentException('Array must contain at least one element!'); + throw new \InvalidArgumentException('min() must have at least one argument!'); } return \min(\is_array($arg1) ? $arg1 : [$arg1, ...$args]); }, - 'octdec' => static fn($arg) => \octdec($arg), - 'pi' => static fn() => M_PI, - 'pow' => static fn($arg1, $arg2) => $arg1 ** $arg2, - 'rad2deg' => static fn($arg) => \rad2deg($arg), - 'round' => static fn($num, int $precision = 0) => \round($num, $precision), - 'sin' => static fn($arg) => \sin($arg), - 'sinh' => static fn($arg) => \sinh($arg), - 'sec' => static fn($arg) => 1 / \cos($arg), - 'sqrt' => static fn($arg) => \sqrt($arg), - 'tan' => static fn($arg) => \tan($arg), - 'tanh' => static fn($arg) => \tanh($arg), - 'tn' => static fn($arg) => \tan($arg), - 'tg' => static fn($arg) => \tan($arg) + 'octdec' => static fn ($arg) => \octdec($arg), + 'pi' => static fn () => M_PI, + 'pow' => static fn ($arg1, $arg2) => $arg1 ** $arg2, + 'rad2deg' => static fn ($arg) => \rad2deg($arg), + 'round' => static fn ($num, int $precision = 0) => \round($num, $precision), + 'sin' => static fn ($arg) => \sin($arg), + 'sinh' => static fn ($arg) => \sinh($arg), + 'sec' => static fn ($arg) => 1 / \cos($arg), + 'sqrt' => static fn ($arg) => \sqrt($arg), + 'tan' => static fn ($arg) => \tan($arg), + 'tanh' => static fn ($arg) => \tanh($arg), + 'tn' => static fn ($arg) => \tan($arg), + 'tg' => static fn ($arg) => \tan($arg) ]; } diff --git a/tests/MathTest.php b/tests/MathTest.php index 59ce207..0c87c45 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -351,8 +351,8 @@ public function bcMathExpressions() ['tan(1.5)'], ['tanh(1.5)'], - ['0.1 + 0.2'], - ['0.1 + 0.2 - 0.3'], + ['0.1 + 0.2', '0.30'], + ['0.1 + 0.2 - 0.3', '0.00'], ['1 + 2'], ['0.1 - 0.2'], @@ -608,7 +608,7 @@ public function testArrays() : void $this->assertEquals(\max([1, 5, 2]), $calculator->execute('max(array(1, 5, 2))')); $calculator->addFunction('arr_with_max_elements', static function($arg1, ...$args) { $args = \is_array($arg1) ? $arg1 : [$arg1, ...$args]; - \usort($args, static fn($arr1, $arr2) => \count($arr2) <=> \count($arr1)); + \usort($args, static fn ($arr1, $arr2) => \count($arr2) <=> \count($arr1)); return $args[0]; }); @@ -687,53 +687,105 @@ public function testFunctionIncorrectNumberOfParametersTooMany() : void public function testFunctionIf() : void { $calculator = new MathExecutor(); - $this->assertEquals(30, $calculator->execute( + $this->assertEquals( + 30, + $calculator->execute( 'if(100 > 99, 30, 0)' - )); - $this->assertEquals(0, $calculator->execute( + ), + 'Expression failed: if(100 > 99, 30, 0)' + ); + $this->assertEquals( + 0, + $calculator->execute( 'if(100 < 99, 30, 0)' - )); - $this->assertEquals(30, $calculator->execute( + ), + 'Expression failed: if(100 < 99, 30, 0)' + ); + $this->assertEquals( + 30, + $calculator->execute( 'if(98 < 99 && sin(1) < 1, 30, 0)' - )); - $this->assertEquals(40, $calculator->execute( + ), + 'Expression failed: if(98 < 99 && sin(1) < 1, 30, 0)' + ); + $this->assertEquals( + 40, + $calculator->execute( 'if(98 < 99 && sin(1) < 1, max(30, 40), 0)' - )); - $this->assertEquals(40, $calculator->execute( + ), + 'Expression failed: if(98 < 99 && sin(1) < 1, max(30, 40), 0)' + ); + $this->assertEquals( + 40, + $calculator->execute( 'if(98 < 99 && sin(1) < 1, if(10 > 5, max(30, 40), 1), 0)' - )); - $this->assertEquals(20, $calculator->execute( + ), + 'Expression failed: if(98 < 99 && sin(1) < 1, if(10 > 5, max(30, 40), 1), 0)' + ); + $this->assertEquals( + 20, + $calculator->execute( 'if(98 < 99 && sin(1) > 1, if(10 > 5, max(30, 40), 1), if(4 <= 4, 20, 21))' - )); - $this->assertEquals(\cos(2), $calculator->execute( + ), + 'Expression failed: if(98 < 99 && sin(1) > 1, if(10 > 5, max(30, 40), 1), if(4 <= 4, 20, 21))' + ); + $this->assertEquals( + \cos(2), + $calculator->execute( 'if(98 < 99 && sin(1) >= 1, max(30, 40), cos(2))' - )); - $this->assertEquals(\cos(2), $calculator->execute( + ), + 'Expression failed: if(98 < 99 && sin(1) >= 1, max(30, 40), cos(2))' + ); + $this->assertEquals( + \cos(2), + $calculator->execute( 'if(cos(2), cos(2), 0)' - )); + ), + 'Expression failed: if(cos(2), cos(2), 0)' + ); $trx_amount = 100000; $calculator->setVar('trx_amount', $trx_amount); $this->assertEquals($trx_amount, $calculator->execute('$trx_amount')); - $this->assertEquals($trx_amount * 0.03, $calculator->execute( + $this->assertEquals( + $trx_amount * 0.03, + $calculator->execute( 'if($trx_amount < 40000, $trx_amount * 0.06, $trx_amount * 0.03)' - )); - $this->assertEquals($trx_amount * 0.03, $calculator->execute( + ), + 'Expression failed: if($trx_amount < 40000, $trx_amount * 0.06, $trx_amount * 0.03)' + ); + $this->assertEquals( + $trx_amount * 0.03, + $calculator->execute( 'if($trx_amount < 40000, $trx_amount * 0.06, if($trx_amount < 60000, $trx_amount * 0.05, $trx_amount * 0.03))' - )); + ), + 'Expression failed: if($trx_amount < 40000, $trx_amount * 0.06, if($trx_amount < 60000, $trx_amount * 0.05, $trx_amount * 0.03))' + ); $trx_amount = 39000; $calculator->setVar('trx_amount', $trx_amount); - $this->assertEquals($trx_amount * 0.06, $calculator->execute( + $this->assertEquals( + $trx_amount * 0.06, + $calculator->execute( 'if($trx_amount < 40000, $trx_amount * 0.06, if($trx_amount < 60000, $trx_amount * 0.05, $trx_amount * 0.03))' - )); + ), + 'Expression failed: if($trx_amount < 40000, $trx_amount * 0.06, if($trx_amount < 60000, $trx_amount * 0.05, $trx_amount * 0.03))' + ); $trx_amount = 59000; $calculator->setVar('trx_amount', $trx_amount); - $this->assertEquals($trx_amount * 0.05, $calculator->execute( + $this->assertEquals( + $trx_amount * 0.05, + $calculator->execute( 'if($trx_amount < 40000, $trx_amount * 0.06, if($trx_amount < 60000, $trx_amount * 0.05, $trx_amount * 0.03))' - )); + ), + 'Expression failed: if($trx_amount < 40000, $trx_amount * 0.06, if($trx_amount < 60000, $trx_amount * 0.05, $trx_amount * 0.03))' + ); $this->expectException(IncorrectNumberOfFunctionParametersException::class); - $this->assertEquals(0.0, $calculator->execute( + $this->assertEquals( + 0.0, + $calculator->execute( 'if($trx_amount < 40000, $trx_amount * 0.06)' - )); + ), + 'Expression failed: if($trx_amount < 40000, $trx_amount * 0.06)' + ); } public function testVariables() : void @@ -1043,40 +1095,32 @@ public function testCalculatingValues($expression, $value) : void public function providerExpressionValues() { return [ - ['arccos(0.5)', 1.0471975511966], ['arccos(0.5)', \acos(0.5)], - ['arccosec(4)', 0.2526802551421], ['arccosec(4)', \asin(1 / 4)], ['arccot(3)', M_PI / 2 - \atan(3)], - ['arccotan(4)', 0.2449786631269], ['arccotan(4)', M_PI / 2 - \atan(4)], - ['arccsc(4)', 0.2526802551421], ['arccsc(4)', \asin(1 / 4)], ['arcctg(3)', M_PI / 2 - \atan(3)], - ['arcsec(4)', 1.3181160716528], ['arcsec(4)', \acos(1 / 4)], - ['arcsin(0.5)', 0.5235987755983], ['arcsin(0.5)', \asin(0.5)], ['arctan(0.5)', \atan(0.5)], - ['arctan(4)', 1.3258176636680], + ['arctan(4)', \atan(4)], ['arctg(0.5)', \atan(0.5)], ['cosec(12)', 1 / \sin(12)], - ['cosec(4)', -1.3213487088109], + ['cosec(4)', 1 / \sin(4)], ['cosh(12)', \cosh(12)], ['cot(12)', \cos(12) / \sin(12)], ['cotan(12)', \cos(12) / \sin(12)], - ['cotan(4)', 0.8636911544506], + ['cotan(4)', \cos(4) / \sin(4)], ['cotg(3)', \cos(3) / \sin(3)], ['csc(4)', 1 / \sin(4)], ['ctg(4)', \cos(4) / \sin(4)], ['ctn(4)', \cos(4) / \sin(4)], ['decbin(10)', \decbin(10)], - ['lg(2)', 0.3010299956639], ['lg(2)', \log10(2)], - ['ln(2)', 0.6931471805599], ['ln(2)', \log(2)], - ['sec(4)', -1.5298856564664], - ['tg(4)', 1.1578212823496], + ['sec(4)', 1 / \cos(4)], + ['tg(4)', \tan(4)], ]; }