root

Symbolic k-th root of a polynomial, left unevaluated.

Category: Mathematics > Polynomials

Syntax

r = root(p, x, k)

The k-th root of the polynomial p in the variable x.

r = root(p, x)

Column vector with all the roots of p.

Description

The result represents an exact root of a polynomial without needing a closed form, which matters for polynomials of degree five and above where no general formula exists. It prints as root(p, x, k) and can be turned into a number with vpa or double.

An index larger than the degree of the polynomial is an error. When the polynomial has multiple distinct roots, the root objects are numbered in a fixed order, so root(p, x, 1) always refers to the same root.

Input arguments

p
Symbolic polynomial.
x
Variable of the polynomial.
k
Index of the root, from 1 to the degree of p.

Output arguments

r
A symbolic object that stands for the root. It can be evaluated with vpa or double.

Example

Exact and numeric root

syms x
root(x^2 - 2, x)
r = root(x^3 - x - 1, x, 1);
vpa(r, 6)
Output
ans = 
root(x^2 - 2, x, 1)
root(x^2 - 2, x, 2)
ans = 1.32472

See also

roots solve vpa poly2sym