!*************************************************** !* Chebyshev Approximation of a user defined real * !* function FUNC(X) in double precision. * !* ----------------------------------------------- * !* SAMPLE RUN: * !* (Approximate sin(x) from x=0 to x=PI). * !* * !* Chebyshev coefficients (N=10): * !* 0.944002431536470 * !* -2.844946500601964E-017 * !* -0.499403258270407 * !* -8.951173136040325E-017 * !* 2.799207961754557E-002 * !* -1.252470349655255E-016 * !* -5.966951958007059E-004 * !* 2.622901895676933E-016 * !* 6.704175523811369E-006 * !* 2.576064361825559E-017 * !* X Chebyshev Eval. SIN(X) * !* -----------------------------------------------* !* 0.00000000E+00 0.46095096E-07 0.00000000E+00 * !* 0.34906585E+00 0.34202018E+00 0.34202014E+00 * !* 0.69813170E+00 0.64278758E+00 0.64278761E+00 * !* 0.10471976E+01 0.86602545E+00 0.86602540E+00 * !* 0.13962634E+01 0.98480773E+00 0.98480775E+00 * !* 0.17453293E+01 0.98480773E+00 0.98480775E+00 * !* 0.20943951E+01 0.86602545E+00 0.86602540E+00 * !* 0.24434610E+01 0.64278758E+00 0.64278761E+00 * !* 0.27925268E+01 0.34202018E+00 0.34202014E+00 * !* 0.31415927E+01 0.46095096E-07 0.12246064E-15 * !* * !* F90 Release By J-P Moreau, Paris. * !* (www.jpmoreau.fr) * !*************************************************** ! To link with Chebyshev.f90. PROGRAM TESTCHEBY parameter(NMAX=50,ZERO=0.d0) real*8 PI,X0,X1, COEFF(NMAX) real*8 DX, X PI=4.d0*datan(1.d0) N=10 X0=ZERO; X1=PI call CHEBFT(X0,X1,COEFF,N) write(*,10) N do I=1, N print *, COEFF(I) end do DX=(X1-X0)/(N-1) X=X0-DX print *,' X Chebyshev Eval. SIN(X) ' print *,' ----------------------------------------------' do I=1, N X=X+DX write(*,20) X, CHEBEV(X0,X1,COEFF,N,X), DSIN(X) end do 10 format(' Chebyshev coefficients (N=',I2,'):') 20 format(3E16.8) END !user defined function real*8 function FUNC(x) real*8 x FUNC=DSIN(x) return end !end of file Tchebysh.f90