0
$\begingroup$

This question already has an answer here:

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!

$\endgroup$

marked as duplicate by J. M. is away Oct 3 '16 at 15:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ 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]]]] $\endgroup$ – JungHwan Min Sep 5 '16 at 18:46
  • $\begingroup$ Take a look at this previous answer: mathematica.stackexchange.com/a/4273/484 $\endgroup$ – Rahul Sep 5 '16 at 18:46
  • $\begingroup$ 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. $\endgroup$ – Michael Seifert Sep 5 '16 at 18:59
  • $\begingroup$ I know but for my purposes I would prefer to have it this way. $\endgroup$ – mtheorylord Sep 5 '16 at 19:11
  • $\begingroup$ If you want a high-quality output of your colored surface, you should consider reading this QA: mathematica.stackexchange.com/q/19110/187 $\endgroup$ – halirutan Sep 5 '16 at 21:03
1
$\begingroup$
f[x_] = x^3;

The min and max of the Im values are

{min, max} = #[
     {Im[x + I*y], -3 <= x <= 3, -3 <= y <= 3},
     {x, y}][[1]] & /@ {Minimize, Maximize}

(*  {-3, 3}  *)

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

$\endgroup$
  • $\begingroup$ Thanks very much. Turned out to be less elementary than I thought. $\endgroup$ – mtheorylord Sep 6 '16 at 0:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.