Compute Math Function Using One Input Value (CMF1)

Instruction Syntax

Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand [4-5]
CMF1 100B Receiver Controls Source
CMF1B 1C0B Branch options Receiver Controls Source Branch targets
CMF1I 180B Indicator options Receiver Controls Source Indicator targets
Operand 1: Numeric variable scalar.

Operand 2: Character(2) scalar.

Operand 3: Numeric scalar.

Operand 4-5:

  • Branch Form–Branch point, instruction pointer, relative instruction number, or absolute instruction number.
  • Indicator Form–Numeric variable scalar or character variable scalar.

Description:

The mathematical function, indicated by the controls operand, is performed on the source operand value and the result is placed in the receiver operand.

The calculation is always done in floating-point.

The result of the operation is copied into the receiver operand.

The controls operand must be a character scalar that specifies which mathematical function is to be performed. It must be at least 2 bytes in length and has the following format:

Offset  
Dec Hex Field Name Data Type and Length
0
0
Controls operand
Hex 0001 =
Sine
Hex 0002 =
Arc sine
Hex 0003 =
Cosine
Hex 0004 =
Arc cosine
Hex 0005 =
Tangent
Hex 0006 =
Arc tangent
Hex 0007 =
Cotangent
Hex 0010 =
Exponential function
Hex 0011 =
Logarithm based e (natural logarithm)
Hex 0012 =
Sine hyperbolic
Hex 0013 =
Cosine hyperbolic
Hex 0014 =
Tangent hyperbolic
Hex 0015 =
Arc tangent hyperbolic
Hex 0020 =
Square root
All other values are reserved

Char(2)
2
2
--- End ---
 

The controls operand mathematical functions are as follows:

  • Hex 0001–Sine

    The sine of the numeric value of the source operand, whose value is considered to be in radians, is computed and placed in the receiver operand.

    The result is in the range:

     -1 <= SIN(x) <= 1
    
  • Hex 0002–Arc sine

    The arc sine of the numeric value of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     -pi/2 <= ASIN(x) <= +pi/2
    
  • Hex 0003–Cosine

    The cosine of the numeric value of the source operand, whose value is considered to be in radians, is computed and placed in the receiver operand.

    The result is in the range:

     -1 <= COS(x) <= 1
    
  • Hex 0004–Arc cosine

    The arc cosine of the numeric value of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     0 <= ACOS(x) <= pi
    
  • Hex 0005–Tangent

    The tangent of the source operand, whose value is considered to be in radians, is computed and the result is placed in the receiver operand.

    The result is in the range:

     -infinity <= TAN(x) <= +infinity
    
  • Hex 0006–Arc tangent

    The arc tangent of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     -pi/2 <= ATAN(x) <= pi/2
    
  • Hex 0007–Cotangent

    The cotangent of the source operand, whose value is considered to be in radians, is computed and the result is placed in the receiver operand.

    The result is in the range:

     -infinity <= COT(x) <= +infinity
    
  • Hex 0010–Exponential function

    The computation e power (source operand) is performed and the result is placed in the receiver operand.

    The result is in the range:

     0 <= EXP(x) <= +infinity
    
  • Hex 0011–Logarithm based e (natural logarithm)

    The natural logarithm of the source operand is computed and the result is placed in the receiver operand.

    The result is in the range:

     -infinity <= LN(x) <= +infinity
    
  • Hex 0012–Sine hyperbolic

    The sine hyperbolic of the numeric value of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     -infinity <= SINH(x) <= +infinity
    
  • Hex 0013–Cosine hyperbolic

    The cosine hyperbolic of the numeric value of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     +1 <= COSH(x) <= +infinity
    
  • Hex 0014–Tangent hyperbolic

    The tangent hyperbolic of the numeric value of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     -1 <= TANH(x) <= +1
    
  • Hex 0015–Arc tangent hyperbolic

    The inverse of the tangent hyperbolic of the numeric value of the source operand is computed and the result (in radians) is placed in the receiver operand.

    The result is in the range:

     -infinity <= ATANH(x) <= +infinity
    
  • Hex 0020–Square root

    The square root of the numeric value of the source operand is computed and placed in the receiver operand.

    The result is in the range:

     0 <= SQRT(x) <= +infinity
    

The following chart shows some special cases for certain arguments (X) of the different mathematical functions which take one argument value.

Function x= Masked NaN x= UnMasked NaN x= +Infinity x= -Infinity x= +0 x= -0
Sine
  • XX if pi*2^26 < |x| < pi*2^50
  • VX(NaN) if |x| >= pi*2^50
x VX(x) VX(NaN) VX(NaN) +0 -0
Arc sine
  • VX(NaN) if |x| > 1
x VX(x) VX(NaN) VX(NaN) +0 -0
Cosine
  • XX if pi*2^26 < |x| < pi*2^50
  • VX(NaN) if |x| >= pi*2^50
x VX(x) VX(NaN) VX(NaN) +1 +1
Arc cosine
  • VX(NaN) if |x| > 1
x VX(x) VX(NaN) VX(NaN) +pi/2 +pi/2
Tangent
  • XX if pi*2^26 < |x| < pi*2^50
  • VX(NaN) if |x| >= pi*2^50
x VX(x) VX(NaN) VX(NaN) +0 -0
Arc Tangent x VX(x) +pi/2 -pi/2 +0 -0
Cotangent
  • XX if pi*2^26 < |x| < pi*2^50
  • VX(NaN) if |x| >= pi*2^50
x VX(x) VX(NaN) VX(NaN) +inf -inf
Natural log base (e) Exponent
  • OF if |x| > ln(2^1023)
  • UF if |x| < ln(2^-1021.455)
x VX(x) +inf +0 +1 +1
Natural (base e) Logarithm
  • VX(NaN) if x < 0
x VX(x) +inf VX(NaN) -inf -inf
Sine hyperbolic x VX(x) +inf -inf +0 -0
Cosine hyperbolic x VX(x) +inf +inf +1 +1
Tangent hyperbolic x VX(x) +1 -1 +0 -0
Arc tangent hyperbolic
  • VX(NaN) if |x| > 1
x VX(x) VX(NaN) VX(NaN) +0 -0
Square root
  • VX(NaN) if x < 0
x VX(x) +inf VX(NaN) +0 -0
Special cases for single argument math functions

These special functions denote floating point exceptions:

VX(value)
Floating-point invalid operand (hex 0C09) exception. The function result for VX(NaN) is the system default masked NaN. The function result for any other value is the masked equivalent of the specified (NaN) value.
XX =
Floating-point inexact result (hex 0C0D) exception
OF =
Floating-point overflow (hex 0C06) exception
UF =
Floating-point underflow (hex 0C07) exception

The following chart provides accuracy data for the mathematical functions that can be invoked by this instruction.

Function Name Sample Selection Accuracy data
Relative Error(e) Absolute Error(E)
A Range of x D MAX(e) SD(e) MAX(E) SD(E)
Arc cosine 9 0<=x<=3.14 U 8.26* 10**-14 2.11*10**-15
Arc sine 10 -1.57<=x<=1.57 U 1.02*10**-13 2.66*10**-15
Arc tangent 1 -pi/2<x<pi/2 1 3.33*10**-16 9.57*10**-17
Arc tangent hyperbolic 14 -3<=x<=3 U 1.06*10**-14 1.79*10**-15
Cosine (See Sine below)
Cosine hyperbolic (See Sine Hyperbolic below)
Cotangent 11 -10<=x<=100

.000001<=x<=.001

4000<=x<=4000000

U

U

U

4.83*10**-16

4.36*10**-16

5.72*10**-16

1.48*10**-16

1.49*10**-16

1.46*10**-16

Exponential 2 -100<=x<=300 U 5.70*10**-14 1.13*10**-14
Natural Logarithm 3 0.5<=x<=1.5 U 2.77*10**-16 8.01*10**-17
Natural Logarithm 4 -100<=x<=700 E 2.17*10**-16 7.37*10**-17
Sine cosine 5 -10<=x<=100

.000001<=x<=.001

4000<=x<=4000000

U

U

U

2.22*10**-16

2.22*10**-16

2.22*10**-16

1.31*10**-16

1.56*10**-16

1.28*10**-16

Sine cosine 6 -10<=x<=100

.000001<=x<=.001

4000<=x<=4000000

U

U

U

3.33*10**-16

4.33*10**-19

3.33*10**-16

8.39*10**-17

1.28*10**-19

8.17*10**-17

Sine/cosine hyperbolic 12 -100<=x<=300 U 6.31*10**-16 1.97*10**-16
Square root 7 -100<=x<=700 E 4.13*10**-16 1.27*10**-16
Tangent 8 -10<=x<=100

.000001<=x<=.001

4000<=x<=4000000

U

U

U

4.59*10**-16

4.42*10**-16

4.77*10**-16

1.54*10**-16

1.44*10**-16

1.43*10**-16

 

3.25*10**-19

 

8.06*10**-20

Tangent hyperbolic 13 -100<=x<=300 U 8.35*10**-16 3.87*10**-17 2.22*10**-16 3.17*10**-17
Note:

