G.2.4 Accuracy Requirements for the Elementary Functions
In the strict mode, the performance of Numerics.Generic_Elementary_Functions
shall be as specified here.
Implementation Requirements
When an exception
is not raised, the result of evaluating a function in an instance
EF
of Numerics.Generic_Elementary_Functions belongs to a
result interval,
defined as the smallest model interval of
EF.Float_Type that contains
all the values of the form
f ·
(1.0 +
d), where
f
is the exact value of the corresponding mathematical function at the
given parameter values,
d is a real
number, and |
d| is less than or equal
to the function's
maximum relative error.
The
function delivers a value that belongs to the result interval when both
of its bounds belong to the safe range of
EF.Float_Type; otherwise,
if
EF.Float_Type'Machine_Overflows
is True, the function either delivers a value that belongs to the result
interval or raises Constraint_Error, signaling overflow;
if EF.Float_Type'Machine_Overflows
is False, the result is implementation defined.
Implementation defined: The result of
an elementary function reference in overflow situations, when the Machine_Overflows
attribute of the result type is False.
The maximum relative
error exhibited by each function is as follows:
2.0 · EF.Float_Type'Model_Epsilon,
in the case of the Sqrt, Sin, and Cos functions;
4.0 · EF.Float_Type'Model_Epsilon,
in the case of the Log, Exp, Tan, Cot, and inverse trigonometric functions;
and
8.0 · EF.Float_Type'Model_Epsilon,
in the case of the forward and inverse hyperbolic functions.
The maximum relative error exhibited by the exponentiation
operator, which depends on the values of the operands, is (4.0 + |Right
· log(Left)| / 32.0) · EF.Float_Type'Model_Epsilon.
The maximum relative error given above applies throughout
the domain of the forward trigonometric functions when the Cycle parameter
is specified.
When the Cycle parameter is omitted,
the maximum relative error given above applies only when the absolute
value of the angle parameter X is less than or equal to some implementation-defined
angle threshold, which shall be at least
EF.Float_Type'Machine_Radix
Floor(EF.Float_Type'Machine_Mantissa/2).
Beyond the angle threshold, the accuracy of the forward trigonometric
functions is implementation defined.
Implementation defined: The value of
the angle threshold, within which certain elementary functions,
complex arithmetic operations, and complex elementary functions yield
results conforming to a maximum relative error bound.
Implementation defined: The accuracy
of certain elementary functions for parameters beyond the angle threshold.
Implementation Note: The angle threshold
indirectly determines the amount of precision that the implementation
has to maintain during argument reduction.
{
AI95-00434-01}
The prescribed results specified in
A.5.1
for certain functions at particular parameter values take precedence
over the maximum relative error bounds; effectively, they narrow to a
single value the result interval allowed by the maximum relative error
bounds. Additional rules with a similar effect are given by table G-1
for the inverse trigonometric functions, at particular parameter values
for which the mathematical result is possibly not a model number of
EF.Float_Type
(or is, indeed, even transcendental). In each table entry, the values
of the parameters are such that the result lies on the axis between two
quadrants; the corresponding accuracy rule, which takes precedence over
the maximum relative error bounds, is that the result interval is the
model interval of
EF.Float_Type associated with the exact mathematical
result given in the table.
This paragraph was
deleted.
The last line of the table is meant to apply when
EF.Float_Type'Signed_Zeros is False; the two lines just above
it, when EF.Float_Type'Signed_Zeros is True and the parameter
Y has a zero value with the indicated sign.
Table G-1: Tightly Approximated Elementary Function Results
Function | Value of
X | Value of Y | Exact
Result
when Cycle
Specified | Exact Result
when Cycle
Omitted
|
---|
Arcsin | 1.0 | n.a. | Cycle/4.0 | π/2.0
|
Arcsin | –1.0 | n.a. | –Cycle/4.0 | –π/2.0
|
Arccos | 0.0 | n.a. | Cycle/4.0 | π/2.0
|
Arccos | –1.0 | n.a. | Cycle/2.0 | π
|
Arctan and Arccot | 0.0 | positive | Cycle/4.0 | π/2.0
|
Arctan and Arccot | 0.0 | negative | –Cycle/4.0 | –π/2.0
|
Arctan and Arccot | negative | +0.0 | Cycle/2.0 | π
|
Arctan and Arccot | negative | –0.0 | –Cycle/2.0 | –π
|
Arctan and Arccot | negative | 0.0 | Cycle/2.0 | π
|
The amount by which the result of an inverse trigonometric
function is allowed to spill over into a quadrant adjacent to the one
corresponding to the principal branch, as given in
A.5.1,
is limited. The rule is that the result belongs to the smallest model
interval of
EF.Float_Type that contains both boundaries of the
quadrant corresponding to the principal branch. This rule also takes
precedence over the maximum relative error bounds, effectively narrowing
the result interval allowed by them.
Finally, the following
specifications also take precedence over the maximum relative error bounds:
The absolute value of the result of the Sin, Cos,
and Tanh functions never exceeds one.
The absolute value of the result of the Coth function
is never less than one.
The result of the Cosh function is never less than
one.
Implementation Advice
The versions of the forward trigonometric functions
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. For the
same reason, the version of Log without a Base parameter should not be
implemented by calling the corresponding version with a Base parameter
of Numerics.e.
Implementation Advice: For elementary
functions, the forward trigonometric functions without a Cycle parameter
should not be implemented by calling the corresponding version with a
Cycle parameter. Log without a Base parameter should not be implemented
by calling Log with a Base parameter.
Wording Changes from Ada 83
The semantics
of Numerics.Generic_Elementary_Functions differs from Generic_Elementary_Functions
as defined in ISO/IEC DIS 11430 (for Ada 83) in the following ways related
to the accuracy specified for strict mode:
The maximum relative error bounds use the
Model_Epsilon attribute instead of the Base'Epsilon attribute.
The accuracy requirements are expressed in
terms of result intervals that are model intervals. On the one hand,
this facilitates the description of the required results in the presence
of underflow; on the other hand, it slightly relaxes the requirements
expressed in ISO/IEC DIS 11430.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe