LogLogPlot encounters Infinite expression

38 views
Skip to first unread message

John_V

unread,
Apr 21, 2012, 12:33:51 AM4/21/12
to
If I try this:

f[x_] = Piecewise[{{0, x < 10}}, Exp[x/20]]
LogLogPlot[1/f[x], {x, 11, 20}]

the result is an error message (Infinite expression 1/0 encountered) and a
plot that has axes but no graph.

Notice that although 1/f is indeed 1/0 for x<10, the requested plot range
does not include x<10. The function is well-defined within the requested
plot range. Does anyone know what's going on with this?

John

Dr. Wolfgang Hintze

unread,
Apr 22, 2012, 6:09:29 AM4/22/12
to
P
If I prepend the command

In[1]:=
<< "Graphics`Graphics`"

everything works out fine in version 5.2

Regards,
Wolfgang


djmpark

unread,
Apr 22, 2012, 6:06:56 AM4/22/12
to
This looks like a bug in the internal initial processing for LogLogPlot,
possibly in trying to determine the y axis Range - although I don't know why
it would do that first.

If one does the following, the routine never samples outside of the
specified domain.

f[x_] := Piecewise[{{0.001, x < 10}}, Exp[x/20]]
Reap[LogLogPlot[1/f[x], {x, 11, 20},
EvaluationMonitor :> Sow[x]]]

If we change back to zero, it bombs before sowing any x values.

The simplest solution is to modify the plot function for the purpose of this
particular plot.

LogLogPlot[1/Exp[x/20], {x, 11, 20}]

With the Presentations Application you could specify the ticks and roll your
own LogLog curve with some extra work but without having to modify the f
function.

<< Presentations`

xticks = CustomTicks[Log, {1, 2, {12, 14, 16, 18, 20}/10, {}}];
yticks = CustomTicks[Log, {-1, 0, Range[3.5, 6, 0.5], {}}];
Draw2D[
{Draw[Log[1/f[E^logx]], {logx, Log[11], Log[20]}]},
AspectRatio -> 0.6,
Axes -> True,
Ticks -> {xticks, yticks}]


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/index.html
Reply all
Reply to author
Forward
0 new messages