<html>
<head>
<title>Nulpunten zoeken van een kwadratische verlijking</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if (isSet($_POST['Submit'])) {
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c'];
// Functie die controleert of $var wel een (negatief/positief) getal is.
function check_getal($var) {
return ereg("^[-0-9]{0,10}$", $var); }
if(check_getal($a) == false || check_getal($b) == false || check_getal($c) == false) {
exit("Voeg getallen in aub!"); }
$machtb = $b*$b;
$discriminant = $machtb - 4 * $a * $c;
if ($discriminant == 0) {
//Discriminant is gelijk aan 0 -> één nulpunt
$opl = $machtb / 2 * $a;
} elseif ($discriminant > 0) {
//Discriminant is groter dan 0 -> Twee nulpunten
$opl1 = (-$b + sqrt($discriminant)) / 2 * $a; $opl2 = (-$b - sqrt($discriminant)) / 2 * $a; }
}
?>
<table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolor="#000000">
<tr>
<td style="backgroud-color: #e2e2e2"><font black><b>Vul drie waardes in:</b></font><i></i></td>
</tr>
<tr>
<td style="backgroud-color: #CCCCCC; height: 30"> <form method="post" action="">Y =
<input type="text" name="a" maxlength="10" size="3">x² +
<input type="text" name="b" maxlength="10" size="3">x +
<input type="text" name="c" maxlength="10" size="3">= 0
<input type="submit" name="Submit" value="Bereken">
</form>
</td>
</tr>
<?php
if (isSet($_POST['Submit'])) { ?>
<tr>
<td>
<u><b>Waardes:</b></u><br><br>
<i>(<b>a</b>:
<?php echo $a; ?>, <b>b</b>:
<?php echo $b; ?>, <b>c</b>:
<?php echo $c; ?>)</i><br><br>
<u><b>Discriminant:</b></u><br> <table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%" style="color: #FF0000"><b>D</font></b></td>
<td width="95%" style="color: #FF0000"><b> = b²-4ac</b></td>
</tr>
<tr>
<td width="5%"> </td>
<td width="95%">=
<?php echo $machtb." - 4 x ".$a." x ".$c; ?></td>
</tr>
<tr>
<td width="5%"> </td>
<td width="95%">= <b>
<?php echo $discriminant; ?></b></td>
</tr>
</table>
<?php
if ($discriminant > 0) {
?> <p>De discriminant is <b>groter dan 0</b> dus er zijn <b>twee nulpunten (x1 en x2)</b>:</p>
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td> </td>
<td align="center">
-b + <img src="sqrt.jpg" width="14" height="14">D
</td>
<td align="center"> </td>
<td>
-
<?php echo $b; ?> + <img src="sqrt.jpg" width="14" height="14">
<?php echo $discriminant; ?> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="2"><b>x1</b>=</td>
<td height="2" align="center">----------</td>
<td height="2">=</td>
<td height="2" align="center">----------</td>
<td height="2">=</td>
<td height="2" style="color: #FF0000"><b>
<?php echo $opl1; ?></b></td>
</tr>
<tr>
<td> </td>
<td align="center">2a</td>
<td> </td>
<td align="center">2 x
<?php echo $a; ?> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td> </td>
<td align="center">-b - <img src="sqrt.jpg" width="14" height="14">D</td>
<td> </td>
<td>-
<?php echo $b; ?> - <img src="sqrt.jpg" width="14" height="14">
<?php echo $discriminant; ?></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="2"><b>x2</b>=</td>
<td height="2" align="center">----------</td>
<td height="2">=</td>
<td height="2" align="center">----------</td>
<td height="2">=</td>
<td height="2" style="color: #FF0000"><b>
<?php echo $opl2; ?></b></td>
</tr>
<tr>
<td> </td>
<td align="center">2a</td>
<td> </td>
<td align="center">2 x
<?php echo $a; ?> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p><u><b>Verzameling:</b></u><br><br>
V=<b>{</b>x1 <b>,</b> x2<b>}</b> = <b>{</b>
<?php echo $opl1; ?><b> , </b>
<?php echo $opl2; ?><b>}</b></p>
<?php
} elseif ($discriminant == 0) {
?>
<p>De discriminant is <b>gelijk aan 0 </b>dus er is één nulpunt <b> (x1 = x2)</b>:</p>
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td> </td>
<td align="center">b²</td>
<td> </td>
<td align="center">
<?php echo $b; ?>²</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="2"><b>x1=x2=</b></td>
<td height="2" align="center">------</td>
<td height="2">=</td>
<td height="2" align="center">------</td>
<td height="2">=</td>
<td height="2" style="color: #FF0000"><b>
<?php echo $opl; ?></b></td>
</tr>
<tr>
<td> </td>
<td>2 x a</td>
<td> </td>
<td align="center">2 x
<?php echo $a; ?></td>
<td> </td>
<td> </td>
</tr>
</table>
<br>
<u><b>Verzameling:</b></u><br><br>V=<b>{</b>x1=x2<b>}</b> = <b>{</b>
<?php echo $opl; ?><b>}</b>
<?php
} elseif ($discriminant < 0) {
?>
<p>De discriminant is <b>kleiner dan 0 </b>dus er zijn geen nulpunten:<br>
<br>
<u><b>Verzameling:</b></u><br></p><br>V=<b>{</b>Ø<b>}</b> </td>
<?php
}
?>
</tr>
<?php } ?>
</table>
</body>
</html>