Root Functions

Root functions are of the form f(x) = (Sqrt[x]) and  f(x) = (x^(1/n)).  In Mathematica the square root function is represented by Sqrt[x] as in the following example.

Plot[Sqrt[x],{x,-2,5}]

We can also use exponential notation for doing roots, so the square root can also be represented by x^(1/2), as below

Plot[x^(1/2),{x,-2,5}]

If you want to do a root of a higher index, such as (x^(1/3)), (x^(1/4)) or (x^(1/5)) you need to use the exponential forms, (x^(1/3)), (x^(1/4)) or (x^(1/5)). And so on.  You need to be careful with fractional exponents when using any technology.  The reason for this is that numerical programs use exponentials and logarithms to find the value of (a^b).  Specifically, (a^b) = (e^(b ln(a))).  So if a < 0 the expression is not real and when doing plots or evaluations we do not get results when a < 0, as can be seen in the plot below.

Plot[x^(1/3),{x,-2,5}]

As we all know ((-1)^(1/3)) is real, in fact it is -1.  This, among other things, tells us that the graph above is not what we expect.  Some computer algebra systems include another function for doing roots.  If Mathematica has one, I have not found it but creating one is fairly simple and we have made one below.  Don't worry about what all of it means just concentrate on how to use it.  The command is the surd command, surd is actually the name of the root symbol.  The syntax is surd(n, x) where n is the index of the root.  So the cube root of x is surd(3, x).

surd[n_,x_]:=If[Mod[n,2]==0,x^(1/n),Piecewise[{{x^(1/n), x≥0},{-(-x)^(1/n), x<0}}]]

Note that the graph below is what we would expect from y = (x^(1/3)).

Plot[surd[3,x],{x,-5,5}]

If we want to graph y = (x^(2/3)), that is y = ((x^2)^(1/3)) we would use,

Plot[surd[3,x^2],{x,-5,5}]

Note as well that this function also works for square roots, and any even indexed root.

Plot[surd[2,x],{x,-5,5}]

Plot[Sqrt[x],{x,-5,5}]

Just another nifty example,

Plot[surd[3,x^3-5x+3],{x,-5,5},PlotPoints->5000]

Now you may be wondering why Mathematica does not just make x^(1/3) work like the surd function we created.  This is not an oversight.  Mathematica is capable of doing symbolic calculus, differential equations, linear algebra, discrete mathematics, number theory, abstract algebra, complex analysis and on and on.  So why does it seem that something as easy as a fractional exponent confuses it.  Well it doesn't, the simple fact is that Mathematica is doing the right thing, even though it is not what you expect.  When you write (8^(1/3)) or (8^(1/3)) you are really asking for the solutions to the equation (x^3)=8, and there are three of them, as you can see below.  The solution 2 is just one of them, and there are two other solutions that are not real numbers.

Solve[x^3==8,x]

N[%]

If we evaluate 8^(1/3) in Mathematica we get 2, what we would expect.

8^(1/3)

But if we evaluate (-8)^(1/3) we do not get -2, which is what we would expect.

(-8)^(1/3)

N[%]

What Mathematica does is return the Principle Root.   If we are taking the root of a positive number the principle root is what we expect, but for negative numbers the principle root is not.  When we created the surd function we forced the output for negative numbers to be what we would expect in a calculus class.  If you were taking a course in complex variables then Mathematica's standard output is the one you would want.

surd[3,-8]

(-8)^(1/3)

N[%]

This notebook was written by Dr. Don Spickler and is used here with permission.

When you have finished reading and executing this notebook... go back to the labs page in your browser and follow the instructions there.