• No results found

5.3 Elementary transcendental floating point operations

5.3.10 Operations for trigonometrics with given angular unit

There shall be one big-angle parameter for argument angular-unit trigonometric operations:

big angle uF ∈ F

It should have the following default value:

big angle uF = drFdpF/2e/6e

A binding or implementation can include a method to change the value for this parameter. This method should only allow the value of this parameter to be set to a value greater than or equal to 1 and such that ulpF(big angleF) 6 1/2000.

NOTE 1 – In order to allow ulpF(big angleF) 6 1/2000, pF > 2 + logrF(1000) should hold.

There shall be a derived parameter signifying the minimum allowed angular unit:

min angular unitF = rF · fminNF/epsilonF

NOTE 2 – That is,min angular unitF = rF(eminF−1+pF) To make the specifications below a bit easier to express, let

GF = {x ∈ F | min angular unitF 6 |x|}.

Let T = {1, 2, 360, 400, 6400}. T consists of angle values for exactly one revolution for some common non-radian angular units: cycles, half-cycles, arc degrees, grades, and mils.

There shall be two parameterised maximum error parameters for argument angular-unit trigonometric operations:

max error sinuF : F → F ∪ {invalid}

max error tanuF : F → F ∪ {invalid}

For u ∈ GF, the max error sinuF(u) parameter shall have a value in the interval [max error sinF, 2].

The max error sinuF(u) parameter shall have the value of max error sinF if |u| ∈ T . For u ∈ GF, the max error tanuF(u) parameter shall have a value in the interval [max error tanF, 4].

The max error tanuF(u) parameter shall have the value of max error tanF if |u| ∈ T . The max error sinuF(u) and max error tanuF(u) parameters return invalid if u 6∈ GF.

5.3.10.1 Argument angular-unit angle normalisation

The argument angular-unit normalisation computes exactly rad(2 · π · x/u) · u/(2 · π), where x is the angular value, and u is the angular unit.

The cycleF operation:

cycleF : F × F → F ∪ {−−−0, absolute precision underflow, invalid}

cycleF(u, x) = remrF(x, u) if u ∈ GF and (x = −−−0 or

(x ∈ F and |x/u| 6 big angle uF))

= absolute precision underflow(qNaN)

if u ∈ GF and x ∈ F and |x/u| > big angle uF

= result NaN2F(u, x) otherwise The axis cycleF operation:

axis cycleF : F × F → ((F × F ) × (F ∪ {−−−0})) ∪ {absolute precision underflow, invalid}

axis cycleF(u, x)

= (axis(u, x), resultF(x − (round(x · 4/u) · u/4), rndF))

if u ∈ GF and x ∈ F and |x/u| 6 big angle uF and (x/u > 0 or x − (round(x · 4/u) · u/4) 6= 0)

= (axis(u, x), −−−0) if u ∈ GF and x ∈ F and |x/u| 6 big angle uF and x/u < 0 and x − (round(x · 4/u) · u/4) = 0 and

= ((1, 0), −−−0) if u ∈ GF and x = −−−0

= absolute precision underflow((qNaN, qNaN), qNaN)

if u ∈ GF and x ∈ F and |x/u| > big angle uF

= ((qNaN, qNaN), qNaN)

if x is a quiet NaN and u is not a signalling NaN

= ((qNaN, qNaN), qNaN)

if u is a quiet NaN and x is not a signalling NaN

= invalid((qNaN, qNaN), qNaN) otherwise where

axis(u, x) = (1, 0) if round(x · 4/u) = 4 · n

= (0, 1) if round(x · 4/u) = 4 · n + 1

= (−1, 0) if round(x · 4/u) = 4 · n + 2

= (0, −1) if round(x · 4/u) = 4 · n + 3 for some n ∈ Z.

NOTES

1 axis cycleF(u, x) is exact when divF(u, 4) = u/4.

2 cycleF is an exact operation.

3 cycleF(u, x) is −−0 or has a result in the interval [−|u/2|, |u/2|] if there is no notification.

4 A zero resulting angle is negative if the original angle value is negative.

5 The cycleF operation is used also in the specifications of the unit argument trigonometric operations. This does not imply that the implementation has to use the cycle operation, when implementing the operations. Just that the results (including notifications) must be as if it did.

