!*************************************************** !* Chebyshev Approximation of a user defined real * !* function FUNC(X) in double precision. * !* ----------------------------------------------- * !* SAMPLE RUN: * !* (Approximate derivative of sin(x) from x=0 to * !* x=PI). * !* * !* X Chebyshev Eval. COS(X) * !* of derivative * !* ---------------------------------------------- * !* 0.00000000E+00 0.99999708E+00 0.10000000E+01 * !* 0.15707963E+00 0.98768902E+00 0.98768834E+00 * !* 0.31415927E+00 0.95105642E+00 0.95105652E+00 * !* 0.47123890E+00 0.89100611E+00 0.89100652E+00 * !* 0.62831853E+00 0.80901694E+00 0.80901699E+00 * !* 0.78539816E+00 0.70710707E+00 0.70710678E+00 * !* 0.94247780E+00 0.58778554E+00 0.58778525E+00 * !* 0.10995574E+01 0.45399046E+00 0.45399050E+00 * !* 0.12566371E+01 0.30901670E+00 0.30901699E+00 * !* 0.14137167E+01 0.15643421E+00 0.15643447E+00 * !* 0.15707963E+01 -0.13801730E-14 0.61230318E-16 * !* 0.17278760E+01 -0.15643421E+00 -0.15643447E+00 * !* 0.18849556E+01 -0.30901670E+00 -0.30901699E+00 * !* 0.20420352E+01 -0.45399046E+00 -0.45399050E+00 * !* 0.21991149E+01 -0.58778554E+00 -0.58778525E+00 * !* 0.23561945E+01 -0.70710707E+00 -0.70710678E+00 * !* 0.25132741E+01 -0.80901694E+00 -0.80901699E+00 * !* 0.26703538E+01 -0.89100611E+00 -0.89100652E+00 * !* 0.28274334E+01 -0.95105642E+00 -0.95105652E+00 * !* 0.29845130E+01 -0.98768902E+00 -0.98768834E+00 * !* 0.31415927E+01 -0.99999708E+00 -0.10000000E+01 * !* * !* F90 Release By J-P Moreau, Paris. * !* (www.jpmoreau.fr) * !*************************************************** ! To link with Chebyshev.f90. PROGRAM TESTCHDER parameter(NMAX=50,ZERO=0.d0) real*8 PI,X0,X1, COEFF(NMAX), CDER(NMAX) real*8 DX, X PI=4.d0*datan(1.d0) N=10 X0=ZERO; X1=PI !calculate Chebyshev coefficients of FUNC(X) call CHEBFT(X0,X1,COEFF,N) NPTS=21 DX=(X1-X0)/(NPTS-1) X=X0-DX !calculate Chebyshev coefficients of derivative of FUNC(X) call CHDER(X0,X1,COEFF,CDER,N) !compare Chebyshev evaluation of integral with exact value !(the constant of integration is set such as initial value !of integral is zero). print *,' X Chebyshev Eval. COS(X) ' print *,' of derivative ' print *,' ----------------------------------------------' do I=1, NPTS X=X+DX write(*,20) X, CHEBEV(X0,X1,CDER,N,X), DCOS(X) end do 20 format(3E16.8) END !user defined function real*8 function FUNC(x) real*8 x FUNC=DSIN(x) return end !end of file Tchebder.f90