# Mysterious spikes in Plot3D

I am using Mathematica 9 and get these strange spikes when I plot the following simple function. I have seen a previous post about this but cannot figure out what is wrong with the following code. Does anyone know how to get rid of them? Any help would be much appreciated.

f[q_, L_] := If[q < 1/(1 + L^0.5), 10*q]

Plot3D[f[q, L], {q, 0, 1}, {L, 0, 5}, BoxRatios -> 1, Mesh -> None,
AxesLabel -> {"q", "L", "Price"},
PlotStyle -> Directive[Opacity[0.6], Blue]] • Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Feb 19 '15 at 3:44

I don't know why it looks like that. However:

It looks like you are trying to restrict the plot region and you do this by defining the function to return Null in other areas. This is not the usual way to do it.

Use RegionFunction instead.

Plot3D[10*q, {q, 0, 1}, {L, 0, 5}, BoxRatios -> 1, Mesh -> None,
AxesLabel -> {"q", "L", "Price"},
PlotStyle -> Directive[Opacity[0.6], Blue],
RegionFunction -> Function[{q, L}, q < 1/(1 + L^0.5)]] 