5.3.10.2 Argument angular-unit sine The sinuF approximation helper function:

sinuF : F × R → R

sinuF(u, x) returns a close approximation to sin(x · 2 · π/u) in R if u 6= 0, with maximum error max error sinuF(u).

Further requirements on the sinuF approximation helper function:

sinuF(u, n · u + x) = sinuF(u, x) if n ∈ Z and u ∈ F and u 6= 0 sinuF(u, u/12) = 1/2 if u ∈ F and u 6= 0

sinuF(u, u/4) = 1 if u ∈ F and u 6= 0 sinuF(u, 5 · u/12) = 1/2 if u ∈ F and u 6= 0 sinuF(u, −x) = −sinuF(u, x) if u ∈ F and u 6= 0 sinuF(−u, x) = −sinuF(u, x) if u ∈ F and u 6= 0 NOTE – sinuF(u, x) ≈ x · 2 · π/u if |x · 2 · π/u| < fminNF. The sinuF operation:

sinuF : F × F → F ∪ {−−−0, underflow, invalid, absolute precision underflow}

sinuF(u, x) = trans resultF(sinuF(u, x), nearestF)

if cycleF(u, x) ∈ F and cycleF(u, x) 6∈ {−u/2, 0, u/2}

= divF(0, u) if cycleF(u, x) ∈ {0, u/2}

= divF(−−−0, u) if cycleF(u, x) ∈ {−u/2, −−−0}

= cycleF(u, x) otherwise

5.3.10.3 Argument angular-unit cosine The cosuF approximation helper function:

cosuF : F × R → R

cosuF(u, x) returns a close approximation to cos(x · 2 · π/u) in R if u 6= 0, with maximum error max error sinuF(u).

Further requirements on the cosuF approximation helper function:

cosuF(u, n · u + x) = cosuF(u, x) if n ∈ Z and u ∈ F and u 6= 0 cosuF(u, 0) = 1 if u ∈ F and u 6= 0

cosuF(u, u/6) = 1/2 if u ∈ F and u 6= 0 cosuF(u, u/3) = −1/2 if u ∈ F and u 6= 0 cosuF(u, u/2) = −1 if u ∈ F and u 6= 0 cosuF(u, −x) = cosuF(u, x) if u ∈ F and u 6= 0 cosuF(−u, x) = cosuF(u, x) if u ∈ F and u 6= 0 NOTE – cosuF(u, x) = 1 should hold if |x · 2 · π/u| <pepsilonF/rF

The cosuF operation:

cosuF : F × F → F ∪ {underflow, invalid, absolute precision underflow}

cosuF(u, x) = trans resultF(cosuF(u, x), nearestF) if cycleF(u, x) ∈ F

= 1 if cycleF(u, x) = −−−0

= cycleF(u, x) otherwise

5.3.10.4 Argument angular-unit tangent The tanuF approximation helper function:

tanuF : F × R → R

tanuF(u, x) returns a close approximation to tan(x · 2 · π/u) in R if u 6= 0, with maximum error max error tanuF(u).

Further requirements on the tanuF approximation helper function:

tanuF(u, n · u + x) = tanuF(u, x) if n ∈ Z and u ∈ F and u 6= 0 tanuF(u, u/8) = 1 if u ∈ F and u 6= 0

tanuF(u, 3 · u/8) = −1 if u ∈ F and u 6= 0 tanuF(u, −x) = −tanuF(u, x) if u ∈ F and u 6= 0 tanuF(−u, x) = −tanuF(u, x) if u ∈ F and u 6= 0 NOTE 1 – tanuF(u, x) ≈ x · 2 · π/u if |x · 2 · π/u| < fminNF. The tanuF operation:

tanuF : F × F → F ∪ {−−−0, pole, overflow, underflow, invalid, absolute precision underflow}

tanuF(u, x) = trans resultF(tanuF(u, x), nearestF)

if cycleF(u, x) ∈ F and

cycleF(u, x) 6∈ {−u/2, −u/4, 0, u/4, u/2}

= divF(0, u) if cycleF(u, x) ∈ {−u/2, 0}

= divF(−−−0, u) if cycleF(u, x) ∈ {−−−0, u/2}

= pole(+∞+∞+∞) if cycleF(u, x) = u/4

