Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cube root for negative x

225 views
Skip to first unread message

robert....@gmail.com

unread,
May 18, 2008, 5:36:29 AM5/18/08
to
Hello, how can I plot the graph of cube root of x? Plotting x**(1.0/3)
gives graph for positive x only, but the cuberoot is defined also for
negative x. And x**(1/3) is a line y=1.Is there any option in gnuplot
which changes the bahavior of powers where denominator is odd integer?
Thanks.

R.M.

Hans-Bernhard Bröker

unread,
May 18, 2008, 9:59:08 AM5/18/08
to

No. There can't be any special treatment, because there is no such
thing as an exponent with an odd denominator in gnuplot. gnuplot
doesn't do fractional arithmetic. Thus no denominator.

gnuplot operates on complex numbers. In that regime (-x)**(1.0/3) for
positive x is not, as you expect it, equal to -(x**(1.0/3)). To see
what it really is, a parametric plot is in order:

set parametric
cbrt(x) = x**(1.0/3)
p [-10:10] real(cbrt(t)), imag(cbrt(t))

Juergen Wieferink

unread,
May 19, 2008, 2:51:31 AM5/19/08
to

You can get what you want using:

cbrt(x) = sgn(x) * abs(x)**(1./3.)
plot cbrt(x)

Please note that there is a difference between "the cuberoot is
defined also for negative x" and "the cuberoot can also be defined
for negative x". Generally, only the latter is true.

Juergen

0 new messages