Arithmetic in Fortran: Higher operators

You may be aware that "Fortran" is a contraction of "formula translator." It should then come as no surprise that the Fortran language includes a full complement of mathematical operations in addition to the basic arithmetic operations of addition, subtraction, multiplication and division.

One such operation is exponentiation, which is indicated by the double asterisk ** as in the following example:

      A = B ** 3

Here the variable A is being assigned a value that is equal to the cube of another variable, B.

Fractional powers may be used: for example, if we want to take the fourth root of some variable C, we could write this as:

      D = C ** 0.25

The following operators take the form of functions. A function operates on one or more inputs, called arguments, that are placed in parentheses after the function. Some of the most commonly used mathematical functions are as follows:

Function Meaning
Y = EXP (X)
Exponential of the argument X; that is, the variable e to the power X.
Y = ALOG (X)
Natural logarithm of the argument X. Attempting to take the logarithm of a negative number will cause the system to report an error.
Y = SIN (X)
Sine of the argument X. Important: X is expressed in radians.
Y = COS (X)
Cosine of the argument X. Important: X is expressed in radians.
Y = TAN (X)
Tangent of the argument X. Important: X is expressed in radians.
Y = ASIN (X)
Arcsine of the argument X. The result will be in radians, with a value between -pi and +pi.
Y = ACOS (X)
Arccosine of the argument X. The result will be in radians, with a value between -pi and +pi.
Y = ATAN (X)
Single-argument arctangent. Here Y is the arctangent of the argument X. The result will be in radians, with a value between -pi/2 and +pi/2.
Y = ATAN2 (X, Z)
Two-argument arctangent; the result is the arctangent of X/Z, in radians. The use of two arguments allows the determination of the quadrant of the angle, so that the result is between -pi and +pi rather than -pi/2 and +pi/2.

Assignment: Write a brief program to compute the solar elevation angle following the instructions for Homework 3. Write the program so that the answer is reported in both degrees and radians.