0

I am new to Mathematica and am taking a course in Complex Analysis. I was wondering how to do the following: Plot in 3D (using Plot3D) the real part of f(x+Iy) and then colouring the corresponding 3D plot using some color scheme so that I can see the Imaginary part of f(x+Iy) by looking at the color. Sorry if this question is very elementary. Thanks in advance!

mtheorylord
  • 197
  • 6
  • 1
    You could use the ColorFunction option of Plot3D. For instance: Plot3D[Re[f[x + I y]], {x, -5, 5}, {y, -5, 5}, ColorFunction -> Function[{x, y}, Im[f[x + I y]]]] – JungHwan Min Sep 05 '16 at 18:46
  • Take a look at this previous answer: http://mathematica.stackexchange.com/a/4273/484 –  Sep 05 '16 at 18:46
  • FYI, I think it's more common to plot the magnitude of $|f|$ along the $z$-axis, and use $\arg(f)$ to determine the color. The color wheel maps nicely onto the $[0, 2\pi)$ range of the $\arg$ function. – Michael Seifert Sep 05 '16 at 18:59
  • I know but for my purposes I would prefer to have it this way. – mtheorylord Sep 05 '16 at 19:11
  • If you want a high-quality output of your colored surface, you should consider reading this QA: http://mathematica.stackexchange.com/q/19110/187 – halirutan Sep 05 '16 at 21:03

1 Answers1

3
f[x_] = x^3;

The min and max of the Im values are

EDIT: Corrected error in calculating {min, max}

{min, max} = #[{ComplexExpand@Im[f[x + I*y]], -3 <= x <= 3, -3 <= y <= 3}, {x,
      y}] & /@ {MinValue, MaxValue}

(* {-54, 54} *)

Legended[ Plot3D[Re[f[x + I*y]], {x, -3, 3}, {y, -3, 3}, AxesLabel -> (Style[#, 14, Bold] & /@ {"x", "y", "Re[f[x+I*y]]"}), ColorFunction -> ( ColorData["TemperatureMap"] [(Im[f[#1 + I*#2]] - min)/(max - min)] &), ColorFunctionScaling -> False], BarLegend[{"TemperatureMap", {min, max}}, LegendLabel -> "Im[f[x+I*y]]"]]

enter image description here

For comparison purposes to verify accuracy of colors

Plot3D[Im[f[x + I*y]],
 {x, -3, 3}, {y, -3, 3},
 AxesLabel -> (Style[#, 14, Bold] & /@
    {"x", "y", "Im[f[x+I*y]]"})]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198