3

Unless I'm missing something very obvious, why does this code:

Plot3D[r^(-2) + 1000*r^2 + 10*Cos[x],{r,0.01,0.5},{x,0,20*Pi},PlotRange->{0,200}]

generate this plot: enter image description here

Why is it not a smooth plot?

(Mathematica version 10.1.0.0, Linux x86-64.)

Zorawar
  • 235
  • 1
  • 6
  • 1
    Both Mathematica 10.4 and 11.0 on OS X yield a smooth surface – Sascha Aug 23 '16 at 11:35
  • If all else fails I'll try upgrading, but is there a mathematica option to ask it to smooth this out. – Zorawar Aug 23 '16 at 11:39
  • 1
    Look at the options PlotPoints and MaxRecursion – Michael E2 Aug 23 '16 at 11:40
  • 1
    Have you tried this with a fresh kernel? – Sascha Aug 23 '16 at 11:40
  • 2
    try PlotPoints -> 100 or MaxRecursion -> 10 – vito Aug 23 '16 at 11:41
  • 2
    I think you mistyped the function in your code. I can reproduce your image with Cos[10 * x]: http://i.stack.imgur.com/uu6aM.png -- Try adding the option PlotPoints -> {25, 75} – Michael E2 Aug 23 '16 at 11:57
  • @Sascha: really? My friends 10.4 version on windows reproduces my error. And yes, problem persists on a new kernel (unfortunately). Even on a different machine I have (which runs version 10.0 I think). – Zorawar Aug 23 '16 at 13:15
  • @MichaelE2: Ah thanks. They seem to smooth it out. PlotPoints seems less intensive than MaxRecursion. And yes I did have a typo. Thanks! I should have had the range of x to be [0,20pi] but effectively the same thing. Thanks! – Zorawar Aug 23 '16 at 13:17
  • @vito: Thanks! I get a smooth plot as I expect with those options added. Thanks again! – Zorawar Aug 23 '16 at 13:20
  • Yes, MaxRecursion helps with local smoothing, but when it's needed everywhere, it can be expensive. OTOH, when it's needed in a small area, it will be more efficient than increasing PlotPoints. – Michael E2 Aug 23 '16 at 13:35
  • @MichaelE2: The documentation on MaxRecursion especially is a little sparse. If you'd like to flesh out what you said here into an answer it would be interesting to me and might be useful for others... (if you have the time :) – Zorawar Aug 23 '16 at 13:45
  • @Zorawar There's some explanation here: (19121), (29346). Also somewhat related: (82912) – Michael E2 Aug 23 '16 at 13:51
  • @MichaelE2: Ah, those look very interesting. Thanks! – Zorawar Aug 23 '16 at 13:57
  • @Zorawar Try this, Plot3D[1/r^2 + 1000 r^2 + 10 Cos[x], {r, 0.01, 0.5}, {x, 0, Pi}, PlotRange -> {0, 200}] – Bob Brooks Aug 23 '16 at 18:32

0 Answers0