with(Math){   
     aVar = round(10*random()+1)
     bVar = round(50*random()+1)
     cVar = round(50*random()+1)
     sVar = bVar/(2*aVar)
     dVar = round(bVar/(2*aVar)-10*random()-1)
     eVar = round(bVar/(2*aVar)+10*random()+1)
     fdVar = aVar*dVar*dVar-bVar*dVar+cVar
     feVar = aVar*eVar*eVar-bVar*eVar+cVar
     fsVar = aVar*sVar*sVar-bVar*sVar+cVar
   }
document.writeln("Find the maximum and minimum of the function<p><center><b>f(x) = "+aVar+"x<sup>2</sup> - "+bVar+"x + "+cVar+"</b></center><p> on the closed interval <b>["+dVar+", "+eVar+"].</b><p>")
document.writeln("<hr color='#006600'><font size=+1><b><i>Solution:</i></b></font><br>")
document.writeln("The derivative of <b>f</b> is "+2*aVar+"x - "+bVar+".<p>Setting "+2*aVar+"x - "+bVar+" = 0, we find that the critical point of <b>f</b> is "+bVar+"/"+2*aVar+".<p>")
document.writeln("We form the following table consisting of the endpoints of the interval and the critical point:<p><center><table bgcolor=black><tr><td><table cellpadding=10 width='100%' bgcolor=lightgreen><tr bgcolor=lightpink><th>x</th><th>f(x)</th></tr>")
document.writeln("<tr align=right><td>"+dVar+"</td><td>"+fdVar+"</td></tr>")
document.writeln("<tr align=right><td>"+eVar+"</td><td>"+feVar+"</td></tr>")
document.writeln("<tr align=right><td>"+bVar+"/"+2*aVar+"</td><td>"+fsVar+"</td></tr>")
document.writeln("</table></td></tr></table><p></center>")
document.writeln("Hence,<ul><li>the maximum of <b>f</b> is at <b>x</b> = ")
if (fdVar < feVar){
  document.write(eVar)
} else {
  document.write(dVar)
}
document.writeln("<li>the minimum of <b>f</b> is at <b>x</b> = "+bVar+"/"+2*aVar+".</ul>")
