Bug introduced in 11.0.0 and fixed in 11.0.1

I've just installed version 11 of Mathematica and have encountered a bug (which a colleague has reported to WRI). It relates to the seemingly incorrect evaluation of arguments to (at least) the LogLogPlot command.

The following code:

y = 10^(-11) x^2.9;
LogLogPlot[y, {x, 1, 10}]

does not produce a straight line on the graph but rather a curve, viz:

Erroneous LogLog curve plot

The above should appear as a straight line as it is a power curve. If you add an Evaluate around y it will produce the correct straight line, i.e.

Correct plot

The correct plot will also be produced by any of these commands:

f[x_, {a_, b_}] := a x^b
LogLogPlot[f[x, {10^(-11), 2.9}], {x, 1, 10}]


y = 10^(-11) x^2.9
LogLogPlot[y /. x -> z, {z, 1, 10}]

So here are the questions:

  1. Has anyone else observed these behaviours?
  2. Are they in fact bugs or are they some subtle (counterintuitive?) behaviour of Mathematica that I and none of my colleagues who use Mathematica are aware of?

Note once more, this behaviour has been reported to WRI so please don't ask.

  • 1
    $\begingroup$ It looks like a bug to me so I added the tag. But at least this was fixed in version 11. $\endgroup$ – Szabolcs Aug 15 '16 at 11:38
  • $\begingroup$ Simple workaround is LogLogPlot[Evaluate[y], ...] $\endgroup$ – Szabolcs Aug 15 '16 at 11:38
  • $\begingroup$ Can you separate these two unrelated problems into two posts? I am going to remove the observations about Table. Please create a new post for those. $\endgroup$ – Szabolcs Aug 15 '16 at 11:39
  • $\begingroup$ @Szabolcs, (1) it is a new bug in version 11 and (2) I noted that evaluate is a valid workaround. Thanks for adding the bug label. $\endgroup$ – Bruce Crawford Aug 15 '16 at 11:40
  • 1
    $\begingroup$ N.B. since you've mentioned that you've made WRI aware of this behavior in the body, there's no need to put it in the title. Also: the Table[] stuff and LogLogPlot[] stuff seem to me disjoint topics; might be a good idea to split. $\endgroup$ – J. M.'s ennui Aug 15 '16 at 11:40

This bug has been fixed in the just released Mathematica 11.0.1.

enter image description here

  • $\begingroup$ How is buy an upgrade an acceptable answer? $\endgroup$ – Ivan Jul 9 '18 at 19:38

I think this is a bug. This is just a long comment on what I think is happening here.

First of all, LogPlot, LogLogPlot, etc. have indeed changed significantly in version 11. This long standing bug is fixed now. Plot now has the ScalingFunctions option, and Plot[..., ScalingFunctions -> {"Log", "Log"}] appears to behave exactly the same as LogLogPlot, including this bug.

What is happening?

Normally Plot[expr, {x,...}] behaves by temporarily setting a value to x (like Block), and then evaluating expr. It seems that this is not true anymore in version 11. Now we have a mix of setting a value to x (Block) and replacing x (Replace).

When running

u = x^2;
LogLogPlot[u, {x, 1, 10}]

the replacement step fails as u does not explicitly contain x. However, when u is later evaluated, then the temporarily set OwnValue of x is picked up.

What evidence do I have for this?

We can use EvaluationMonitor to test what is happening. But we must do so carefully because it turns out that the replacement step is done on the contents of the EvaluationMonitor option as well.

Test 1:

LogLogPlot[u, {x, 1, 10}, EvaluationMonitor :> Print[Hold[x]], 
 MaxRecursion -> 0]

This prints Hold[Exp[x]]. This is evidence for the replacement.

Test 2:

f[] := OwnValues[x]
LogLogPlot[u, {x, 1, 10}, EvaluationMonitor :> Print[f[]], 
 MaxRecursion -> 0]

This prints from {HoldPattern[x]:>4.69915*10^-8} to {HoldPattern[x]:>2.30259}, which are Log[1] to Log[10]. This is evidence for setting a temporary OwnValue for x. I used f[] to prevent the replacement.

Test 3:

We can see the combined effect of these like so:

LogLogPlot[u, {x, 1, 10}, EvaluationMonitor :> Print[x], 
 MaxRecursion -> 0]

This prints values from 1 to 10. This is achieved by first replacing x by Exp[x], then evaluating it with values from x=1 to x=10.

Test 4:


u = x^2;
LogLogPlot[u, {x, 1, 10}]

is really equivalent to

LogLogPlot[Log[x]^2, {x, 1, 10}]

since x is really set values not from 1 to 10 but from Log[1] to Log[10].

Evaluating these two commands gives the same plot.

Is this a bug?

My personal opinion is that this is confusing enough that I would call it a bug. However, I do expect that some will disagree. Generally, masking the variable of an expression in Plot can lead to strange effect in various ways.

The following is a clearer and less error prone way to do the same thing:

u[x_] := x^2
LogLogPlot[u[x], {x, 1, 10}]
  • $\begingroup$ Thanks. It will take me a while to digest this but I'm sure my more experienced Mathematica using colleagues will find it immediately useful. $\endgroup$ – Bruce Crawford Aug 15 '16 at 12:15
  • $\begingroup$ @BruceCrawford Sorry, I don't think I can say anything useful other than what you already said (use Evaluate). I was just trying to shed some light on how things go wrong. A bug is just a bug ... there's not much we can do other than look for workarounds. $\endgroup$ – Szabolcs Aug 15 '16 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.