PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_zeros_quadratic_complex (c02ah)
Purpose
nag_zeros_quadratic_complex (c02ah) determines the roots of a quadratic equation with complex coefficients.
Syntax
Description
nag_zeros_quadratic_complex (c02ah) attempts to find the roots of the quadratic equation
(where
,
and
are complex coefficients), by carefully evaluating the ‘standard’ closed formula
It is based on the function CQDRTC from
Smith (1967).
Note: it is not necessary to scale the coefficients prior to calling the function.
References
Smith B T (1967) ZERPOL: a zero finding algorithm for polynomials using Laguerre's method Technical Report Department of Computer Science, University of Toronto, Canada
Parameters
Compulsory Input Parameters
- 1:
– double scalar
- 2:
– double scalar
-
ar and
ai must contain the real and imaginary parts respectively of
, the coefficient of
.
- 3:
– double scalar
- 4:
– double scalar
-
br and
bi must contain the real and imaginary parts respectively of
, the coefficient of
.
- 5:
– double scalar
- 6:
– double scalar
-
cr and
ci must contain the real and imaginary parts respectively of
, the constant coefficient.
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
The real and imaginary parts of the smallest root in magnitude are stored in and respectively.
- 2:
– double array
-
The real and imaginary parts of the largest root in magnitude are stored in and respectively.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
- W
-
On entry, . In this case, and contain the real and imaginary parts respectively of the root .
-
-
On entry,
and
. In this case,
contains the largest machine representable number (see
nag_machine_real_largest (x02al)) and
contains zero.
-
-
On entry,
and the root
overflows. In this case,
contains the largest machine representable number (see
nag_machine_real_largest (x02al)) and
contains zero.
-
-
On entry, and the root overflows. In this case, both and contain zero.
-
-
On entry, is so large that is indistinguishable from and the root overflows, where , and . In this case, and contain the real and imaginary parts respectively of the root .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
If
on exit, then
contains the largest machine representable number (see
nag_machine_real_largest (x02al)) and
contains zero.
Accuracy
If
on exit, then the computed roots should be accurate to within a small multiple of the
machine precision except when underflow (or overflow) occurs, in which case the true roots are within a small multiple of the underflow (or overflow) threshold of the machine.
Further Comments
None.
Example
This example finds the roots of the quadratic equation
.
Open in the MATLAB editor:
c02ah_example
function c02ah_example
fprintf('c02ah example results\n\n');
ar = 1; ai = 0;
br = -3; bi = 1;
cr = 8; ci = 1;
[zsm, zlg, ifail] = c02ah(ar, ai, br, bi, cr, ci);
disp('Roots of the quadratic equation:');
z(1) = zsm(1) + i*zsm(2);
z(2) = zlg(1) + i*zlg(2);
disp(z');
c02ah example results
Roots of the quadratic equation:
1.0000 - 2.0000i
2.0000 + 3.0000i
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015