= pole(−∞−∞−∞) if cycleF(u, x) = −u/4

= cycleF(u, x) otherwise

NOTE 2 – The pole notification can arise for tanuF(u, x) only when u/4 is in F .

5.3.10.5 Argument angular-unit cotangent The cotuF approximation helper function:

cotuF : F × R → R

cotuF(u, x) returns a close approximation to cot(x · 2 · π/u) in R if u 6= 0, with maximum error max error tanuF(u).

Further requirements on the cotuF approximation helper function:

cotuF(u, n · u + x) = cotuF(u, x) if n ∈ Z and u ∈ F and u 6= 0 cotuF(u, u/8) = 1 if u ∈ F and u 6= 0

cotuF(u, 3 · u/8) = −1 if u ∈ F and u 6= 0 cotuF(u, −x) = −cotuF(u, x) if u ∈ F and u 6= 0 cotuF(−u, x) = −cotuF(u, x) if u ∈ F and u 6= 0 The cotuF operation:

cotuF : F × F → F ∪ {−−−0, pole, overflow, underflow, invalid, absolute precision underflow}

cotuF(u, x) = trans resultF(cotuF(u, x), nearestF)

if cycleF(u, x) ∈ F and

cycleF(u, x) 6∈ {−u/2, −u/4, 0, u/2}

= −−−0 if cycleF(u, x) = −u/4

= divF(u, tanuF(u, x)) if cycleF(u, x) ∈ {−u/2, −−−0, 0, u/2}

= cycleF(u, x) otherwise

5.3.10.6 Argument angular-unit secant The secuF approximation helper function:

secuF : F × R → R

secuF(u, x) returns a close approximation to sec(x · 2 · π/u) in R if u 6= 0, with maximum error max error tanuF(u).

Further requirements on the secuF approximation helper function:

secuF(u, n · u + x) = secuF(u, x) if n ∈ Z and u ∈ F and u 6= 0 secuF(u, 0) = 1 if u ∈ F and u 6= 0

secuF(u, u/6) = 2 if u ∈ F and u 6= 0 secuF(u, u/3) = −2 if u ∈ F and u 6= 0 secuF(u, u/2) = −1 if u ∈ F and u 6= 0 secuF(u, −x) = secuF(u, x) if u ∈ F and u 6= 0 secuF(−u, x) = secuF(u, x) if u ∈ F and u 6= 0 secuF(u, x) = 1 if |x · 2 · π/u| < 0.5 ·√

epsilonF The secuF operation:

secuF : F × F → F ∪ {pole, overflow, invalid, absolute precision underflow}

secuF(u, x) = trans resultF(secuF(u, x), nearestF)

if cycleF(u, x) ∈ F and cycleF(u, x) 6∈ {−u/4, u/4}

= divF(1, cosuF(u, x)) if cycleF(u, x) ∈ {−u/4, −−−0, u/4}

= cycleF(u, x) otherwise

5.3.10.7 Argument angular-unit cosecant The cscuF approximation helper function:

cscuF : F × R → R

cscuF(u, x) returns a close approximation to csc(x · 2 · π/u) in R if u 6= 0, with maximum error max error tanuF(u).

Further requirements on the cscuF approximation helper function:

cscuF(u, n · u + x) = cscuF(u, x) if n ∈ Z and u ∈ F and u ∈ 0 cscuF(u, u/12) = 2 if u ∈ F and u 6= 0

cscuF(u, u/4) = 1 if u ∈ F and u 6= 0 cscuF(u, 5 · u/12) = 2 if u ∈ F and u 6= 0 cscuF(u, −x) = −cscuF(u, x) if u ∈ F and u 6= 0 cscuF(−u, x) = −cscuF(u, x) if u ∈ F and u 6= 0 The cscuF operation:

cscuF : F × F → F ∪ {pole, overflow, invalid, absolute precision underflow}

cscuF(u, x) = trans resultF(cscuF(u, x), nearestF)

if cycleF(u, x) ∈ F and cycleF(u, x) 6∈ {−u/2, 0, u/2}

= divF(1, sinuF(u, x)) if cycleF(u, x) ∈ {−u/2, −−−0, 0, u/2}

= cycleF(u, x) otherwise

5.3.10.8 Argument angular-unit cosine with sine

