Skip navigation

In plotting a simple cube root function y = x1/3, you expect to see a graph like this:
Real cube root graph

But when you do

x = -3:0.01:3;
y = x.^(1/3);

You get:
Complex cube root graph


“Pete wanted it that way.”

No, but really. Why is the plot of the cube root complex-valued, and not real-valued?

You should know that there are in fact __3__ cube roots for any number.

For instance, -3 has 1 real, and 2 COMPLEX cube roots:

The three cube roots of -3 are:

  • 0.7211 + 1.2490i
  • 0.7211 – 1.2490i
  • -1.44224

They look like this in the complex plane. Notice that they are separated by 120 degrees.

roots of -3

When you multiply those cube roots together, you get -3 again:

(0.7211 + 1.249i)*(0.7211 - 1.249i)*(-1.44224)
= (2.08)(-1.44224)
= -3

When you do:

x = -3:0.01:3;
y = x.^(1/3);

Matlab is putting the first cube root inside y (values like 0.7211 + 1.2490i as the cube root of -3), hence giving y complex values.

Howdya get it to give you just the real ones? Use Matlab’s nthroot function. For example, try:

x = -3:0.01:3;
y = nthroot( x, 3 );

just see this.

y = nthroot(X, n) returns the real nth root of the elements of X. Both X and n must be real and n must be a scalar. If X has negative entries, n must be an odd integer.


nthroot(-2, 3)
returns the real cube root of -2.

ans =




    • Anonymous
    • Posted December 13, 2008 at 10:35 pm
    • Permalink


    • Anonymous
    • Posted March 12, 2009 at 8:39 pm
    • Permalink

    thank you

    • tin
    • Posted December 31, 2011 at 11:55 am
    • Permalink

    thanks for your post.But If it is the nth root, is the angle equal pi/n ? And is there any way to get that n from the function ex:
    f= (((x-1)^2)*(x-4))^(1/3) (n=3 for this func) which is already in workspace?

    • emilio
    • Posted March 15, 2012 at 10:12 am
    • Permalink

    buenas me gustaria saber como se represeta el seno de la raiz cubica de x y el seno al cubo en el intervalo [0,2*pi]..muxas gracias y un saludo

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: