How do I plot the differential of this function?

Suppose I have this function:

z(x,y)=|13x+iy−2xiy+1x|z(x,y) = \left| \frac{ \frac{1}{3x +iy} -2x}{iy + \frac{1}{x}} \right|

I want the contour plot of ∂z∂x\frac{\partial z}{\partial x} with axes (x,y)(x,y). Tried this code, but didn’t work.

z = Abs[ ( (1/3 x + I y) – 2 x )/ (I y + 1/x) ]
ContourPlot[D[z[x, y],x], {x, -2, 2}, {y, -2, 2}]

This seems rather straightforward, so I’m not sure what I’m missing.

=================

  

 

One issue is that you defined z as an expression but you’re using it as a function. Another issue might be the derivative of Abs; try using ComplexExpand.`
– b.gatessucks
Aug 5 ’14 at 9:27

  

 

How do I fix that?
– user44840
Aug 5 ’14 at 9:33

  

 

You can do z[x_,y_]=ComplexExpand[…, TargetFunctions->{Re, Im}].
– b.gatessucks
Aug 5 ’14 at 9:36

1

 

Following what @b.gatessucks said you have this.
– Öskå
Aug 5 ’14 at 9:48

  

 

@Öskå Ha, you beat me to it :).
– Teake Nutma
Aug 5 ’14 at 9:52

=================

2 Answers
2

=================

As @b.gatessucks said in the comments, there are two issues with your code. First, you’ll need to define z as a function with SetDelayed, and also add in ComplexExpand:

z[x_, y_] := ComplexExpand @ Abs[((1/3 x + I y) – 2 x)/(I y + 1/x)];

z[x,y]

Sqrt[(25 x^2)/9 + y^2] / Sqrt[x^-2 + y^2]

Additionally, ContourPlot holds its arguments (i.e. it doesn’t evaluate them), so you’ll also need to throw in an Evaluate to successfully plot the contours:

ContourPlot[Evaluate @ D[z[x, y], x], {x, -2, 2}, {y, -2, 2}]

  

 

Since b.gatessucks precisely said it, why not letting him/her answer and take the credits for what he/she said? 🙂
– Öskå
Aug 5 ’14 at 9:51

  

 

@Öskå Fair enough; if / when he posts an answer I’ll delete this. In the meantime, I’ve change it to a community wiki.
– Teake Nutma
Aug 5 ’14 at 9:54

  

 

(1/3 x + I y) is different than 1/(3 x + I y).
– Artes
Aug 5 ’14 at 9:55

  

 

@Artes That’s the OP’s fault 😛
– Öskå
Aug 5 ’14 at 9:55

  

 

@TeakeNutma I don’t mean to blame you for this, there are a few questions already answered in the comments which get answered by someone else, I (is it just me?) just think that it’s better to ask the original answerer before posting 🙂
– Öskå
Aug 5 ’14 at 9:57

I believe that you have to split the derivative into two parts (real + imaginary) and then make the corresponding contour plots like this

z[x_, y_] := Abs[((1/3 x + I y) – 2 x)/(I y + 1/x)];
dx[x_, y_] := D[z[x, y], x]
real = Re[ComplexExpand[dx[x, y]]];
img = Im[ComplexExpand[dx[x, y]]];
ContourPlot[real, {x, -2, 2}, {y, -2, 2}, PlotPoints -> 50]
ContourPlot[img, {x, -2, 2}, {y, -2, 2}, PlotPoints -> 50]

The contour of the real part

and that of the imaginary

1

 

AddSomePictures.png.
– Öskå
Aug 5 ’14 at 9:38

  

 

Do I still need to do ContourPlot[{(real)^2 + (img)^2},{x,-2,2},{y,-2,2}] because by defining zz to be the absolute function,thus zz is real, and so dxdx must be real?
– user44840
Aug 5 ’14 at 9:44