Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7315 > unrolled thread

Re: Mathematica LogPlot Bug

Started byBill Rowe <readnews@sbcglobal.net>
First post2011-12-17 07:54 +0000
Last post2011-12-17 07:54 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Mathematica LogPlot Bug Bill Rowe <readnews@sbcglobal.net> - 2011-12-17 07:54 +0000

#7315 — Re: Mathematica LogPlot Bug

FromBill Rowe <readnews@sbcglobal.net>
Date2011-12-17 07:54 +0000
SubjectRe: Mathematica LogPlot Bug
Message-ID<jchhr5$ilo$1@smc.vnet.net>
On 12/16/11 at 5:47 AM, ant.piniz@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?

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web