MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Can plot take limits? Or something like it ...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43183] RE: [mg43169] Can plot take limits? Or something like it ...
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 17 Aug 2003 04:27:53 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Mathieu,

It's because of the different way Mathematica selects the plot points in the
two plots.

plot1 = Plot[Sin[x]/x, {x, 0, 1}];

With Plot, Mathematica uses an adaptive algorithm to pick the points and it
never seems to use the exact endpoints. You can use

First[plot1]

to see the actual Line and points that Mathematica used (I omitted the
output from my posting). If we examine more closely the first and last
points we obtain...

Part[plot1, 1, 1, 1, 1] // First // InputForm
{4.166666666666666*^-8, 0.9999999999999998}

Part[plot1, 1, 1, 1, 1] // Last // InputForm
{0.9999999583333333, 0.8414709973565913}

and you can see that Mathematica never used 0 and 1. Since it never used 0,
it didn't get into any problem.

But with...

Plot3D[y*Sin[x]/x, {x, 0, 1}, {y, 0, 1}]

Mathematica does not use an adaptive algorithm but makes an exact two
dimensional grid that goes from 0 to 1 in each direction. Therefore it does
not avoid the zero x values on one side of the grid and generates all of the
error messages. You could suppress the error messages by turning them off
with Off (but there are so many different ones that it doesn't seem worth
it), or you could use the following statement.

Plot3D[y*Sin[x]/x, {x, 10*^-8, 1}, {y, 0, 1}]

and explicitly avoid the zero values.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/




From: Mathieu McPhie [mailto:mathieu_mcphie at yahoo.com.au]
To: mathgroup at smc.vnet.net

Hello friendly helpers and knowledgable personages,

I'm sure this is a problem encountered (and answered) before. And it
is just one of the many I have encountered with this drat perverse
progam. Anyway ...

The following two commands (this is an extremely cut down version of
my problem so try and be general)

Plot[Sin[x]/x, {x, 0, 1}]
Plot3D[y*Sin[x]/x, {x, 0, 1}, {y, 0, 1}]

The first works perfectly, correctly going toward the limit at x=0 of
1.

For the second I get ...

Power::infy : Infinite expression 1/0. encountered.

\[Infinity]::indet : Indeterminate expression 0. ComplexInfinity
encountered.

Plot3D::plnc: y*Sin[x]/x is neither a machine-size real number at
{x,y}={0., 0.} nor a list of a real number and a valid color
directive.

Please explain, Vielin Dank, Mathieu McPhie


  • Prev by Date: Re: Mathematica does this integral wrong?
  • Next by Date: Random Number Generation : Is there a faster way of doing this ?
  • Previous by thread: Re: Can plot take limits? Or something like it ...
  • Next by thread: Re: Can plot take limits? Or something like it ...