Learn R Programming

trio (version 3.10.0)

poly4root: Roots of a Fourth Degree Polynomial

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

poly4root(a)
poly4rootMat(amat)

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

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.

Examples

Run this code
# 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))

Run the code above in your browser using DataLab