Trying to graph cubic function f(x)=x^(1/3)

9 views
Skip to first unread message

Andy

unread,
Feb 22, 2008, 9:08:13 AM2/22/08
to sage-support
I am interested in the use of Sage as a teaching tool at all grade
levels. At the moment, I'm trying to weave Sage into an introductory
algebra curriculum.

I can graph all the basic functions with plot(x), replacing x with
x^2, x^3, 1/x, etc. The one I can't get to work is x^(1/3). I've
tried to express the cube root function several different ways. The
expression I'm using now is:

sage:
show(plot(x^(1/3),-10,10),figsize=[5,5],xmin=-10,xmax=10,ymin=-10,ymax=10)

I receive the error message "TypeError: 'float' object is
unsubscriptable"

Also, is the expression above the most succinct way to generate a
graph with this kind of view, x and y ranging -10 to 10?

Thanks for any advice.

Andy

Alex Ghitza

unread,
Feb 22, 2008, 9:19:12 AM2/22/08
to sage-s...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Andy,

I had the exact same question a few days ago. There are
many issues involved here, but the short answer to your
question (provided by Carl Witty) is:

you can plot x^(1/3) with

show(plot(lambda x : RR(x).nth_root(3), -10, 10), figsize=[5,5],
ymin=-10, ymax=10)

You don't need to specify xmin and xmax in show since they're
given in the plot command.

Best,
Alex


- --
Alexandru Ghitza
Assistant Professor
Department of Mathematics
Colby College
Waterville, ME 04901
http://bayes.colby.edu/~ghitza/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHvtngdZTaNFFPILgRAvbjAJ9qlM5R2UnmCHwOMV2HOlhg+LcwZACcC21K
Mrx/wRMSjGXeYz2KpkXN0Xo=
=O3v+
-----END PGP SIGNATURE-----

William Stein

unread,
Feb 22, 2008, 11:36:08 AM2/22/08
to sage-s...@googlegroups.com
On Fri, Feb 22, 2008 at 6:19 AM, Alex Ghitza <agh...@gmail.com> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Andy,
>
> I had the exact same question a few days ago. There are
> many issues involved here, but the short answer to your
> question (provided by Carl Witty) is:
>
> you can plot x^(1/3) with
>
> show(plot(lambda x : RR(x).nth_root(3), -10, 10), figsize=[5,5],
> ymin=-10, ymax=10)
>
> You don't need to specify xmin and xmax in show since they're
> given in the plot command.
>

Hi,

What would people think of improving the _error_ message to plot
so that it prints some additional helpful information for certain strikingly
common situations? +1 ? -1?

-- William

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Jason Grout

unread,
Feb 22, 2008, 1:24:39 PM2/22/08
to sage-s...@googlegroups.com
Alex Ghitza wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Andy,
>
> I had the exact same question a few days ago. There are
> many issues involved here, but the short answer to your
> question (provided by Carl Witty) is:
>
> you can plot x^(1/3) with
>
> show(plot(lambda x : RR(x).nth_root(3), -10, 10), figsize=[5,5],
> ymin=-10, ymax=10)
>
> You don't need to specify xmin and xmax in show since they're
> given in the plot command.


Good call. I've published a worksheet illustrating this for the next
person to ask it :).

https://www.sagenb.org/home/pub/1702/

Jason

Andy

unread,
Feb 22, 2008, 7:39:59 PM2/22/08
to sage-support
Alex

Thanks for your help. I had searched the group and found the thread
about nth roots, but I wasn't putting it together with the plot
statement correctly.

Thanks also to Jason for publishing an illustration -- good idea. The
published worksheets are a great resource for learning Sage and
working through the subtleties, one which I'll remember to search for
future questions.
> Waterville, ME 04901http://bayes.colby.edu/~ghitza/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
Reply all
Reply to author
Forward
0 new messages