MATLAB: Function that should be continuous isn’t continuously plotted

analysisMATLABplotting

Given the function: f(x,y) = (x^3 – 3*x*y^2)/(x^2+y^2)
I'd plot it typing:
[x,y] = meshgrid(-2:0.2:2)
z = (x.^3 - 3.*x.*y.^2)./(x.^2+y.^2)
surf(x,y,z)
Doing this Matlab shows me a quite dedicate plot, however with a whole in the origin (A sign for non continous functions, right?). That's why this is staying in contrast to my math lectures. Maybe it's because I haven't defined "f(x,y) = 0 if (x,y) = (0,0)". Or why is that?

Best Answer

The function is continuous at (0,0); it has a removable singularity. Try using
[x,y] = meshgrid(-2+eps:0.2:2+eps);
eps is Matlab's inbuilt value (about 2.2204e-16).
Related Question