#include #include #include #include #include "ps.h" double f(double); void plotd(void); void frame(void); int main(void) { init(); viewport(0.2, 0.2, 0.8, 0.8); xyworld(0.0, 0.0, 4.0, 4.0); frame(); plotd(); fin(); return 0; } double f(double x) { double fx; fx=x*x*x/(5.0+x*x)+10.0; return (fx); } void plotd() { double x1[21],y1[21];int n,i; n=20; for (i=0;i<=n; i++) { x1[i]=1.0*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]); } 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,ixx,iyy; double x,y,dx,dy; linewidth(1.0); rect(0.0, 0.0, 4.0, 4.0, 0.0, 1.0, 1); nx=4; for(ix=0;ix<=nx-1;ix++) { setgray(0.3); x = (double)ix; dy=4.0; if(ix!=0) {plot(x,0.0,3);plot(x,dy,2);stroke(); } for(ixx=2;ixx<=9;ixx++) { setgray(0.8);x = (double) ix+log10((double) ixx); plot(x,0.0,3);plot(x,dy,2);stroke(); } } ny=4; for(iy=0;iy<=ny-1;iy++) { setgray(0.5); y = (double)iy; dx=4.0; if(iy!=0) {plot(0.0,y,3);plot(dx,y,2);stroke(); } for(iyy=2;iyy<=9;iyy++) { setgray(0.8);y = (double) iy+log10((double) iyy); plot(0.0,y,3);plot(dx,y,2);stroke(); } } setgray(0.0); textx(3.5, 0.0, 1, "x"); textx(0.0, 0.02, 1, "1"); textx(1.0, 0.02, 2, "10"); textx(2.0, 0.02, 3, "100"); textx(3.0, 0.02, 4, "1000"); textx(4.0, 0.02, 5, "10000"); texty(0.0, 3.5, 1, "y"); texty(0.0, 0.0, 1, "1"); texty(0.0, 1.0, 2, "10"); texty(0.0, 2.0, 3, "100");texty(0.0, 3.0, 4, "1000"); texty(0.0, 4.0, 5, "10000"); return; }