Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program test
- implicit none
- real :: angle, ret
- PRINT *, 'Enter an angle (in radian)'
- read *, angle
- print *,'real_cos(', angle, ') =', cos(angle) ! real cosinus
- call cos2(angle, 12, ret)
- print *,'cos(', angle, ') = ', ret ! cosinus calculate
- end program test
- subroutine cos2(angle, n, ret)
- implicit none
- integer :: i, n, a, b
- real :: angle, ret
- a = 8*n - 6
- b = 2*n * (2*n - 1)
- ret = 1.000000
- do i = 1, n
- ret = 1 - (angle * angle * ret) / b
- b = b - a
- a = a - 8
- end do
- !return ret
- end subroutine cos2
Advertisement
Add Comment
Please, Sign In to add comment