import java.awt.*;
import javax.swing.*;
public class Radice extends JApplet {

 Display disegno;
 int x[]; int y[];
 double xmin,xmax;
 double ymin,ymax;
 double xf[],yf[];
 int larghezza,lunghezza;
 public void init(){
  disegno = new Display();  
  setContentPane(disegno);
  x = new int[300]; y = new int[300];
  xf = new double[300];
  yf = new double[300];
 
  
  xmin = -7.; xmax=3;
  ymax = -1.e-10; ymin = 1.e10;
  for(int i=0; i < x.length;i++){
    xf[i] = xmin +i * (xmax-xmin)/x.length;
    yf[i] = f( xf[i]);
    if(yf[i]>ymax) ymax = yf[i];
    if(yf[i]<ymin) ymin = yf[i];

  }
  System.out.println(ymax + "  " + ymin);
 }
 double f( double x){
  return( x*x-5);
  }
class Display extends JPanel {
 public void paintComponent(Graphics g){
   super.paintComponent(g);
   lunghezza = getSize().width;
   larghezza = getSize().height;
   for(int i=0; i < x.length;i++){
      x[i]=(int) ((xf[i]-xmin)/(xmax-xmin)*lunghezza); 
      y[i]= (int) ((ymax-yf[i])/(ymax-ymin)*larghezza);  
     
    } 
    g.setColor(Color.magenta);
    g.drawPolyline(x,y,x.length);
     }
 }
 }

