G.2.6 Accuracy Requirements for Complex Arithmetic
1
In the strict mode, the performance of Numerics.Generic_Complex_Types
and Numerics.Generic_Complex_Elementary_Functions shall be as specified
here.
Implementation Requirements
2
When an exception is not raised, the result of evaluating
a real function of an instance
CT of Numerics.Generic_Complex_Types
(i.e., a function that yields a value of subtype
CT.Real'Base
or
CT.Imaginary) belongs to a result interval defined as for a
real elementary function (see
G.2.4).
3
{result interval
(for a component of the result of evaluating a complex function)}
When an exception is not raised, each component of
the result of evaluating a complex function of such an instance, or of
an instance of Numerics.Generic_Complex_Elementary_Functions obtained
by instantiating the latter with
CT (i.e., a function that yields
a value of subtype
CT.Complex), also belongs to a
result interval.
The result intervals for the components of the result are either defined
by a
maximum relative error bound or by a
maximum box error
bound.
{maximum relative error (for a
component of the result of evaluating a complex function)}
When the result interval for the real (resp., imaginary)
component is defined by maximum relative error, it is defined as for
that of a real function, relative to the exact value of the real (resp.,
imaginary) part of the result of the corresponding mathematical function.
{maximum box error (for a component of
the result of evaluating a complex function)} When
defined by maximum box error, the result interval for a component of
the result is the smallest model interval of
CT.Real that contains
all the values of the corresponding part of
f
· (1.0 +
d), where
f
is the exact complex value of the corresponding mathematical function
at the given parameter values,
d is
complex, and 
d is less than or equal
to the given maximum box error.
{Overflow_Check
[partial]} {check,
languagedefined (Overflow_Check)} The
function delivers a value that belongs to the result interval (or a value
both of whose components belong to their respective result intervals)
when both bounds of the result interval(s) belong to the safe range of
CT.Real; otherwise,
3.a
Discussion: The maximum relative error
could be specified separately for each component, but we do not take
advantage of that freedom here.
3.b
Discussion: Note that f
· (1.0 + d) defines a small
circular region of the complex plane centered at f,
and the result intervals for the real and imaginary components of the
result define a small rectangular box containing that circle.
3.c
Reason: Box error is used when the computation
of the result risks loss of significance in a component due to cancellation.
3.d
Ramification: The components of a complex
function that exhibits bounded relative error in each component have
to have the correct sign. In contrast, one of the components of a complex
function that exhibits bounded box error may have the wrong sign, since
the dimensions of the box containing the result are proportional to the
modulus of the mathematical result and not to either component of the
mathematical result individually. Thus, for example, the box containing
the computed result of a complex function whose mathematical result has
a large modulus but lies very close to the imaginary axis might well
straddle that axis, allowing the real component of the computed result
to have the wrong sign. In this case, the distance between the computed
result and the mathematical result is, nevertheless, a small fraction
of the modulus of the mathematical result.
4
 {Constraint_Error
(raised by failure of runtime check)} if
CT.Real'Machine_Overflows is True, the function either delivers
a value that belongs to the result interval (or a value both of whose
components belong to their respective result intervals) or raises Constraint_Error,
signaling overflow;
5
 if CT.Real'Machine_Overflows
is False, the result is implementation defined.
5.a
Implementation defined: The result of
a complex arithmetic operation or complex elementary function reference
in overflow situations, when the Machine_Overflows attribute of the corresponding
real type is False.
6/2
{
AI950043401}
The error bounds for particular complex functions are tabulated
in
table G2 below. In the table, the
error bound is given as the coefficient of
CT.Real'Model_Epsilon.
7/1
This paragraph was
deleted.
Table G2: Error
Bounds for Particular Complex Functions
Function or Operator  Nature
of
Result  Nature of
Bound  Error Bound


Modulus  real  max.
rel. error  3.0

Argument  real  max.
rel. error  4.0

Compose_From_Polar  complex  max.
rel. error  3.0

"*" (both operands complex)  complex  max.
box error  5.0

"/" (right operand complex)  complex  max.
box error  13.0

Sqrt  complex  max.
rel. error  6.0

Log  complex  max.
box error  13.0

