MathGroup Archive 2011

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

Search the Archive

Re: Mathematica LogPlot Bug

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123758] Re: Mathematica LogPlot Bug
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 17 Dec 2011 02:48:57 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 12/16/11 at 5:47 AM, ant.piniz at gmail.com (AntonioP) wrote:

>I have to draw some functions in log scale, but LogPlot seems not to
>be able to draw them correctly if the y-value is too small. A simple
>case:

>f[x_] = 10^(-5 x) LogPlot[f[x], {x, 1, 100}, PlotRange -> Full]

>the plot should be a simple straight line for any x value, while at
>about x=61.5 there is a step and, for any greater value of x, the
>function appears to be constant. Nevertheless, Mathematica is able
>to compute the correct value of f[x] for any x:

>N[f[60]] N[f[65]] N[f[80]] N[f[100]]

>N[f[60]]
>N[f[65]]
>N[f[80]]
>N[f[100]]

>There is a similar problem for large y-values, as well. Apparently
>there is a y-range, about (10^-308, 10^308), outside which LogPlot
>doesn't work correctly.

Specifically, the range over which you can get the plots to work
as you expect is given by

{$MinMachineNumber,$MaxMachineNumber)

To understand what is going on here, you have to understand the
difference between machine precision arithmetic done by hardware
and exact arithmetic done by Mathematica.

Since you have defined f with exact values, Mathematica can
compute f exactly when supplied with exact values. So, when you do

N[f[100]]

Mathematica computes f[100] exactly, then converts it to an
approximate value using the arbitrary precision arithmetic
technology built in to Mathematica.

Note the difference between:

In[19]:= Precision[N[f[10]]]

Out[19]= MachinePrecision

and

In[20]:= Precision[N[f[100]]]

Out[20]= 15.9546

The first gives a machine precision value since f[10] is within
the range of $MinMachineNumber and $MaxMachineNumber

The second uses Mathematica's arbitrary precision arithmetic to
give you a value with equivalent precision to a machine
precision number but does not return a machine number since
f[100] lies outside the range for machine numbers.

Now getting back to your problem. Plot and its kin use machine
numbers to evaluate functions. This is done since that allows
your FPU to be used rendering the plot much faster than could be
done any other way. The break you see in the plot happens when
you reach the limit of what can be represented as a machine
number. This is not a bug. It is simply a limitation of hardware
and the choice of using hardware to do the computations.

>Any idea on how to resolve the problem?

If I had to, I could create a plot without the break shown. But
why? Why do you need to plot such large or small values?




  • Prev by Date: Re: Mathematica LogPlot Bug
  • Next by Date: Re: Elementary Document Formatting Questions
  • Previous by thread: Re: Mathematica LogPlot Bug
  • Next by thread: Re: Mathematica LogPlot Bug