Download the PHP package gamajo/quadratic without Composer
On this page you can find all versions of the php package gamajo/quadratic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gamajo/quadratic
More information about gamajo/quadratic
Files in gamajo/quadratic
Package quadratic
Short Description Handle solving of quadratic equations.
License MIT
Informations about the package quadratic
Gamajo Quadratic Equation Solver
PHP classes for working with, and solving, quadratic equations.
What Is A Quadratic Equation?
A quadratic equation is a univariate polynomial with degree of 2, that is then set to equal zero so that the indeterminate can be determined:
ax2 + bx + c = 0
Equations can often be solved with factoring or completing the square, but there is also a Quadratic Formula:
The QuadraticEquation interface constructor accepts values for a, b and c and the Solver can return one or both roots, including imaginary roots.
Installation
Requires PHP 7.
Usage
Basic Usage
Create an equation object, pass that to the solver, solve, and retrieve the roots:
The Solver has no problem with complex roots:
BasicQuadraticEquation
Methods
The BasicQuadraticEquation
class implements the QuadraticEquation
interface, which in turn extends the Equation
interface. As such, it supports the following methods:
There is also a hasValidArguments()
method, but as this library uses scalar type declarations, the manual check to see if they are all integers is somewhat redundant.
Solver
Methods
The Solver
class can optionally set the maximum decimal place precision of the roots:
Change Log
See the change log.
License
MIT.
Contributions
Contributions are welcome - fork, fix and send pull requests against the develop
branch please.
Credits
Built by Gary Jones.
Original procedural code version, copyright 2004 Gary Jones.
This version copyright 2016 Gamajo Tech