easy question

1 view
Skip to first unread message

Dana Ernst

unread,
Feb 8, 2010, 8:47:03 AM2/8/10
to sage...@googlegroups.com
Forgive my ignorance and for asking such a silly question...

Today in Calc II, I'm introducing the natural log as an integral.  I'd like to show the graph of y=1/t from say 0 to 8 and have the area under the graph shaded from say 1/2 to 1.  Doing the following seemed natural to me:

plot(1/t,.1,8)+plot(1/t,1/2,1,fill=true).show()

However, this doesn't work.  (Of course, I declared t as a variable earlier.)  I'm sure I could figure this out, but I teach in an hour and I'm sure someone here could quickly tell me:)

Also, if someone wouldn't mind telling when to use ".show" that would be great.


Dana Ernst, Ph.D.
Assistant Professor
Department of Mathematics
Plymouth State University
MSC 29, 17 High Street
Plymouth, NH 03264-1595

Email: dce...@plymouth.edu
Web Page: http://oz.plymouth.edu/~dcernst
Office: Hyde 312

Rob Beezer

unread,
Feb 8, 2010, 8:52:22 AM2/8/10
to sage-edu
I haven't checked, but try grouping the plots together,

(plot(1/t,.1,8)+plot(1/t,1/2,1,fill=true)).show()

Rob

> Email: dcer...@plymouth.edu

jason...@creativetrax.com

unread,
Feb 8, 2010, 8:53:51 AM2/8/10
to sage...@googlegroups.com
Dana Ernst wrote:
> Forgive my ignorance and for asking such a silly question...
>
> Today in Calc II, I'm introducing the natural log as an integral. I'd like to show the graph of y=1/t from say 0 to 8 and have the area under the graph shaded from say 1/2 to 1. Doing the following seemed natural to me:
>
> plot(1/t,.1,8)+plot(1/t,1/2,1,fill=true).show()
>
> However, this doesn't work. (Of course, I declared t as a variable earlier.) I'm sure I could figure this out, but I teach in an hour and I'm sure someone here could quickly tell me:)
>
> Also, if someone wouldn't mind telling when to use ".show" that would be great.
>
>

var('t')
plot(1/t,(t,.1,8))+plot(1/t,(t,1/2,1),fill=True,ymin=0)

(sorry; I'd explain more, but I have to run)

Thanks,

Jason


Dana Ernst

unread,
Feb 8, 2010, 9:22:33 AM2/8/10
to sage...@googlegroups.com
 I'd like to show the graph of y=1/t from say 0 to 8 and have the area under the graph shaded from say 1/2 to 1.  Doing the following seemed natural to me:

plot(1/t,.1,8)+plot(1/t,1/2,1,fill=true).show()

However, this doesn't work.  (Of course, I declared t as a variable earlier.)  I'm sure I could figure this out, but I teach in an hour and I'm sure someone here could quickly tell me:)

Also, if someone wouldn't mind telling when to use ".show" that would be great.

 

var('t')
plot(1/t,(t,.1,8))+plot(1/t,(t,1/2,1),fill=True,ymin=0)

Awesome, that works (and so does Rob's suggestion).  What is ymin=0 doing in this context?  I'm guessing that in the context of what I'm trying to do, I don't need it.  Also, is "var('t')" redundant if you include t in (t,.1,8) for example?

Dana

kcrisman

unread,
Feb 8, 2010, 10:32:00 AM2/8/10
to sage-edu

I think he is doing it from scratch, so you need to declare 't' at
that point.

The ymin=0 could be necessary if your original function didn't get
close enough to the x-axis for the axes to actually cross.

Finally, plot passes all options (like fill) to show() if you just
type plot(stuff), as opposed to P=plot(stuff), which doesn't
automatically show it. So since you only needed the fill for the
second thing, putting that option directly in "its" plot did what you
wanted. The original thing threw an error because you tried to add a
plot object and a "show", which are not the same type of object.

Incidentally, Dana, I encourage you to put future questions of this
sort on sage-support, where more people will benefit from them! This
list is primarily for discussing more abstract educational issues, but
on sage-support many people can learn about basic syntax issues like
this. But thanks for asking, either way :)

- kcrisman

Reply all
Reply to author
Forward
0 new messages