ploting x^(1/3)

0 views
Skip to first unread message

Hobus

unread,
Dec 18, 2009, 9:55:58 AM12/18/09
to sage-support
Why when I want to graph f=x^(1/3) I get the following error?
In this case, what should I do to get the complete graph?

sage: plot(x^(1/3),x,-1,1)

verbose 0 (2999: plot.py, generate_plot_points) WARNING: When
plotting,
failed to evaluate function at 100 points.
verbose 0 (2999: plot.py, generate_plot_points) Last error message:
'negative number to a fractional power not real'


And the graph goes wrong

Greetings

kcrisman

unread,
Dec 18, 2009, 1:21:16 PM12/18/09
to sage-support

There is some documentation at the end of
sage: plot?
that should cover this. Consistent with other similar programs (still
true, right?), we let (-1)^(1/3) be e^(pi*I/3), which can't be plotted
in this sense.

However, the graph itself is correct. You may be confused by the
axes; we typically try to have the axes not cross if the plotted
points are not close enough to the origin, which will usually be true
(there is some randomization) in this case, since you did not end at
x=0. The usual way to fix this is
sage: plot(x^(1/3),x,0,1)

I hope this helps!

- kcrisman

PS to sage-devel types:
sage: plot(x^(1/3),x,0,1) # still that annoying one-pixel thing -
where is it coming from???

Dan Aldrich

unread,
Dec 18, 2009, 3:01:47 PM12/18/09
to sage-s...@googlegroups.com
Two options I can think of, probably a lot more from the elders here:

1) turn off verbose
set_verbose(-1)
f(x) = x^(1/3)
plot(f(x),(-5,5))

2) Don't plot negative
f(x) = x^(1/3)
plot(f(x),(0,5))

-d

Reply all
Reply to author
Forward
0 new messages