s07aa returns the value of the circular tangent, tanx.


public static double s07aa(
	double x,
	out int ifail
Visual Basic
Public Shared Function s07aa ( _
	x As Double, _
	<OutAttribute> ByRef ifail As Integer _
) As Double
Visual C++
static double s07aa(
	double x, 
	[OutAttribute] int% ifail
static member s07aa : 
        x : float * 
        ifail : int byref -> float 


Type: System..::..Double
On entry: the argument x of the function.
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Return Value

s07aa returns the value of the circular tangent, tanx.


s07aa calculates an approximate value for the circular tangent of its argument, tanx. It is based on the Chebyshev expansion
where -π4<θ<π4 and -1<t<+1,  t=24θπ2-1.
The reduction to the standard range is accomplished by taking
where N is an integer and -π4<θ<π4,
i.e., θ=x-2xππ2 where N=2xπ=​ the nearest integer to ​2xπ.
From the properties of tanx it follows that


Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

Error Indicators and Warnings

Errors or warnings detected by the method:
The method has been called with an argument that is larger in magnitude than F; the default result returned is zero. The value of F is given in the Users' Note for your implementation.
The method has been called with an argument that is too close (as determined using the relative tolerance F) to an odd multiple of π/2, at which the function is infinite; the method returns a value with the correct sign but a more or less arbitrary but large magnitude (see [Accuracy]). The value of F is given in the Users' Note for your implementation.
An error occured, see message report.


If δ and ε are the relative errors in the argument and result respectively, then in principle
That is a relative error in the argument, x, is amplified by at least a factor 2x/sin2x in the result.
Similarly if E is the absolute error in the result this is given by
The equalities should hold if δ is greater than the machine precision (δ is a result of data errors etc.) but if δ is simply the round-off error in the machine it is possible that internal calculation rounding will lose an extra figure.
The graphs below show the behaviour of these amplification factors.
Figure 1
Figure 1
Figure 2
Figure 2
In the principal range it is possible to preserve relative accuracy even near the zero of tanx at x=0 but at the other zeros only absolute accuracy is possible. Near the infinities of tanx both the relative and absolute errors become infinite and the method must fail (error 2).
If N is odd and θxF2 the method could not return better than two figures and in all probability would produce a result that was in error in its most significant figure. Therefore the method fails and it returns the value
which is the value of the tangent at the nearest argument for which a valid call could be made.
Accuracy is also unavoidably lost if the method is called with a large argument. If x>F1 the method fails (error 1) and returns zero. (See the Users' Note for your implementation for specific values of F1 and F2.)

Parallelism and Performance


Further Comments



This example reads values of the argument x from a file, evaluates the function at each value of x and prints the results.

Example program (C#): s07aae.cs

Example program data: s07aae.d

Example program results: s07aae.r

See Also