# Using VectorPlot3D gives me the following error: “Value of option PlotPoints -> {} is not an integer >= 2”

f[x, y] := {1 - ((20 - x)/20)^y}
scalarField = (1 - ((20 - x)/20)^y) - z       (*This is the same as f[x, y] - z, used later*)
vectorField = D[scalarField,  {{x, y, z}}]

In:= v = VectorPlot3D[vectorField, {x, 0.001, 10}, {y, 0.001, 5}, {z, 0, 1},
RegionFunction -> Function[{x, y, z}, TrueQ[f[x, y] == z]],
VectorPoints -> Automatic]


I get the following error:

VectorPlot3D::ppts: Value of option PlotPoints -> {} is not an integer >= 2.


I'm VERY new to Mathematica and the documentation doesn't really help me understand what I'm doing wrong.

What I want to happen is that I get only the vectors on the surface of f[x, y], so the documentation says I should be using the RegionFunction property. The Region function property was giving me even MORE errors before I wrapped it in TrueQ (it was claiming f[x,y] == z wasn't boolean).

What am I doing wrong?

• function f[x, y] should be f[x_, y_], but the problem is that TrueQ[f[x, y] == z] is always false. Hence there is no region to plot. It like writing RegionFunction -> Function[{x, y, z}, False] – Nasser Apr 8 '20 at 0:24
• @Nasser Why is f[x, y] == z always False? There are values (x, y, z) for which TrueQ[f[x,y] == z] is True. For example: TrueQ[f[3, 3] == {3087/8000}] – Axoren Apr 8 '20 at 0:26
• It's really not a good error message, is it? – Michael E2 Apr 8 '20 at 2:09

Another way to get the desired sampling:

ClearAll[f];
f[x_, y_] := {1 - ((20 - x)/20)^y}
scalarField = (1 - ((20 - x)/20)^y) - z;
vectorField = D[scalarField, {{x, y, z}}];

r = Plot3D[f[x, y], {x, 0.001, 10}, {y, 0.001, 5}, Mesh -> None,
MaxRecursion -> 0, PlotPoints -> 9, NormalsFunction -> None];

v = VectorPlot3D[
vectorField, {x, 0.001, 10}, {y, 0.001, 5}, {z, 0, 1},
VectorPoints ->
Cases[r, {_Real, _Real, z_Real}, Infinity],
VectorScaling -> Automatic] • A more direct way to get sampling: r = Flatten[ Outer[Flatten@{##, f@##} &, Subdivide[0.001, 10, 8], Subdivide[0.001, 5, 8]], 1]. The inner Flatten would be unnecessary if f[x, y] returned a scalar instead of a 1-vector. But Plot3D[] will automatically handle singularities and holes in the domain of f[]. – Michael E2 Apr 8 '20 at 12:41
 Why is f[x, y] == z always False?


The numbers are not exact. You could add tolerance. Without it, RegionFunction returns False, there was no case where TrueQ[f[x, y] == z] returned True.

scalarField = (1 - ((20 - x)/20)^y) -
z       (*This is the same as f[x,y]-z,used later*)
vectorField = D[scalarField, {{x, y, z}}]
f[x_, y_] := 1 - ((20 - x)/20)^y
epsilon = 0.1;
VectorPlot3D[vectorField, {x, 0.001, 10}, {y, 0.001, 5}, {z, 0, 1},
RegionFunction -> Function[{x, y, z}, Abs[f[x, y] - z] < epsilon],
VectorPoints -> Automatic] You could also make your VectorPoints -> Fine instead of automatic. But the whole reason for the error you are getting is that TrueQ[f[x, y] == z] returns False for all the sampling used as is.

For example

epsilon = 0.01;
VectorPlot3D[vectorField, {x, 0.001, 10}, {y, 0.001, 5}, {z, 0, 1},
RegionFunction -> Function[{x, y, z}, TrueQ[Abs[f[x, y] - z] < epsilon ]],
VectorPoints -> 30]


Returns 