nthroot
Nth root of symbolic numbers
Syntax
Description
Examples
Calculate Nth Roots
Calculate the nth root of a negative number.
x = sym(-27); n = -3; y = nthroot(x,n)
y =
Check that the answer solves the equation .
y^n
ans =
Calculate the nth root of a complex number.
x = sym(1 + 1i); y = nthroot(x,4)
y =
Find a numeric equivalent of the root.
vpa(y)
ans =
Check that the answer solves the equation .
y^4
ans =
Calculate the nth roots of an array.
x = sym([-27,-8,-4 27,64,-12])
x =
n = sym([3,3,4 3,2,-2])
n =
y = nthroot(x,n)
y =
Check that the answer solves the equation .
y.^n
ans =
Use nthroot
in further symbolic calculations.
syms x
y = solve(nthroot(x,-3) == -3, x)
y =
syms x n y = diff(nthroot(x,n),x)
y =
Input Arguments
x
— Input array for taking root
symbolic array | numeric array
Input array for taking root, specified as a symbolic or numeric array. When taking the root, the function acts element-wise.
If both x
and n
are nonscalar arrays, they
must have the same size. If any element of x
or n
is symbolic and some elements are numeric, nthroot
converts numeric
arguments to symbolic before processing.
Example: [sym(-8),sym(8);sym(-27),sym(27)]
n
— Input array for order of root
symbolic array | real array
Input array for order of root, specified as a symbolic array or real array.
If an element of
x
is not real and positive, meaning it is either negative or has a nonzero imaginary part, then the corresponding element ofn
must be a nonzero integer.If an element of
x
is real and positive, then the corresponding element ofn
can have any nonzero real value.
If both x
and n
are nonscalar arrays, they
must have the same size. If any element of x
or n
are symbolic and some elements are numeric, nthroot
converts numeric
arguments to symbolic before processing.
Example: sym(-3)
Version History
Introduced in R2018b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)