# Proposal for "Math_Assoc"

• Status: Proposed
» Description
// WHAT IS MATH_ASSOC?
// MATH_ASSOC is a PHP class, that can:
// 1. calculate any math expression
// 3. check numbers (prime,negative,positive,null)
// 4. find greatest/least common multiple/divisor
// 5. convert units/measures
// 6. manipulate dates
//

//MATH_ASSOC syntax
/*
# {number} square root
# 6^2 six of the second degree (returns 36)
# 5%2 returns the remainder of 5/2 (returns 1)
!!! ALL OTHER OPERATIONS HAVE THE SAME SYNTAX LIKE PHP (*+-/()) !!!
*/

//building a form using MATH_ASSOC class
/*
<?
if(\$_POST['submit'])
{
\$this->exec(\$_POST['str']);
}
?>
<form method="post" name="equ" action="<? echo \$_SERVER[PHP_SELF]; ?>">
<input type="text" id="str" name="str" value="<? echo \$_POST[str]; ?>" size="30"/>
<input class="mstr" type="submit" name="submit" value="Go!"/>
<input type="reset" onClick="javascript:decision('Do you really want to reset?','<? echo \$_SERVER[PHP_SELF]; ?>');"/>
</form>
*/

//main functions
# \$math_assoc->view(); echoes an example form that includes all the features of the class.
# echo \$math_assoc->exec("2x+3=6"); echoes full solution of the equation with 1 root
# echo \$math_assoc->compute("2x+3=6"); returns the answer of the equation with 1 root
# echo \$math_assoc->compute("2x+3=6","x"); returns the same as above
# echo \$math_assoc->compute("{5^5}"); returns short answer 5
# echo \$math_assoc->compute("x^2+x+2=0","d"); returns the discriminant of the equation

# echo \$math_assoc->flip_sign(\$num); multiples \$num by (-1)
# echo \$math_assoc->is_positive(\$num); returns true or false
# echo \$math_assoc->is_negative(\$num); returns true or false
# echo \$math_assoc->is_null(\$num); returns true or false

# echo \$math_assoc->isPrime("2+1"); returns boolean true if prime; if(\$math_assoc->isPrime("2+2")==true) { ... } else { ... }
# echo \$math_assoc->gcm(12,24); returns the greatest common multiple of two numbers
# echo \$math_assoc->gcm_nums( array(12, 24, 48) ); returns the greatest common multiple of more then two numbers
# echo \$math_assoc->lcm(12,4); returns the least common multiple of two numbers
# echo \$math_assoc->lcm_nums( array(6, 10, 4, 9, 54) ); returns the least common multiple of more than two numbers
# echo \$math_assoc->gcd_(6,12); returns the greatest common divisor of two numbers
# echo \$math_assoc->gcd_nums( array(6, 12) ); returns the greatest common divisor of more then two numbers

// romanic system
# echo \$math_assoc->arabic2romanic("24"); returns a romanic number
# echo \$math_assoc->arabic2romanic("{21+4}"); it calculates, and then returns a romanic number
# echo \$math_assoc->romanic2arabic("XXIV"); returns an arabic number, if an arabic one is given

//"convert" examples

//date manipulator