Exp (complex parameter)  complex  max.
rel. error  7.0

Exp (imaginary parameter)  complex  max.
rel. error  2.0

Sin, Cos, Sinh, and Cosh  complex  max.
rel. error  11.0

Tan, Cot, Tanh, and Coth  complex  max.
rel. error  35.0

inverse trigonometric  complex  max.
rel. error  14.0

inverse hyperbolic  complex  max.
rel. error  14.0

8
The maximum relative error given above applies throughout
the domain of the Compose_From_Polar function when the Cycle parameter
is specified. When the Cycle parameter is omitted, the maximum relative
error applies only when the absolute value of the parameter Argument
is less than or equal to the angle threshold (see
G.2.4).
For the Exp function, and for the forward hyperbolic (resp., trigonometric)
functions, the maximum relative error given above likewise applies only
when the absolute value of the imaginary (resp., real) component of the
parameter X (or the absolute value of the parameter itself, in the case
of the Exp function with a parameter of pureimaginary type) is less
than or equal to the angle threshold. For larger angles, the accuracy
is implementation defined.
8.a
Implementation defined: The accuracy
of certain complex arithmetic operations and certain complex elementary
functions for parameters (or components thereof) beyond the angle threshold.
9
The prescribed results
specified in
G.1.2 for certain functions
at particular parameter values take precedence over the error bounds;
effectively, they narrow to a single value the result interval allowed
by the error bounds for a component of the result. Additional rules with
a similar effect are given below for certain inverse trigonometric and
inverse hyperbolic functions, at particular parameter values for which
a component of the mathematical result is transcendental. In each case,
the accuracy rule, which takes precedence over the error bounds, is that
the result interval for the stated result component is the model interval
of
CT.Real associated with the component's exact mathematical
value. The cases in question are as follows:
10
 When the parameter X has the value
zero, the real (resp., imaginary) component of the result of the Arccot
(resp., Arccoth) function is in the model interval of CT.Real
associated with the value π/2.0.
11
 When the parameter X has the value
one, the real component of the result of the Arcsin function is in the
model interval of CT.Real associated with the value π/2.0.
12
 When the parameter X has the value
–1.0, the real component of the result of the Arcsin (resp., Arccos)
function is in the model interval of CT.Real associated with the
value –π/2.0 (resp., π).
12.a
Discussion: It is possible to give many
other prescribed results in which a component of the parameter is restricted
to a similar model interval when the parameter X is appropriately restricted
to an easily testable portion of the domain. We follow the proposed ISO/IEC
standard for Generic_Complex_Elementary_Functions (for Ada 83) in not
doing so, however.
13/2
{
AI950043401}
The amount by which a component of the result of an inverse trigonometric
or inverse hyperbolic function is allowed to spill over into a quadrant
adjacent to the one corresponding to the principal branch, as given in
G.1.2, is limited. The rule is that the result
belongs to the smallest model interval of
CT.Real that contains
both boundaries of the quadrant corresponding to the principal branch.
This rule also takes precedence
over to
the maximum error bounds, effectively narrowing the result interval allowed
by them.
14
Finally, the results allowed by the error bounds
are narrowed by one further rule: The absolute value of each component
of the result of the Exp function, for a pureimaginary parameter, never
exceeds one.
Implementation Advice
15
The version of the Compose_From_Polar function without
a Cycle parameter should not be implemented by calling the corresponding
version with a Cycle parameter of 2.0*Numerics.Pi, since this will not
provide the required accuracy in some portions of the domain.
15.a.1/2
Implementation Advice:
For complex arithmetic, the Compose_From_Polar
function without a Cycle parameter should not be implemented by calling
Compose_From_Polar with a Cycle parameter.
Wording Changes from Ada 83
15.a
The semantics of Numerics.Generic_Complex_Types
and Numerics.Generic_Complex_Elementary_Functions differs from Generic_Complex_Types
and Generic_Complex_Elementary_Functions as defined in ISO/IEC CDs 13813
and 13814 (for Ada 83) in ways analogous to those identified for the
elementary functions in
G.2.4. In addition,
we do not generally specify the signs of zero results (or result components),
although those proposed standards do.