A02AAF (PDF version)
A02 Chapter Contents
A02 Chapter Introduction
NAG Library Manual
NAG Library Routine Document
A02AAF
Note:
before using this routine, please read the Users' Note for your implementation to check the interpretation of
bold italicised
terms and other implementation-dependent details.
+
−
Contents
1
Purpose
2
Specification
3
Description
4
References
5
Parameters
6
Error Indicators and Warnings
7
Accuracy
8
Further Comments
+
−
9
Example
9.1
Program Text
9.2
Program Data
9.3
Program Results
1 Purpose
A02AAF evaluates the square root of the complex number
x
=
x
r
,
x
i
.
2 Specification
SUBROUTINE A02AAF (
XR
,
XI
,
YR
,
YI
)
REAL (KIND=nag_wp)
XR, XI, YR, YI
3 Description
The method of evaluating
y
=
x
depends on the value of
x
r
.
For
x
r
≥
0
,
y
r
=
x
r
+
x
r
2
+
x
i
2
2
,
y
i
=
x
i
2
y
r
.
For
x
r
<
0
,
y
i
=
sign
x
i
×
x
r
+
x
r
2
+
x
i
2
2
,
y
r
=
x
i
2
y
i
.
Overflow is avoided when squaring
x
i
and
x
r
by calling
A02ABF
to evaluate
x
r
2
+
x
i
2
.
4 References
Wilkinson J H and Reinsch C (1971)
Handbook for Automatic Computation II, Linear Algebra
Springer–Verlag
5 Parameters
1: XR – REAL (KIND=nag_wp)
Input
2: XI – REAL (KIND=nag_wp)
Input
On entry
:
x
r
and
x
i
, the real and imaginary parts of
x
, respectively.
3: YR – REAL (KIND=nag_wp)
Output
4: YI – REAL (KIND=nag_wp)
Output
On exit
:
y
r
and
y
i
, the real and imaginary parts of
y
, respectively.
6 Error Indicators and Warnings
None.
7 Accuracy
The result should be correct to
machine precision
.
8 Further Comments
The time taken by A02AAF is negligible.
9 Example
This example finds the square root of
-
1.7
+
2.6
i
.
9.1 Program Text
Program Text (a02aafe.f90)
9.2 Program Data
Program Data (a02aafe.d)
9.3 Program Results
Program Results (a02aafe.r)
A02AAF (PDF version)
A02 Chapter Contents
A02 Chapter Introduction
NAG Library Manual
© The Numerical Algorithms Group Ltd, Oxford, UK. 2012