# RevolutionPlot3D: Inconsistency between Mathematica 8/Linux and Mathematica 9/OSX

The following code runs error-free in Mathematica 8.0 under Linux.

ClearAll["Global*"];
x = RandomReal[{0.1, Pi}, 100];
g[t_] := x[[Ceiling[t]]]/Max[x]
RevolutionPlot3D[
{g[t] Sin[t]^2 + 1, t},
{t, 0, 5},                    (* see comment in 'EDIT' regarding the t=0 case *)
{θ, 0, 2 Pi}]


The same exact code produces the following errors when is executed in Mathematica 9.0.1 under Mac OSX (copied by hand):

Part:pspec : Part specification Ceiling[t] is neither a machine-sized integer nor a list of machine-sized integers.>>
General::stop : Further output of Part::pspec will be suppressed during this calculation.>>

EDIT: g yields 0.32669List, but changing the domain to say {1,5} does not fix anything.

Despite the errors an almost original image is produced.

I used an evaluation monitor to check whether g[t] is properly calculated like:

ClearAll["Global*"];
x = RandomReal[{0.1, Pi}, 100];
g[t_] := x[[Ceiling[t]]]/Max[x]
RevolutionPlot3D[
{g[t] Sin[t]^2 + 1, t},
{t, 0, 5},                    (* see comment in 'EDIT' regarding the t=0 case *)
{θ, 0, 2 Pi}, PlotPoints->3,  (* restrict points or else we will get flooded *)
EvaluationMonitor :> Print["t=", t, ", g[t]=", g[t]]]


The output I get is of the form:

... Part::pspec : ...
t[2.5x10^-6, g[t]=0.40655
t[2.5], g[t]=0.811194
...

which looks ok.

Finally, I don't think that my problem has to do with RevolutionPlot3D[] per se, but rather with the way I define and call g[t] in this context.

• The same on Win7, and if you take {g[t] Sin[t]^2 + 1, t,1} to ParametricPlot3D it will produce the same error. – Kuba Aug 23 '13 at 20:36
• Makes some sense @Kuba since RevolutionPlot3D[] is a special case of ParametricPlot3D[] according to the official docs. – stathisk Aug 23 '13 at 20:39

It seems on Win and OSX Mathematica is smuggling something non numerical to g[].

This seems to do the job on Win7:

g[t_?NumberQ] := x[[Ceiling[t]]]/Max@x


PatternTest will help you but I don't know why :)

My first thought was it is lack of Evaluate but it does not seem to be the issue. Also, if Ceiling called directly, there is no error:

RevolutionPlot3D[{Ceiling[t] Sin[t]^2 + 1, t},...


There is also the thing about

g


0.321071 List

what is obvious but changing t domain to {1,5} does not fix anything.

• I confirm @Kuba that with the pattern test it works fine. I will leave the question as it is for now and unless someone explains this behavior I will accept your answer. Thanks! – stathisk Aug 23 '13 at 21:02
• I was using {0.1, ...} in the domain but it didn't make any difference. Thanks for bringing it up though. – stathisk Aug 23 '13 at 21:08
• @Zet I'm glad it helps but I'm curious what's the matter :) – Kuba Aug 23 '13 at 21:09