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: [mg43186] Re: Can plot take limits? Or something like it ...
  • From: Bill Rowe <listuser at earthlink.net>
  • Date: Sun, 17 Aug 2003 04:27:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 8/16/03 at 2:53 AM, mathieu_mcphie at yahoo.com.au (Mathieu McPhie) wrote:

> 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.

<snip>

> Please explain,

The problem is undoubtedly related to Mathematica's adaptive sampling algorithm. With Plot, it must be the case that the adaptive sampling alogorithm is not sampling at x = 0. In the neighborhood of x = 0, the function Sin[x]/x is nearly constant. So, there would be nothing to cause Mathematica's adaptive sampling algorighm to sample the function at many points in this neighborhood. And since the Plot routine simply joins adjacent points with line segments, this will appear to smoothly go to 1 as x approaches zero.

With Plot3D, Mathematica is clearly sampling at x = 0 and complaining the function is singular. Niether Plot nor Plot3D do any sophisticated analysis of functions. The simply compute the function values at the sampled points and join them as appropriate with line segments etc. Consequently, neither Plot nor Plot3D reconize Sin[x]/x to be 1 at x = 0.

To get around this, you need to redefine the function so that it always returns a machine precision number no matter what input it is given. That is you need to explicitly tell Plot3D that Sin[x]/x is 1 at x = 0. Also, you may need to do something about the precision to which this is computed near x = 0 so that the result of Sin[x]/x is still a machine precision number.


  • Prev by Date: Merging objects before tumbling animation
  • Next by Date: Re: Mathematica does this integral wrong?
  • Previous by thread: Re: Can plot take limits? Or something like it ...
  • Next by thread: RE: Can plot take limits? Or something like it ...