[Date Index]
[Thread Index]
[Author Index]
Controlling evaluation or Re: Plot[] acting funny (help)
*To*: mathgroup at yoda.ncsa.uiuc.edu
*Subject*: Controlling evaluation or Re: Plot[] acting funny (help)
*From*: jacobson at cello.hpl.hp.com
*Date*: Wed, 23 Jan 91 09:49:09 PST
antonyc at tybalt.caltech.edu (Bill T. Cat) asks about the following plot
Plot[NIntegrate[((Sin[t x])^2),{x,0,Pi}],{t,0,10}]
I think the problem was confusion caused by Mathematica drawing the x
axis at y=1. Adding PlotRange->All makes it look as expected.
Now for my question: I observed that this integral can easily be done
analytically. So I tried plotting
Plot[Release[Integrate[((Sin[t x])^2),{x,0,Pi}]],{t,0,10},
PlotRange->All]
and this works just fine, and a lot faster, but gives a bunch of error
messages, since Integrate[((Sin[t x])^2),{x,0,Pi}] evaluates to
Pi Cos[Pi t] Sin[Pi t]
-- - -------------------
2 2 t
so there is a division by zero at t=0. But there is also a Sin[Pi t]
in the numerator, so the limit as t->0 is well defined. Now what I'd
like to do is, in a one-liner, make it do the integral and wrap a
limit around it, something like
Plot[Release[Limit[Integrate[((Sin[tt x])^2),{x,0,Pi}]],tt->t],{t,0,10},
PlotRange->All]
but this doesn't quite work, as it takes the limit too soon and I
still get the division by zero. I want Plot to see on each
iteratation
Limit[Pi/2 - (Cos[Pi*tt]*Sin[Pi*tt])/(2*tt),tt-> <<current value of t>>]
Any ideas about how to do this?
(No replies please about Limit being slow, or about using Off[], etc.
This is a question about controlling evaluation.)
-- David Jacobson
Prev by Date:
**RE: Generating a normal 0,1**
Next by Date:
**Help with Programming Mathematica**
Previous by thread:
**RE: Generating a normal 0,1**
Next by thread:
**Help with Programming Mathematica**
| |