class Samp10
{   

     double f(double x)
     {   double pi, fx;
         pi=Math.atan(1.0)*4.0;
         fx=Math.exp(-x)*Math.sin(4.0*pi*x);
         return(fx);
      }

     void plotd()
     {    
      double [] new x1[21],y1[21];int n,i;
      n=20;
      for(i=0;i<=n;i++){ 
        x1[i]=double(i)/double(n);y1[i]=f(x1[i]); }
      linewidth(1.5);linety(1);
      setgray(0.0);
      plot(x1[0],y1[0],3);
      for (i=1;i<=n-2;i++){
      spline1(x1[i-1],y1[i-1],x1[i],y1[i],x1[i+1],y1[i+1],x1[i+2],y1[i+2],-1); }
      spline1(x1[n-3],y1[n-3],x1[n-2],y1[n-2],x1[n-1],y1[n-1],x1[n],y1[n],0);
      spline1(x1[n-3],y1[n-3],x1[n-2],y1[n-2],x1[n-1],y1[n-1],x1[n],y1[n],1);
      stroke();
      }

      void frame()
      {
      int ix,nx,iy,ny; double x,dx,y,dy;
      linewidth(1.0);
      rect(0.0,-1.0,1.0,1.0,0.0,1.0,1);
      nx=2; 
      for(ix=1;ix<=nx*10-1;ix++){
       x=double(ix)/double(nx*10);dy=1.0;
       if(ix/10*10==ix) setgray(0.5); else setgray(0.8); 
       plot(x,-dy,3);plot(x,dy,2);stroke(); }
      ny=2;
      for(iy=1;iy<=ny*10-1;iy++){
       y=double(iy)/double(ny*10)*2.0-1.0;dx=1.0;
       if(iy/10*10==iy) setgray(0.5); else setgray(0.8);
       plot(0.0,y,3);plot(dx,y,2);stroke(); }
      setgray(0.0);
      textx(0.75,0.0,1,"x");
         textx(0.05,0.02,1,"0");textx(0.55,0.02,3,"0.5");textx(0.95,0.02,1,"1");
      texty(0.0,0.5,1,"y");
         texty(0.0,-1.0,2,"-1");texty(0.0,0.0,1,"0");texty(0.0,1.0,1,"1");
      }
     public static void main(String args[])
     {  

       PS ps1= new PS();
       ps1.init();
       ps1.viewport(0.2, 0.2, 0.8, 0.8);
       ps1.xyworld(0.0, -1.0, 1.0, 1.0);
       ps1.setchar(1, 10);
       frame(); 
       plotd();
       ps1.fin(); 
     }
}