cossinuF : F × F → (F × (F ∪ {−−−0})) ∪ {underflow, invalid, absolute precision underflow}

cossinuF(u, x) = (cosuF(u, x), sinuF(u, x))

5.3.10.9 Argument angular-unit arc sine The arcsinuF approximation helper function:

arcsinuF : F × F → R

arcsinuF(u, x) returns a close approximation to arcsin(x) · u/(2 · π) in R, with maximum error max error sinuF(u).

Further requirements on the arcsinuF approximation helper function:

arcsinuF(u, 1/2) = u/12 arcsinuF(u, 1) = u/4

arcsinuF(u, −x) = −arcsinuF(u, x) arcsinuF(−u, x) = −arcsinuF(u, x)

NOTE – arcsinuF(u, x) ≈ u/(2 · π) if |x| < fminNF. Range limitation:

arcsinu#F(u, x) = max{upF(−|u/4|), min{arcsinuF(u, x), downF(|u/4|)}}

The arcsinuF operation:

arcsinuF : F × F → F ∪ {−−−0, underflow, invalid}

arcsinuF(u, x) = trans resultF(arcsinu#F(u, x), nearestF)

if u ∈ GF and x ∈ F and |x| 6 1 and x 6= 0

= mulF(u, x) if u ∈ GF and x ∈ {−−−0, 0}

= result NaN2F(u, x) otherwise

5.3.10.10 Argument angular-unit arc cosine The arccosuF approximation helper function:

arccosuF : F × F → R

arccosuF(u, x) returns a close approximation to arccos(x) · u/(2 · π) in R, with maximum error max error sinuF(u).

Further requirements on the arccosuF approximation helper function:

arccosuF(u, 1/2) = u/6 arccosuF(u, 0) = u/4 arccosuF(u, −1/2) = u/3 arccosuF(u, −1) = u/2

arccosuF(−u, x) = −arccosuF(u, x) Range limitation:

arccosu#F(u, x) = max{upF(−|u/2|), min{arccosuF(u, x), downF(|u/2|)}}

The arccosuF operation:

arccosuF : F × F → F ∪ {underflow, invalid}

arccosuF(u, x) = trans resultF(arccosu#F(u, x), nearestF)

if u ∈ GF and x ∈ F and |x| 6 1

= nearestF(u/4) if u ∈ GF and x = −−−0

= result NaN2F(u, x) otherwise

5.3.10.11 Argument angular-unit arc tangent The arctanuF approximation helper function:

arctanuF : F × F → R

arctanuF(u, x) returns a close approximation to arctan(x) · u/(2 · π) in R, with maximum error max error tanuF(u).

Further requirements on the arctanuF approximation helper function:

arctanuF(u, 1) = u/8

arctanuF(u, x) = u/4 if arctanuF(u, x) 6= arctan(x) · u/(2 · π) and x > 3 · rF/epsilonF

arctanuF(u, −x) = −arctanuF(u, x) arctanuF(−u, x) = −arctanuF(u, x)

NOTE 1 – arctanuF(u, x) ≈ u/(2 · π) if |x| < fminNF

Range limitation:

arctanu#F(u, x) = max{upF(−|u/4|), min{arctanuF(u, x), downF(|u/4|)}}

The arctanuF operation:

arctanuF : F × F → F ∪ {−−−0, invalid, underflow}

arctanuF(u, x) = trans resultF(arctanu#F(u, x), nearestF)

if u ∈ GF and x ∈ F and x 6= 0

= mulF(x, u) if u ∈ GF and x ∈ {−−−0, 0}

= upF(−u/4) if u ∈ GF and x = −∞−∞−∞ and u > 0

= downF(u/4) if u ∈ GF and x = +∞+∞+∞ and u > 0

= downF(−u/4) if u ∈ GF and x = −∞−∞−∞ and u < 0

= upF(u/4) if u ∈ GF and x = +∞+∞+∞ and u < 0

= result NaN2F(u, x) otherwise NOTE 2 – arctanuF(u, x) ≈ arcuF(u, 1, x).

5.3.10.12 Argument angular-unit arc cotangent

This clause specifies two inverse cotangent operations. One approximating the continuous (but not sign symmetric) arccot, the other approximating the sign symmetric (but discontinuous at 0) arcctg.

The arccotuF approximation helper function:

arccotuF : F × F → R

arccotuF(u, x) returns a close approximation to arccot(x) · u/(2 · π) in R, with maximum error max error tanuF(u).

The arcctguF approximation helper function:

arcctguF : F × F → R

arcctguF(u, x) returns a close approximation to arcctg(x) · u/(2 · π) in R, with maximum error max error tanuF(u).

Further requirements on the arccotuF and arcctguF approximation helper functions:

arccotuF(u, 1) = u/8 arccotuF(u, 0) = u/4 arccotuF(u, −1) = 3 · u/8

arccotuF(u, x) 6 u/2 if u > 0 arccotuF(u, x) > u/2 if u < 0

arccotuF(u, x) = u/2 if arccotuF(u, x) 6= arccot(x) · u/(2 · π) and x < −3 · rF/epsilonF

arccotuF(−u, x) = −arccotuF(u, x)

arcctguF(u, x) = arccotuF(u, x) if x > 0 arcctguF(u, −x) = −arcctguF(u, x)

Range limitation:

arccotu#F(u, x) = max{upF(−|u/2|), min{arccotuF(u, x), downF(|u/2|)}}

arcctgu#F(u, x) = max{upF(−|u/4|), min{arcctguF(u, x), downF(|u/4|)}}

The arccotuF operation:

arccotuF : F × F → F ∪ {invalid, underflow}

arccotuF(u, x) = trans resultF(arccotu#F(u, x), nearestF) if u ∈ GF and x ∈ F

= nearestF(u/4) if u ∈ GF and x = −−−0

= downF(u/2) if u ∈ GF and x = −∞−∞−∞ and u > 0

= upF(u/2) if u ∈ GF and x = −∞−∞−∞ and u < 0

= divF(u, x) if u ∈ GF and x = +∞+∞+∞

= result NaN2F(u, x) otherwise NOTE – arccotuF(u, x) ≈ arcuF(u, x, 1).

The arcctguF operation:

arcctguF : F × F → F ∪ {invalid, underflow}

arcctguF(u, x) = trans resultF(arcctgu#F(u, x), nearestF) if u ∈ GF and x ∈ F

= negF(arcctguF(u, 0)) if u ∈ GF and x = −−−0

= divF(u, x) if u ∈ GF and x ∈ {−∞−∞−∞, +∞+∞+∞}

= result NaN2F(u, x) otherwise

5.3.10.13 Argument angular-unit arc secant The arcsecuF approximation helper function:

arcsecuF : F × F → R

arcsecuF(u, x) returns a close approximation to arcsec(x) · u/(2 · π) in R, with maximum error max error tanuF(u).

Further requirements on the arcsecuF approximation helper function:

arcsecuF(u, 2) = u/6 arcsecuF(u, −2) = u/3 arcsecuF(u, −1) = u/2

arcsecuF(u, x) 6 u/4 if x > 0 and u > 0 arcsecuF(u, x) > u/4 if x < 0 and u > 0

arcsecuF(u, x) = u/4 if arcsecuF(u, x) 6= arcsec(x) · u/(2 · π) and

|x| > 3 · rF/epsilonF arcsecuF(−u, x) = −arcsecuF(u, x)

Range limitation:

arcsecu#F(u, x) = max{upF(−|u/4|), min{arcsecuF(u, x), downF(|u/4|)}}

if x > 1

= max{upF(u/4), min{arcsecuF(u, x), downF(u/2)}}

if x 6 −1 and u > 0

= max{upF(u/2), min{arcsecuF(u, x), downF(u/4)}}

if x 6 −1 and u < 0 The arcsecuF operation:

arcsecuF : F × F → F ∪ {underflow, invalid}

arcsecuF(u, x) = trans resultF(arcsecu#F(u, x), nearestF)

if u ∈ GF and x ∈ F and (x 6 −1 or x > 1)

= downF(u/4) if u ∈ GF and x = −∞−∞−∞ and u > 0

= upF(u/4) if u ∈ GF and x = +∞+∞+∞ and u > 0

= upF(u/4) if u ∈ GF and x = −∞−∞−∞ and u < 0

= downF(u/4) if u ∈ GF and x = +∞+∞+∞ and u < 0

= result NaN2F(u, x) otherwise

5.3.10.14 Argument angular-unit arc cosecant The arccscuF approximation helper function:

arccscuF : F × F → R

arccscuF(u, x) returns a close approximation to arccsc(x) · u/(2 · π) in R, with maximum error max error tanuF(u).

Further requirements on the arccscuF approximation helper function:

arccscuF(u, 2) = u/12 arccscuF(u, 1) = u/4

arccscuF(u, −x) = −arccscuF(u, x) arccscuF(−u, x) = −arccscuF(u, x) Range limitation:

arccscu#F(u, x) = max{upF(−|u/4|), min{arccscuF(u, x), downF(|u/4|)}}

The arccscuF operation:

arccscuF : F × F → F ∪ {underflow, invalid}

arccscuF(u, x) = trans resultF(arccscu#F(u, x), nearestF)

if u ∈ GF and x ∈ F and (x > 1 or x 6 −1)

= mulF(−u, 0) if u ∈ GF and x = −∞−∞−∞

= mulF(u, 0) if u ∈ GF and x = +∞+∞+∞

= result NaN2F(u, x) otherwise

5.3.10.15 Argument angular-unit angle from Cartesian co-ordinates The arcuF approximation helper function:

arcuF : F × F × F → R

arcuF(u, x, y) returns a close approximation to arc(x, y) · u/(2 · π) in R, with maximum error max error tanuF(u).

Further requirements on the arcuF approximation helper function:

arcuF(u, x, x) = u/8 if x > 0 arcuF(u, 0, y) = u/4 if y > 0 arcuF(u, x, −x) = 3 · u/8 if x < 0 arcuF(u, x, 0) = u/2 if x < 0

arcuF(u, x, −y) = −arcuF(u, x, y) if y 6= 0 or x > 0 arcuF(−u, x, y) = −arcuF(u, x, y)

Range limitation:

arcu#F(u, x, y) = max{upF(−|u/2|), min{arcuF(u, x, y), downF(|u/2|)}}

The arcuF operation:

arcuF : F × F × F → F ∪ {−−−0, underflow, invalid}

arcuF(u, x, y) = trans resultF(arcu#F(u, x, y), nearestF)

if u ∈ GF and x, y ∈ F and (x < 0 or y 6= 0)

= mulF(u, 0) if u ∈ GF and x ∈ F and x > 0 and y = 0

= 0 if u ∈ GF and x = 0 and y = 0

= downF(u/2) if u ∈ GF and x = −−−0 and y = 0 and u > 0

= upF(u/2) if u ∈ GF and x = −−−0 and y = 0 and u < 0

= arcuF(u, 0, y) if u ∈ GF and x = −−−0 and y ∈ F ∪ {−∞−∞−∞, +∞+∞+∞} and y 6= 0

= negF(arcuF(u, x, 0)) if u ∈ GF and y = −−−0 and x ∈ F ∪ {−∞−∞−∞, −−−0, +∞+∞+∞}

= mulF(0, u) if u ∈ GF and x = +∞+∞+∞ and y ∈ F and y > 0

= mulF(0, −u) if u ∈ GF and x = +∞+∞+∞ and y ∈ F and y < 0

= nearestF(u/8) if u ∈ GF and x = +∞+∞+∞ and y = +∞+∞+∞

= nearestF(u/4) if u ∈ GF and x ∈ F and y = +∞+∞+∞

= nearestF(3 · u/8) if u ∈ GF and x = −∞−∞−∞ and y = +∞+∞+∞

= downF(u/2) if u ∈ GF and x = −∞−∞−∞ and y ∈ F and y > 0 and u > 0

= upF(−u/2) if u ∈ GF and x = −∞−∞−∞ and y ∈ F and y < 0 and u > 0

= upF(u/2) if u ∈ GF and x = −∞−∞−∞ and y ∈ F and y > 0 and u < 0

= downF(−u/2) if u ∈ GF and x = −∞−∞−∞ and y ∈ F and y 6 0 and u < 0

= nearestF(−3 · u/8) if u ∈ GF and x = −∞−∞−∞ and y = −∞−∞−∞

= nearestF(−u/4) if u ∈ GF and x ∈ F and y = −∞−∞−∞

= nearestF(−u/8) if u ∈ GF and x = +∞+∞+∞ and y = −∞−∞−∞

= result NaN3F(u, x, y) otherwise