Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: What to do in v. 6 in place of Miscellaneous`RealOnly

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76811] Re: [mg76799] Re: [mg76728] Re: What to do in v. 6 in place of Miscellaneous`RealOnly
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Mon, 28 May 2007 00:50:46 -0400 (EDT)
  • References: <f33ork$l7l$1@smc.vnet.net> <f36dbl$6eo$1@smc.vnet.net> <200705260840.EAA18695@smc.vnet.net> <200705270906.FAA03577@smc.vnet.net>

Andrzej Kozlowski wrote:

>On 26 May 2007, at 17:40, Helen Read wrote:
>
>  
>
>>David W.Cantrell wrote:
>>    
>>
>>>Helen Read <read at math.uvm.edu> wrote:
>>>      
>>>
>>>>Suppose my calculus students want to plot x^(1/3), for say  
>>>>{x,-8,8}. The
>>>>problem, of course, is that Mathematica returns complex roots for  
>>>>x<0.
>>>>In past versions of Mathematica, we could get the desired real roots
>>>>(and plot the function) by loading the package  
>>>>Miscellaneous`RealOnly. I
>>>>guess we can still do it that way (and ignore the "obsolete package"
>>>>message), but is there a suggested way of doing what we need in 6.0?
>>>>        
>>>>
>>>Perhaps have them define their own
>>>
>>>realCubeRoot[x_]:= Sign[x] Abs[x]^(1/3)
>>>
>>>which plots as desired, of course.
>>>      
>>>
>>Well, yes, but it's kind of a pain to have to define their own root
>>functions this way on an individual basis. (Not to mention, it
>>completely hoses the derivative. Try realCubeRoot'[x] or
>>realCubeRoot'[-8] and see what you get.)
>>
>>I was hoping for a more convenient way to do this in Mathematica 6.0.
>>Surely it *knows* the real nth roots of x for n odd and x<0. It  
>>would be
>>nice to be able to define f[x_]=x^(1/3) or x^(3/5) or whatever and  
>>just
>>set some option to make it return the real value for x<0.
>>
>>--
>>Helen Read
>>University of Vermont
>>
>>    
>>
>
>
>Yes, it knows it, and there is a way of expressing it, but I am sure  
>you won't like it.
>
>realCubeRoot[x_] := Root[#^3 - x &, 1]
>
>Now,
>
>realCubeRoot[-1]
>-1
>
>etc. Plotting is no problem. Moreover you can differentiate, but only  
>using D !
>
>  D[realCubeRoot[x], x] /. x -> 8
>  1/12
>
>It won't work with Derivative :
>
>realCubeRoot'[x]
>0
>
>And just in case anyone thinks of reporting the last output as a bug  
>to WRI, this has been known ever since RootObject appeared in version  
>3 of Mathematica.
>
>Andrzej Kozlowski
>
>  
>
If we change the definition of realCubeRoot to avoid the use of Slots 
(#), then we can get Derivative to work as well:

In[35]:= realCubeRoot[x_] := Root[Function[z, z^3 - x], 1]

In[36]:= realCubeRoot'[x]
Out[36]= 1/(3 Root[#1^3-x&,1]^2)

However, note the unfortunate reappearance of Slot in the result.

Carl Woll
Wolfram Research


  • Prev by Date: Re: Re: Stopping Automatic Animation in v6
  • Next by Date: Re: Sierpinski's thing
  • Previous by thread: Re: Re: What to do in v. 6 in place of Miscellaneous`RealOnly
  • Next by thread: Re: Re: What to do in v. 6 in place of Miscellaneous`RealOnly