<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Fun with chaos</title>
    <link rel="stylesheet" href="css/main.css" type="text/css" media="screen" />
</head>
<body>
<h1>Fun with chaos</h1>
<h3>By Thomas Stig Jacobsen</h3><br />
<?php
(float) $k = (isset($_GET["k"]) && $_GET["k"] > 0) ? $_GET["k"] : 2.5;
(array) 
$results = array("0" => (float) 0.2);

for (
$i=1$i <= 1000$i++) {
    (float) 
$results[$i] = $k*$results[$i-1]*(1-$results[$i-1]);
}
(array) 
$resultCopy $results;
(array) 
$arrayChunks array_chunk($results100);
(array) 
$shownResults $arrayChunks[0];
echo 
"    <strong>Graphical display of the 100 first values:</strong><br />
        <center>
            <img src=\"http://chart.apis.google.com/chart?chxt=x,y&chxr=0,0,100|1,0,1&chds=0,1,0,1&chs=900x300&cht=lc&chco=0077CC&chd=t:" 
implode(","$shownResults) . "\">
        </center><br /><br />"
;

$countResult = (int) count($resultCopy)-count(array_unique($resultCopy));
echo 
"<strong>Based on:</strong> <img src=\"formel.png\" width=\"250px\" alt=\"Formel\" /><br />";
echo 
"<strong>k:</strong> " $k "<br />";
echo 
"<strong>f<sub>k</sub>(x<sub>0</sub>):</strong> " $results[0] . "<br />";
echo 
"<strong>Duplicate values:</strong> " $countResult "<br /><br />";
echo 
"<strong>Here comes the data:</strong><br /><dd>";
foreach (
$results as $key => $result) {
    echo 
"x<sub>" $key "</sub>: " $result "<br />";
}
echo 
"</dd>"
?>
</body>
</html>