poly4root: Roots of a Fourth Degree Polynomial

Description Usage Arguments Value Author(s) Examples

View source: R/poly4root.R

Description

While poly4root computes the (real-valued) roots of a polynomial of fourth degree, poly4rootMat can be applied to several polynomials of fourh degree at once by assuming that each row the input matrix contains the coefficients for one of the polynomials.

Usage

1
2
3

Arguments

a

a numeric vector of length five specifying the coefficients of the polynomial a[1]*x^4 + a[2]*x^3 + a[3]*x^2 + a[4]*x + a[5].

amat

a numeric matrix with five columns in which each row contains the five coefficients of a polynomial of fourth degree.

Value

For poly4root, a vector containing the real-valued roots of the polynomial. For poly4rootMat, a matrix with four columns in which each row contains the real-valued roots of the corresponding polynomial. If a polynomial has less than four real-valued roots, the remaining entries in the corresponding row are set to NA.

Author(s)

Holger Schwender, holger.schwender@udo.edu

Examples

1
2
3
4
# The roots of 
# 2 * x^4 + 3 * x^3 - x^2 + 5 * x^1 - 4 
# can be determined by
poly4root(c(2, 3, -1, 5, -4))

Example output

[1] -2.3318945  0.6491345
Warning message:
In sqrt(tmp) : NaNs produced

trio documentation built on Nov. 8, 2020, 7:41 p.m.