! ! ****** function T_sine ***************************************** ! function T_sine(x,n) implicit none integer:: k, n real(8):: pi real(8):: x, xp, fact_k, ak, fk real(8):: T_sine_k real(8):: T_sine real(8),parameter:: eps = 1.0d-10 pi = 4.0d0 * atan(1.0d0) ! ! initalize: f(x=0) = sin(0), 0! = 1, x**0 = 1.0 ! T_sine_k = 0.0d0 fact_k = 1.0d0 xp = 1.0d0 ! ! take summation sigma_( a(i)*x**i ) for i = 1 to n ! do k = 1,n fact_k = fact_k * dfloat(k) ! calculate factorial real(k!) ak = (-mod(k,2))**(k/2) / fact_k ! coefficient xp = xp * x ! calculate xp = x**k fk = ak * xp ! k-th order term T_sine_k = T_sine_k + fk ! calculate summation end do T_sine = T_sine_k return end function T_sine