PHP Classes

PHP Equation Solver: Solve linear, quadratic and polynomial equations

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 62%Total: 376 All time: 6,758 This week: 560Up
Version License PHP version Categories
equation-solver 1.2BSD License5PHP 5, Math
Description 

Author

This class can solve linear, quadratic and polynomial equations.

It takes a string with a given equation with coefficients and variables and parses the equation.

The class can simplify and solve the equation.

Picture of Samuel Adeshina
  Performance   Level  
Name: Samuel Adeshina is available for providing paid consulting. Contact Samuel Adeshina .
Classes: 19 packages by
Country: Nigeria Nigeria
Age: 25
All time rank: 5222 in Nigeria Nigeria
Week rank: 69 Up5 in Nigeria Nigeria Down
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Example

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Equation Solver | Solve Your Everyday Maths Equation Problem</title>
    <style>
        body{
                height: 100%;
                background-color: #ADD8E6;
            }
        #equa{
            font-size: 1.5em;
        }
        #equa:hover, #eq:active
        {
            font-size: 2em;
        }
        #down
        {
            background-color: #fff;
            height: auto;
            width: 80%;
            border: 1px solid #000;
            border-radius: 20px;
            margin: 2% 0% 0% 10%;
        }
        #h{
            margin-left: 2%;
            text-align: center;
        }
        #h > h1
        {
            font-variant: small-caps;
            letter-spacing: 20px;
            text-shadow: 1px 1px 10px #fff;
        }
        #m{
            font-size: 1.2em;
        }
    </style>
</head>
<body>
    <div id = "h"><h1>Equation Solver</h1>
    <p>Solve Your Linear, Quadratic, Trinomial or Polynomial Equations All In One Place Without Worrying About Variables!</p></div>
<form style = "margin-left: 0.2%; text-align: center" action = "<?php echo $_SERVER['PHP_SELF'];?>" method = "POST">
    <p style = "font-size: 1.5em"></p><br/>
    <input id = "equa" type = "text" style = "width: 100%; height: 40px; text-align: center;" name = "equation" placeholder = "Enter an equation using any variable of choice except e and E. Represent Exponents using either of e or E"/><br/>
    <br/>Show error messages: <input type = "radio" name = "error" value = "true">true</input>&nbsp;&nbsp;<input type = "radio" name = "error" value = "false">false</input>
    <br/><br/><input type = "Submit" style = "width: 50%; height: 50px">
</form>
<?php
require_once("EquationSolver.php");
    if (!isset(
$_POST["error"]))
    {
       
$_POST["error"] = "true";
    }
    if (isset(
$_POST["equation"]))
    {
       
$equation = $_POST["equation"];
       
$errors = $_POST["error"];
       
$equation = new Solve($equation, $errors);
       
$var = $equation->solution()[0];
       
$solutions = $equation->solution()[1];
        echo
"<div id = \"down\"><br/>";
        echo
"<center>The equation <i>\"$equation->equation\"</i> which you asked me to solve is a <i>\"$equation->equationType Equation\"</i><br/>The Solution(s) is/are: <br/>";
        foreach (
$solutions as $solution)
        {
            if (
is_nan($solution))
            {
               
$solution = $solution . "&nbsp;&nbsp;(Solution results in Complex Numbers)";
            }
            if (
$solution == $solutions[0])
            {
                echo
"<br/><b>$var = $solution</b><br/>";
            }
            else
            {
                echo
"or<br/><b>$var = $solution</b><br/>";
            }
        }
        echo
"</center><br/></div>";
    }
    else
    {
echo <<<_END
<div id = "down">
    <p style = "font-size: 1.5em; text-align: center">Examples of equations you can try out (Just copy and paste them into the text box)</p>
    <ol style = "font-size: 1.5em">
        <li> -1019b + 14b - 81b - 2000 + 48b = 800b - 8080 + 41b</li>
        <li> 8x + 4x - 3x - 100 = -99x + 11 </li>
        <li> xE2 + 5x - 20 = 8x + 20 </li>
        <li> Ae2 - 1A + 1 = 0 </li>
    </ol>
</div>
_END;
    }
?>
<br/><br/><center><p id = "m">&copy;2015 - <a href = "https://plus.google.com/+SamuelAdeshina73">Samuel Adeshina</a> &lt;samueladeshina73@gmail.com&gt; | <a href = "http://samshaltechs.blogspot.com">samshaltechs.blogspot.com</a> | <a href = "https://twitter.com/SamuelAdeshina6">@samueladeshina6</a></p></center>
</body>
</html>


Details

Equation-Solver

A PHP Class that parses and solves different type of equations


  Files folder image Files (5)  
File Role Description
Plain text file EquationSolver.php Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file QuickTestFile.php Test You can use this test file to quickly solve an equation by just passing it as a get variable
Accessible without login Plain text file README.md Data Documentation
Accessible without login Plain text file test.php Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:376
This week:0
All time:6,758
This week:560Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:62%StarStarStarStar
Rank:940