Recommend this page to a friend! 
Download .zip 
Info  Example  Demos  View files (17)  Download .zip  Reputation  Support forum  Blog  Links 
Ratings  Unique User Downloads  Download Rankings  
61%  Total: 2,015  All time: 1,937 This week: 160 
Version  License  PHP version  Categories  
eos 3.2.1  GNU Lesser Genera...  5.3  Graphics, Math 
Description  Author  
This class solves equations with multiple variables. Innovation Award

Install EOS with Composer
Add the dependency:
"require": {
"jlawrence/eos": "3.*"
}
Run composer update
and you're done.
This class makes it incredibly easy to use and parse/solve equations in
your own applications. __NOTE__ ALL of the functions within
these classes are static. It is also important to note that these
classes throw exceptions if running in to errors, please read the beginning
of the Math.php
file for the defines of the exceptions thrown. Exceptions
includes a descriptive message of the error encountered and within Parser
will
also typically include the full equation used.
This class has one important function, Parser::solve()
which does all the legwork,
so we'll start there and end with examples.
use jlawrence\eos\Parser;
To use this function:
$value = Parser::solve($eq, $vars);
Is simply a standard equation with variable support.
Example Equations:
2(4x)
5+((1+2)*4)+3
5+4(1+2)+3
10*sin(x)
10*cos(x)
The parser has good implied multiplication.
The variables are fairly simple to understand. If it contains a scalar (ie
a nonarray value) _every_ variable within the equation will be replaced with
that number. If it contains an array, there will be a byvariable replacement 
note that the array MUST be in the format of 'variable' => value
Such as:
array(
'x' => 2,
'y' => 3
);
Given the equation:
5x^y
If this is called by:
Parser::solveIF('5x^y', 2);
It will equal '20', as every variable is replaced by 2. However, if called like:
Parser::solveIF('5x^y', array(
'x' => 2,
'y' => 3));
You will get the result of '40' as it would equate to 5*2^3
, as expected.
To use:
use jlawrence\eos\Graph;
This is the fun class that can create graphs. The image will default to 640x480, to initialize a different size use:
Graph::init($width, $height);
The $width
and $height
are the values used for the image size.
This method will generate the graph for the equation ($eq
) with a min and max
x
range that it will parse through. All Variables explained:
If you don't want the axis' labeled with their numbers, you can turn off the default behavior with:
Graph::$labelAxis = false;
TODO:
To set up a graph with a 21x21
window (ie 10 to 10
) for the equation
sin(x)
and output as PNG, would use as:
Graph::graph('sin(x)', 10, 10, 0.01, true, false, 10, 10);
Graph::outPNG();
It would look like:
Run the unit tests by first installing phpunit with (from the repository root)
composer update
Then run the tests with
phpunit
When creating classes for adding functions to the package, make sure to call
Parser::solveIF()
instead of Parser::solve()
so that the class retains
the full original equation used by the user.
Files 
File  Role  Description  

src (7 files)  
tests (1 directory)  
README.md  Doc.  Description of class functionality and use cases  
.codeclimate.yml  Data  For testing  
.travis.yml  Data  For testing  
composer.json  Data  Auxiliary data  
index.php  Example  Example usage of graphing function  
phpunit.xml  Data  For testing 
Files  /  src 
File  Role  Description 

AdvancedFunctions.php  Class  Class source 
Graph.php  Class  Class source 
Math.php  Class  Class source 
Matrix.php  Class  Class source 
Parser.php  Class  Class source 
Stack.php  Class  Class source 
Trig.php  Class  Class source 
Files  /  tests  /  unit 
File  Role  Description 

GraphTest.php  Test  For testing 
MatrixTest.php  Test  For testing 
ParserTest.php  Test  Unit test script 
StackTest.php  Test  For testing 
Version Control  Unique User Downloads  Download Rankings  
94% 


User Ratings  

Applications that use this package 
Equation Grapher Online graphing calculator 
If you know an application of this package, send a message to the author to add a link here.
Related pages 
GitHub Github with readme 
Pages that reference this package 
complex mathematical operations (Turkish) For these complex equations there is a class... 