Re: Plot of (2 x^2 - x^3)^(1/3)
- To: mathgroup at smc.vnet.net
- Subject: [mg112084] Re: Plot of (2 x^2 - x^3)^(1/3)
- From: Peter Breitfeld <phbrf at t-online.de>
- Date: Sun, 29 Aug 2010 02:51:27 -0400 (EDT)
- References: <i5aqbk$eru$1@smc.vnet.net>
Bernard wrote: > I see in Calcul Diff=E9rentiel et int=E9gral, N. Piskounov, Editions > MIR, Moscou 1970, on p. 210 the graph of (2 x^2 - x^3)^(1/3) with > negative values for x > 2, something like : > > Plot[Piecewise[{{(2 x^2 - x^3)^(1/3), x <= 2}, {-Re[(2 x^2 - > x^3)^(1/3)], x > 2}}], {x, -1, 3}] > > When I plot this function with : > > Plot[(2 x^2 - x^3)^(1/3) // Re, {x, -1, 3}] > > I obtain positives values for x > 3. I don't understand why. > Thank you very much for your help ! The reason is, that Mathematica always uses complex arithmetic. Especially for multi-valued roots it takes the main value e^x=Exp[e Log[b]] f[x_]:=(2x^2-x^3)^(1/3) f[3] --> (-1)^(1/3)*3^(2/3) val=ComplexExpand[f[3]] --> (3/2)I*3^(1/6) + 3^(2/3) So f[3] is a complex number with positive real part. There are two ways to get your graph: 1. avoid non integer Powers, e.g. using ContourPlot ContourPlot[2x^2-x^2==y^3, {x,-1,3},{y,-3,3}] 2. define a version of Power, that uses the real branch like this: rprule=(b_?Negative)^Rational[m_,n_?OddQ]:>(-(-b)^(1/n))^m; Attributes[realPower]={Listable,NumericFunction, OneIdentity}; realPower[b_?Negative,Rational[m_,n_?OddQ]]:=(-(-b)^(1/n))^m realPower[x_,y_]:=x^y realPower[x]:=x//.rprule The last definition ensures, that realPower[(-8)^(1/3)] gives -2 Now Plot will work: g[x_]:=realPower[2x^2-x^2,1/3] Plot[g[x],{x,-1,3}] -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de