Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Program_External_Function

program external_function
  implicit none
  double precision :: x,myexp
  read(*,*) x
  10 format(a,1x,f6.2,a,1x,f20.10)
  20 format(a,1x,f20.10)
  write(*,10) '       exp(',x,') =',exp(x)
  write(*,10) '  myexpval(',x,') =',myexp(x)
  write(*,20) '         difference =',exp(x)  - myexp(x)
end program external_function

function myexp(x)
  double precision,intent(in) :: x
  double precision :: myexp,e,nfact
  integer :: i,n
  n = 12
  e = 0
  nfact = 1
  do i = 0,n
    if (i > 1) nfact = nfact * i
    e = e + ((x ** i) / nfact)
  end do
  myexp = e
end function myexp

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.