Learn R Programming

textir (version 1.5.2)

cubic: Cubic function solver

Description

Finds analytical roots to the function y = x^3 + ax^2 + bx + c

Usage

cubic(a, b, c, quiet=FALSE, plot=FALSE)

Arguments

a,b,c
Cubic function coefficients (MONIC FORM).
quiet
If false, the solution is printed to screen.
plot
If true, the function and real root(s) are plotted.

Value

  • A list with entries for the coefficients, roots, and solution characterization. In particular,
  • typeThe solution characterization is either "one real", "three real", or "one real, two complex".
  • coefThe input coefficients c(a,b,c).
  • rootsA vector for the cubic roots. The first root roots[1] is always real. If there are complex roots, roots[2] is the real part and roots[3] is the imaginary part (i.e., complex roots are roots[2] +- roots[3]*i). Otherwise, roots[2:3] are (possibly identical) real roots.

Details

Finds roots to the cubic function $y = x^3 + ax^2 + bx + c$.

References

Gerolamo Cardano, Ars Magna (1545)

See Also

'polyroot' for numerical solutions.

Examples

Run this code
cubic(0,-15,-4, plot=TRUE)

Run the code above in your browser using DataLab