Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
PHP를위한 강력한 현대 수학 라이브러리 : 설명적인 통계 및 회귀 분석 기능; 연속적이고 이산 된 확률 분포; 행렬 및 벡터를 이용한 선형 대수학, 수치 해석; 특별한 수학 함수; 대수학
MathPHP is the only library you need to integrate mathematical functions into your applications. It is a self-contained library in pure PHP with no external dependencies.
MathPHP는 수학 함수를 응용 프로그램에 통합하는 데 필요한, 외부 의존성이없는 순수한 PHP의 독립적 라이브러리.
Minimum Requirements
- PHP7
Install composer
$ composer search math-php markrogoyski/math-php Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability ... $ composer require markrogoyski/math-php ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing markrogoyski/math-php (v0.29.0): Downloading (100%) Writing lock file Generating autoload files
Use
require_once(__DIR__ . '/vendor/autoload.php'); use MathPHP\Algebra; // Greatest common divisor (GCD) $gcd = Algebra::gcd(8, 12); // Extended greatest common divisor - gcd(a, b) = a*a' + b*b' $gcd = Algebra::extendedGcd(12, 8); // returns array [gcd, a', b'] // Least common multiple (LCM) $lcm = Algebra::lcm(5, 2); // Factors of an integer $factors = Algebra::factors(12); // returns [1, 2, 3, 4, 6, 12] // Quadradic equation // list($a, $b, $c) = [1, 2, -8]; // x² + 2x - 8 // list($x₁, $x₂) = Algebra::Quadradic($a, $b, $c); // var_dump( $x₁, $x₂ ); // php7.1.5 Algebra::Quadradic 2.9 버전에서 : PHP Fatal error: Uncaught Error: Call to undefined method MathPHP\Algebra::Quadradic() // Cubic equation list($a₃, $a₂, $a₁, $a₀) = [2, 9, 3, -4]; // 2x³ + 9x² + 3x -4 list($x₁, $x₂, $x₃) = Algebra::cubic($a₃, $a₂, $a₁, $a₀); var_dump( $x₁, $x₂, $x₃ ); // Quartic equation list($a₄, $a₃, $a₂, $a₁, $a₀) = [1, -10, 35, -50, 24]; // z⁴ - 10z³ + 35z² - 50z + 24 = 0 list($z₁, $z₂, $z₃, $z₄) = Algebra::quartic($a₄, $a₃, $a₂, $a₁, $a₀); var_dump($z₁, $z₂, $z₃, $z₄);
반응형
'lang > php' 카테고리의 다른 글
Ubuntu php7.1/7.2 Switch (0) | 2018.03.02 |
---|---|
Yii model get query (0) | 2017.08.25 |
php7.1 Catching Multiple Exception Types (0) | 2017.05.31 |
brew php-xdebug (0) | 2017.05.29 |
Multi-library chart PHP (0) | 2017.05.26 |