Yeah, so I need to find the roots of a polynomial in php using arrays. So far, I have a functions page with: function rootsPolynomials($poly,$x) {
$array = array($a,$b,$c);
// ax^2 + bx + c = 0then I need to solve for x???
return ($a * (pow($x,2))) + ($b * $x) + $c == 0;
}
and then I have my forms.php to display what I have:
<div id="uhoh"><?php
if($category == 'quadratic'){
if(!is_numeric($a) || !is_numeric($b) || !is_numeric($c)) {
echo "Uh oh! Input a numerical value, please.";
} else {
if ($operation == 'discriminant'){
$discriminant = discriminant($a,$b,$c);
echo "The discriminant of ($a,$b,$c) is $discriminant.";
} else {
if ($operation == 'polynomial'){
$polynomial = rootsPolynomials($poly,$x);
echo "The roots of the polynomial $a x + $b x^2 + $c is $x and $poly.";
}
}
}
}
?>
</div>
I have no idea how to use arrays, but I have to use them. I can't seem to get it to show up, nor can I seem to get it to solve the polynomial. Help?
$array = array($a,$b,$c);
// ax^2 + bx + c = 0then I need to solve for x???
return ($a * (pow($x,2))) + ($b * $x) + $c == 0;
}
and then I have my forms.php to display what I have:
<div id="uhoh"><?php
if($category == 'quadratic'){
if(!is_numeric($a) || !is_numeric($b) || !is_numeric($c)) {
echo "Uh oh! Input a numerical value, please.";
} else {
if ($operation == 'discriminant'){
$discriminant = discriminant($a,$b,$c);
echo "The discriminant of ($a,$b,$c) is $discriminant.";
} else {
if ($operation == 'polynomial'){
$polynomial = rootsPolynomials($poly,$x);
echo "The roots of the polynomial $a x + $b x^2 + $c is $x and $poly.";
}
}
}
}
?>
</div>
I have no idea how to use arrays, but I have to use them. I can't seem to get it to show up, nor can I seem to get it to solve the polynomial. Help?