Skip to main content
Engineering LibreTexts

5.4: Intrinsic Functions

  • Page ID
    54258
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Intrinsic functions are standard built-in functions that are provided by Fortran. These include a rich set of standard functions, including the typical mathematical standard functions. Intrinsic functions can be used in expressions as needed. Most intrinsic functions accept one or more arguments as input and return a single value.

    Mathematical Intrinsic Functions

    The intrinsic or built-in functions include the standard mathematical functions such as sine, cosine, tangent, and square root.

    For example, the cosine of \(\pi\) is -1.0. Declaring and initializing the variables z and pi as follows,

    real :: z
    real, parameter :: pi = 3.14159
    

    and then performing the calculation of the cosine the variable pi as follows,

    z = cos(pi)
    

    which will set z to -1.0. The variable pi is the input argument.

    Conversion Functions

    Other intrinsic functions include functions to change the type of variables or values. The basic conversion functions are as follows:

    Function Explanation
    real(<integer argument>) Convert the <integer argument> to a real value
    int(<real argument>) Convert the <real argument> to an integer, truncates the fractional portion
    nint(<real argument>) Convert the <real argument> to an integer, rounds the fractional portion

    For example, given the following variable declarations,

    integer :: inum1=10, inum2, inum3
    real :: rnum1, rnum2 = 4.8, rnum3 = 5.8
    

    and calculate the rnum1, inum2, and inum3,

    rnum1 = real(inum1)
    inum2 = int(rnum2)
    inum3 = nint(rnum3)
    

    which will set to rnum1 to 10.0, inum2 to 4, and inum3 to 6.

    Summary

    A summary of some of the more common intrinsic functions include:

    Function Description
    COS(W) Returns real cosine of real argument W in radians.
    INT(A) Converts real argument A to integer, truncating (real part) towards zero.
    MOD(R1,R2) Returns remainder after division of R1 on division by R2. Result, R1 and R2 should be all integer or all real types.
    NINT(X) Returns the nearest integer to real value X (thus rounding up or down as appropriate).
    REAL(A) Converts integer argument A to real.
    SIN(W) Returns real sine of real argument W in radians.
    SQRT(W) Returns the real square root of real argument W; W must be positive.
    TAN(X) Returns the real tangent of real argument X in radians.

    A more complete list of intrinsic functions in located in Appendix D.


    This page titled 5.4: Intrinsic Functions is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Ed Jorgensen via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?