class Samp9 { static double f(double x) { double fx; fx=x*x*x/(5.0+x*x)+10.0; return(fx); } static double log10(double x) { double fx; fx=Math.log(x)/Math.log(10.0); return(fx); } static void frame(PS ps1) { int ix,nx,iy,ny,ixx,iyy;double x,y,dx,dy; ps1.linewidth(1.0); ps1.rect(0.0,0.0,4.0,4.0,0.0,1.0,1); nx=4; for (ix=0;ix<=nx-1;ix++){ ps1.setgray(0.3); x=(double)ix;dy=4.0; if(ix!=0) {ps1.plot(x,0.0,3);ps1.plot(x,dy,2);ps1.stroke();} for (ixx=2;ixx<=9;ixx++) { ps1.setgray(0.8);x=(double)ix+log10((double)ixx); ps1.plot(x,0.0,3);ps1.plot(x,dy,2);ps1.stroke();} } ny=4; for (iy=0;iy<=ny-1;iy++){ ps1.setgray(0.3); y=(double)iy;dx=4.0; if(iy!=0) {ps1.plot(0.0,y,3);ps1.plot(dx,y,2);ps1.stroke();} for (iyy=2;iyy<=9;iyy++) { ps1.setgray(0.8);y=(double)iy+log10((double)iyy); ps1.plot(0.0,y,3);ps1.plot(dx,y,2);ps1.stroke();} } ps1.setgray(0.0); ps1.textx(3.5,0.0,1,"x");ps1.textx(0.0,0.02,1,"1");ps1.textx(1.0,0.02,2,"1O"); ps1.textx(2.0,0.02,3,"100");ps1.textx(3.0,0.02,4,"1000");ps1.textx(4.0,0.02,5,"10000"); ps1.texty(0.0,3.5,1,"y");ps1.texty(0.0,0.0,1,"1");ps1.texty(0.0,1.0,2,"10"); ps1.texty(0.0,2.0,3,"100");ps1.texty(0.0,3.0,4,"1000");ps1.texty(0.0,4.0,5,"10000"); } static void plotd(PS ps1) { double [] x1=new double[21]; double [] y1=new double[21];int n,i; n=20; for (i=0;i<=n;i++){ x1[i]=1.0*Math.pow(10.0,(double)i/(double)n*4.0); y1[i] = f(x1[i]);} for (i=0;i<=n;i++){ x1[i]=log10(x1[i]); y1[i] = log10(y1[i]);} ps1.linewidth(1.5);ps1.linety(1); ps1.setgray(0.0); ps1.plot(x1[0],y1[0],3); for (i=1;i<=n-2;i++){ ps1.spline1(x1[i-1],y1[i-1],x1[i],y1[i],x1[i+1],y1[i+1],x1[i+2],y1[i+2],-1);} ps1.spline1(x1[n-3],y1[n-3],x1[n-2],y1[n-2],x1[n-1],y1[n-1],x1[n],y1[n],0); ps1.spline1(x1[n-3],y1[n-3],x1[n-2],y1[n-2],x1[n-1],y1[n-1],x1[n],y1[n],1); ps1.stroke(); } 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, 0.0, 4.0, 4.0); frame(ps1); plotd(ps1); ps1.fin(); } }