Learn R Programming

boostmath (version 1.0.0)

polynomial_root_finding: Polynomial Root-Finding

Description

Functions for finding roots of polynomials of various degrees.

Usage

quadratic_roots(a, b, c)

cubic_roots(a, b, c, d)

cubic_root_residual(a, b, c, d, root)

cubic_root_condition_number(a, b, c, d, root)

quartic_roots(a, b, c, d, e)

Value

A numeric vector of the polynomial roots, residual, or condition number.

Arguments

a

Coefficient of the polynomial term (e.g., for quadratic ax^2 + bx + c, a is the coefficient of x^2).

b

Coefficient of the linear term (e.g., for quadratic ax^2 + bx + c, b is the coefficient of x).

c

Constant term (e.g., for quadratic ax^2 + bx + c, c is the constant).

d

Coefficient of the cubic term (for cubic ax^3 + bx^2 + cx + d, d is the constant).

root

The root to evaluate the residual or condition number at.

e

Coefficient of the quartic term (for quartic ax^4 + bx^3 + cx^2 + dx + e, e is the constant).

Details

This package provides functions to find roots of quadratic, cubic, and quartic polynomials. The functions return the roots as numeric vectors.

Examples

Run this code
# Example of finding quadratic roots
quadratic_roots(1, -3, 2)
# Example of finding cubic roots
cubic_roots(1, -6, 11, -6)
# Example of finding quartic roots
quartic_roots(1, -10, 35, -50, 24)
# Example of finding cubic root residual
cubic_root_residual(1, -6, 11, -6, 1)
# Example of finding cubic root condition number
cubic_root_condition_number(1, -6, 11, -6, 1)

Run the code above in your browser using DataLab