What are the possible ways of visualizing a 4D function in Mathematica?

One possible way is to use Graphics3D with Point and color points by function value so it's like density plot 3d. For example,

xyz = Flatten[
         Table[{i, j, k}, {i, 1, 10, .35}, {j, 1, 10, .35}, {k, 1, 
          10, .35}], 2];

f[x_, y_, z_] := x^2 y Cos[z]

Graphics3D[
       Point[xyz, VertexColors -> (Hue /@ Rescale[f[##] & @@@ xyz])], 
 Axes -> True, AxesLabel -> {x, y, z}]

enter image description here

Another possible choice is just thinking one parameter as time variable and use Manipulate:

Manipulate[Plot3D[f[x, y, z], {x, 1, 10}, {y, 1, 10}], {z, 1, 10}]

enter image description here

There should be many other way to visualize 4d data, but it's really depending on what you want to see and how you want to visualize.

Like amr suggested, you can also use Image3D or Raster3D:

values = Rescale[
    Table[f[i, j, k], {i, 1, 10, .2}, {j, 1, 10, .2}, {k, 1, 10, .2}]];

Graphics3D[Raster3D[values, ColorFunction -> Hue]]

enter image description here

Image3D[values, ColorFunction -> Hue]

enter image description here

Image3D[values]

enter image description here


A typical way of visualizing functions of the form $f(x,y,z)$ is in terms of level sets. One uses ContourPlot3D in Mathematica. Here I show it in conjunction with the function's gradient field, which may be omitted.

Manipulate[
 Show[
   ContourPlot3D[f == c, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
    ContourStyle -> Opacity[0.5]],
   ControlActive[{}, VectorPlot3D[Evaluate[D[f, {{x, y, z}}]], {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]]
  ],
 {{f, x^2 + x y z + z^4}, InputField},
 {{c, 0.1}, -0.25, 5, Appearance -> "Labeled"}]

output

You mention in a comment visualizing error. I wasn't sure exactly what you were after, but you can plot contours plus or minus a given error in the value of f fairly easily.

Manipulate[
 Show[
  ContourPlot3D[f, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
   Contours -> c + {-dc, 0, dc}, 
   ContourStyle -> {Directive[Opacity[0.3], Red], Opacity[0.3], 
     Directive[Opacity[0.3], Blue]}, Mesh -> None],
  ControlActive[{}, VectorPlot3D[Evaluate[D[f, {{x, y, z}}]], {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]]
  ],
 {{f, x^2 + x y z + z^4}, InputField},
 {{c, 0.6}, -0.25, 5, Appearance -> "Labeled"},
 {{dc, 0.5}, 0, 1., Appearance -> "Labeled"}]

output


As of version 10.2 one can use DensityPlot3D:

DensityPlot3D[x^2 y Cos[z], {x, 1, 10}, {y, 1, 10}, {z, 1, 10}, 
  ColorFunction -> "Rainbow", AxesLabel -> {x, y, z}]

enter image description here

The transparent regions can be set manually and will be indicated on the left side of the bar legend:

of[f_] := Max[.02, Abs[2f - 1]^1.5]

DensityPlot3D[x^2 y Cos[z], {x, 1, 10}, {y, 1, 10}, {z, 1, 10}, 
  ColorFunction -> "Rainbow", AxesLabel -> {x, y, z},
  OpacityFunction -> of, PlotLegends -> Automatic]

enter image description here