EXP(3) - [MATHEMATICS] Base-e exponential function
result = exp(x)
elemental TYPE(kind=KIND) function exp(x)TYPE(kind=KIND),intent(in) :: x
o X may be real or complex of any kind. o The return value has the same type and kind as X.
EXP(3) returns the value of e (the base of natural logarithms) raised to the power of X.
"e" is also known as Eulers constant.
So for either a real or complex scalar X, it returns e**X , where e is the base of the natural logarithm (approximately 2.718281828459045).
For real inputs, EXP returns a real result.
If X is of type complex, its imaginary part is regarded as a value in radians such that (see Eulers formula):
exp((re,im)) = exp(re) * cmplx(cos(im),sin(im),kind=kind(cx))Since EXP(3) is the inverse function of LOG(3) the maximum valid magnitude of the real component of X is LOG(HUGE(X)).
EXP being elemental, when X is an array (real or complex), the function is applied element-wise, returning an array of the same shape.
Numerical ConsiderationsFor very large real X, the result may overflow to infinity in finite-precision arithmetic. For very small (negative) real X , the result approaches zero. Complex inputs with large imaginary parts may produce results with significant numerical errors due to the trigonometric functions involved.
o X : The type shall be real or complex.
The value of the result is E**X where E is Eulers constant.
If X is of type complex, its imaginary part is regarded as a value in radians.
Sample program:
program demo_exp implicit none integer,parameter :: dp=kind(0.0d0) real :: x, re, im complex :: cx real :: r_array(3), r_array_result(3) complex :: c_array(2), c_array_result(2) integer :: iResults:x = 1.0 write(*,*)"Eulers constant is approximately",exp(x)
!! complex values ! given re=3.0 im=4.0 cx=cmplx(re,im)
! complex results from complex arguments are Related to Eulers formula write(*,*)given the complex value ,cx write(*,*)exp(x) is,exp(cx) write(*,*)is the same as,exp(re)*cmplx(cos(im),sin(im),kind=kind(cx))
! exp(3) is the inverse function of log(3) so ! the real component of the input must be less than or equal to write(*,*)maximum real component,log(huge(0.0)) ! or for double precision write(*,*)maximum doubleprecision component,log(huge(0.0d0))
! but since the imaginary component is passed to the cos(3) and sin(3) ! functions the imaginary component can be any real value
! Real array example r_array = [0.0, 1.0, -1.0] r_array_result = exp(r_array) do i = 1, size(r_array) write(*, (A, I0, A, F15.10)) "exp(r_array(", i, ")) = ", r_array_result(i) enddo
! Complex array example c_array = [cmplx(0.0, 0.0, kind=dp), cmplx(1.0, 1.0, kind=dp)] c_array_result = exp(c_array) do i = 1, size(c_array) write(*, (A, I0, A, F15.10, A, F15.10, A)) "exp(c_array(", i, ")) = (", & real(c_array_result(i)), ", ", aimag(c_array_result(i)), ")" enddo end program demo_exp
> Eulers constant is approximately 2.71828175 > given the complex value (3.00000000,4.00000000) > exp(x) is (-13.1287832,-15.2007847) > is the same as (-13.1287832,-15.2007847) > maximum real component 88.7228394 > maximum doubleprecision component 709.78271289338397 > exp(r_array(1)) = 1.0000000000 > exp(r_array(2)) = 2.7182817459 > exp(r_array(3)) = 0.3678794503 > exp(c_array(1)) = ( 1.0000000000, 0.0000000000) > exp(c_array(2)) = ( 1.4686938524, 2.2873551846)
FORTRAN 77
o LOG(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
o Wikipedia:Exponential function o Wikipedia:Eulers formula
