# naginterfaces.library.zeros.cubic_​real¶

naginterfaces.library.zeros.cubic_real(u, r, s, t)[source]

cubic_real determines the roots of a cubic equation with real coefficients.

For full information please refer to the NAG Library document for c02ak

https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/c02/c02akf.html

Parameters
ufloat

, the coefficient of .

rfloat

, the coefficient of .

sfloat

, the coefficient of .

tfloat

, the constant coefficient.

Returns
zerocomplex, ndarray, shape

contains the th root.

errestfloat, ndarray, shape

contains an approximate error estimate for the th root.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

The companion matrix cannot be formed without overflow.

(errno )

Failure to converge in lapackeig.dhseqr.

Notes

In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

cubic_real attempts to find the roots of the cubic equation

where , , and are real coefficients with . The roots are located by finding the eigenvalues of the associated (upper Hessenberg) companion matrix given by

The eigenvalues are obtained by a call to lapackeig.dhseqr. Further details can be found in Further Comments.

To obtain the roots of a quartic equation, quartic_real() can be used.

References

Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore