# How to mark visible points on a Plot3D?

I'd like to illustrate a two-variable function discontinuous at zero. The function is $f(x,y)=xy/(x^2+y^2)$ unless $x=y=0$, in which case $f(0,0)=0$. I thought that I could draw a plot and then mark two sequences of points $(x_n,y_n)$ and, say, $(x^\prime_n,y^\prime_n)$ converging to $(0,0)$ such that $f(x_n,y_n)$ and $f(x^\prime_n,y^\prime_n)$ converge to different limits. I did something like this:

f[x_, y_] := If[x == y == 0, 0, x*y/(x^2 + y^2)]
p := Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}]
Show[p, ListPointPlot3D[
Thread[{Table[1/n, {n, 5}], Table[1/n, {n, 5}],
Table[f[1/n, 1/n], {n, 5}]}]]]


but the dots are barely visible; I'd like to have them bigger and/or blacker. How to achieve this?

-
And where do I put this? –  mbork Aug 28 '12 at 22:24

Nasser's suggestion in comments is correct. You need to provide a non-default style to the points in the ListPointPlot3D. I would also suggest giving p a style that allows one to see through the surface to the points partly on the other side of the surface, using Opacity. And incidentally, there's no particular reason to use SetDelayed (:=) rather than Set (=) when defining p. You can suppress output with a semicolon. If you use SetDelayed, you are recalculating the graphic when you evaluate the Show expression, which is a waste of processor cycles.

f[x_, y_] := If[x == y == 0, 0, x*y/(x^2 + y^2)]

p = Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1},
PlotStyle -> Opacity[0.5]] ;

Show[p, ListPointPlot3D[
Thread[{Table[1/n, {n, 5}], Table[1/n, {n, 5}],
Table[f[1/n, 1/n], {n, 5}]}], PlotStyle -> PointSize[.05]]]


As you can see, options are placed at the end of a function list. This tutorial is about writing your own functions to take options and optional arguments, but it helps explain how options work. The Mathematica documentation for each function (including ListPointPlot3D) goes through the options it can take and provides examples.

-
Thanks, I had no idea about the difference between = and := (in fact, I feel quite lost in the documentation of Mathematica; also it seems so much different from anything I know that I ask here even for "simple" things...) –  mbork Aug 28 '12 at 22:41
You're welcome - the Mathematica learning curve is steep, so it is understandable. Anyway, seeing the occasional "easy" question we can answer over our morning coffee (I am in Australia) is actually quite good. –  Verbeia Aug 28 '12 at 22:48
Thanks again. Actually, I have nothing against steep learning curves as such (I've been programming in TeX since high school, for example, and four years ago I defended a PhD in maths;)), but I couldn't find on the 'net any, say, 60-120-minutes tutorial giving me the basics. So my Mathematica coding is a bit of cargo cult programming: I just copy-paste fragments of official docs or code found here... (And my thinking, OTOH, is getting worse as I'm approaching 1.00 am here in Poland...) –  mbork Aug 28 '12 at 22:53
@mbork have you seen Leonid Shifrin's book? –  Verbeia Aug 28 '12 at 22:56
Are you suggesting Leonid's book is commutative? –  belisarius Aug 29 '12 at 0:24

An alternative to Verbeia's answer is to use Sphere[] primitives to depict the points, as in the following:

f[x_, y_] := If[x == y == 0, 0, x y/(x^2 + y^2)];

Show[Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}],
Graphics3D[{Darker[Blue], Sphere[Table[{1/n, 1/n, f[1/n, 1/n]}, {n, 5}], 1/15]}],
PlotRange -> All]


This is a bit beyond your actual question, but let me just note that the surface you're considering is one of those surfaces that look better in cylindrical coordinates than in rectangular coordinates. Witness the following:

Show[ParametricPlot3D[{r Cos[θ], r Sin[θ], Cos[θ] Sin[θ]}, {r, 0, Sqrt[2]}, {θ, -π, π}],
Graphics3D[{Darker[Blue], Sphere[Table[{1/n, 1/n, f[1/n, 1/n]}, {n, 5}], 1/15]}],
PlotRange -> All]


-