Re: New user question

*To*: mathgroup at smc.vnet.net*Subject*: [mg20456] Re: New user question*From*: paul <paul at physics.uwa.edu.au>*Date*: Wed, 27 Oct 1999 02:04:34 -0400*Organization*: University of Western Australia*References*: <7uefh0$277@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Thomas Moriarty wrote: > I have just begun to use/learn Mathematica. One of the first things I > tried was to Plot[x^(1/3),{x,-5,5}] and got error messages indicating that > the negatives^(1/3) were not machine level real numbers (or close to > that) - the positive side displayed ok. > > What am I doing wrong? Your question is answered at http://support.wolfram.com/Graphics/TwoD/PlotPower.html _______________________________________________________________________________ How do I Plot the function x^(1/3) for negative values of x? The error messages generated when plotting x^(1/3) for negative values of x Plot[x^(1/3), {x, -1, 1}] are generated because x^(1/3) evaluates to a complex number for negative values of x. For more information on this behavior, please see the following FAQ. http://support.wolfram.com/Math/Algebra/RealPower.html At this link, the following question is answered: _______________________________________________________________________________ How do I get x^(1/3) (where x is a negative number) to evaluate to a real number? The function x^y, or Power[x, y], is defined by the following equation x^y == Exp[y Log[x]] for all expressions x and y. This identity gives the principal branch of the Power function. If y is a fraction, as in x^(1/3), this identity gives the principal root of x. Mathematica uses the principal root by default. Another way to define x^(1/3) is to say that it is a number z such that z^3 equals x. For every value of x, there are three numbers with this property, at least two of which are complex. A common and general way of selecting a single number is to choose the principal root. If x is negative, the principal branch of x^y will always give a complex number unless y is an integer. To understand this fact, it is important to look at the definition of x^y and realize that the principal branch of the logarithm function Log[x] has an imaginary part of I Pi when x is negative. This imaginary part is reflected in the value of x^y. Here is a simple example showing this effect in Mathematica. In[1]:= Log[-2.7] Out[1]= 0.993252 + 3.14159 I In[2]:= (-2.7)^(1/3) Out[2]= 0.696238 + 1.20592 I In applications where complex numbers are not used, or in educational situations where complex numbers have not been introduced, it is common to treat odd roots of negative real numbers as a special case, and to use the real root rather than the principal root for an expression such as (-1.0)^(1/3). You can cause Mathematica to use the real root in these situations by loading the package Utilities`RealOnly`, which add a rule that changes the definition of the Power function. In[3]:= Needs["Miscellaneous`RealOnly`"] Here is an example showing the effect of this rule. In[4]:= (-2.7)^(1/3) Out[4]= -1.39248 Instead of being a complex number, the result is now a negative real number. Changing the definition of Power[x, y] is usually a safe thing to do, especially if you are not using complex numbers directly, and you are not using packages that use principal roots internally. There are, however, very good reasons for using the principal branch of x^y. For example, the identity (z^(2/3))^(3/2) == z is true for all values of z if the principal branch of Power[x, y] is used, but it is not true if Power[x, y] is redefined. Also, redefinition of Power[x, y] causes the function (-1)^(1/n) to have point singularities for odd integer values of n, and will have an analogous effect on contour integrals. Nevertheless, if issues related to complex numbers are not important in your application, then changing the definition of Power[x, y] as described above is usually a safe thing to do, and will give the behavior that is often expected in these situations. _______________________________________________________________________________ Cheers, Paul -- ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul at physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul God IS a weakly left-handed dice player ____________________________________________________________________

**Re: Separating**

**Re: A simple question? Please help**

**Re: New user question**

**Display problems**