Algorithm Notes:

  1. f(x) = x, and g(x) = ATAN(TAN(x)).
  2. f(x) = e**x, and g(x) = e**(1n(e**x)).
  3. f(x) = 1n(x), and g(x) = 1n(e**(1n(x))).
  4. f(x) = x, and g(x) = 1n(e**x).
  5. Sum of squares algorithm. f(x) = 1, and g(x) = SIN(x))**2 + (COS(x))**2.
  6. Double angle algorithm. f(x) - SIN(2x), and g(x) = 2*(SIN(x)*COS(x)).
  7. f(x) = e(**x, and g(x) = (SQR(e**x))**2.
  8. f(x) = TAN(x), and g(x) = SIN(x) / COS(x).
  9. f(x) = x, and g(x) = ACOS(COS(x)).
  10. f(x) = x, and g(x) = ASIN(SIN(x)).
  11. f(x) = COT(x), and g(x) = COS(x) / SIN(x).
  12. f(x) = SINH(2x), and g(x) = 2*(SINH(x)*COSH(x)).
  13. f(x) = TANH(x), and g(x) = SINH(x) / COSH(x).
  14. f(x) = x, and g(x) = ATANH(TANH(x)).

Distribution Note:

  1. The sample input arguments were tangents of numbers, x, uniformly distributed between -pi/2 and +pi/2.
Accuracy data for CMF1 mathematical functions

The vertical columns in the accuracy data chart have the following meanings:

  • Function Name: This column identifies the principal mathematical functions evaluated with entries arranged in alphabetical order by function name.
  • Sample Selection: This column identifies the selection of samples taken for a particular math function through the following subcolumns:
    • A: identifies the algorithm used against the argument, x, to gather the accuracy samples. The numbers in this column refer to notes describing the functions, f(x) and g(x), which were calculated to test for the anticipated relation where f(x) should equal g(x). An accuracy sample then, is an evaluation of the degree to which this relation held true. The algorithm used to sample the arctangent function, for example, defines g(x) to first calculate the tangent of x to provide an appropriate distribution of input arguments for the arctangent function. Since f(x) is defined simply as the value of x, the relation to be evaluated is then x=ARCTAN(TAN(x)). This type of algorithm, where a function and its inverse are used in tandem, is the usual type employed to provide the appropriate comparison values for the evaluation.
    • Range of x: gives the range of x used to obtain the accuracy samples. The test values for x are uniformly distributed over this range. It should be noted that x is not always the direct input argument to the function being tested; it is sometimes desirable to distribute the input arguments in a nonuniform fashion to provide a more complete test of the function (see column D below). For each function, accuracy data is given for one or more segments within the valid range of x. In each case, the numbers given are the most meaningful to the function and range under consideration.
    • D: identifies the distribution of arguments input to the particular function being sampled. The letter E indicates an exponential distribution. The letter U indicates a uniform distribution. A number refers to a note providing detailed information regarding the distribution.
  • Accuracy Data: The maximum relative error and standard deviation of the relative error are generally useful and revealing statistics; however, they are useless for the range of a function where its value becomes zero. This is because the slightest error in the argument can cause an unpredictable fluctuation in the magnitude of the answer. When a small argument error would have this effect, the maximum absolute error and standard deviation of the absolute error are given for the range.
    • Relative Error (e): The maximum relative error and standard deviation (root mean square) of the relative error are defined:
      MAX(e) =
      MAX( ABS((f(x) - g(x) ) / f(x)))

      where: MAX selects the largest of its arguments and ABS takes the absolute value of its argument.

      SD(e) =
      SQR( (1/N) SUMSQ((f(x) - g(x) ) / f(x)))

      where: SQR takes the square root of its argument and SUMSQ takes the summation of the squares of its arguments over all of the test cases.

    • Absolute Error (E): The maximum absolute error produced during the testing and the standard deviation (root mean square) of the absolute error are:
      MAX(E) =
      MAX( ABS( f(x) - g(x) ) )

      where: the operators are those defined above.

      SD(E) =
      SQR( (1/N) SUMSQ( f(x) - g(x) ) )

      where: the operators are those defined above.

Limitations (Subject to Change)

The following are limits that apply to the functions performed by this instruction.

The source and receiver operands must both be specified as floating-point with the same length (4 bytes for short format or 8 bytes for long format).

Resultant Conditions

  • Positive–The algebraic value of the receiver operand is positive.
  • Negative–The algebraic value of the receiver operand is negative.
  • Zero–The algebraic value of the receiver operand is zero.
  • Unordered–The value assigned to the floating-point result is NaN.

Authorization Required

  • None

Lock Enforcement

  • None

Exceptions

  • 06 Addressing
    • 0601 Space Addressing Violation
    • 0602 Boundary Alignment
    • 0603 Range
  • 08 Argument/Parameter
    • 0801 Parameter Reference Violation
  • 0C Computation
    • 0C06 Floating-Point Overflow
    • 0C07 Floating-Point Underflow
    • 0C09 Floating-Point Invalid Operand
    • 0C0D Floating-Point Inexact Result
  • 10 Damage Encountered
    • 1004 System Object Damage State
    • 1044 Partial System Object Damage
  • 1C Machine-Dependent
    • 1C03 Machine Storage Limit Exceeded
  • 20 Machine Support
    • 2002 Machine Check
    • 2003 Function Check
  • 22 Object Access
    • 2201 Object Not Found
    • 2202 Object Destroyed
    • 2203 Object Suspended
    • 2208 Object Compressed
    • 220B Object Not Available
  • 24 Pointer Specification
    • 2401 Pointer Does Not Exist
    • 2402 Pointer Type Invalid
  • 2C Program Execution
    • 2C04 Branch Target Invalid
  • 2E Resource Control Limit
    • 2E01 User Profile Storage Limit Exceeded
    • 2E02 Security Audit Journal Failure
  • 32 Scalar Specification
    • 3201 Scalar Type Invalid
    • 3203 Scalar Value Invalid
  • 36 Space Management
    • 3601 Space Extension/Truncation
  • 44 Protection Violation
    • 4401 Object Domain or Hardware Storage Protection Violation
    • 4402 Literal Values Cannot Be Changed