      program deriv3
c derivovanie pomocou chebyshev aproximacie
      dimension xray(101),yray(101),yray1(101),yray2(101)
      dimension c(40),cder(40)
      external funct
      x=-5.0
      a=-5.0
      b=5.0
      n=20
      call chebft(a,b,c,n,funct)
      call chder(a,b,c,cder,n)
      do i=1,101
         xray(i)=x
         yray(i)=funct(x)
         yray1(i)=chebev(a,b,c,n,x)
         yray2(i)=chebev(a,b,cder,n,x)
         x=x+0.1
      end do
c
      call metafl('cons')
      CALL SETPAG('DA4L')
      CALL DISINI
      CALL TITLIN(CTIT,1)
      CALL AXSLEN(2500,700)
      CALL AXSPOS(200,800)
      CALL GRAF(-5.,5.,-5.,2.,-1.2,1.2,-1.2,4.e-1)
           NX=NXPOSN(-3.)
           NY=NYPOSN(1.4)
      CALL MESSAG('Funkcia a aproximacia',NX,NY)
      CALL COLOR('red')
      CALL curve(xray,yray,101)
      CALL COLOR('yellow')
      CALL curve(xray,yray1,101)
      CALL COLOR('white')
      CALL ENDGRF
      CALL AXSLEN(2500,700)
      CALL AXSPOS(200,1800)
      CALL GRAF(-5.,5.,-5.,2.,-3.,3.,-3.,1.0)
           NX=NXPOSN(-3.)
           NY=NYPOSN(3.5)
      CALL MESSAG('Numericka derivacia',NX,NY)
      CALL COLOR('red')
      CALL curve(xray,yray2,101) 
      CALL DISFIN
      END 
c
      function funct(x)
        a=0.1*(2.*rand()+1.)
        funct=0.5*sin(3.*x)+a
c        funct=0.01*x*x*x+a
      return
      end 
         
      