Quadratic Equation Solver
Roots:
';
$callStartTime = microtime(true);
$discriminantFormula = '=POWER('.$_POST['B'].',2) - (4 * '.$_POST['A'].' * '.$_POST['C'].')';
$discriminant = PHPExcel_Calculation::getInstance()->calculateFormula($discriminantFormula);
$r1Formula = '=IMDIV(IMSUM(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].')';
$r2Formula = '=IF('.$discriminant.'=0,"Only one root",IMDIV(IMSUB(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].'))';
echo PHPExcel_Calculation::getInstance()->calculateFormula($r1Formula).'
';
echo PHPExcel_Calculation::getInstance()->calculateFormula($r2Formula).'
';
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo '
Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds
';
echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB
';
}
}
?>