# How can I improve the code for contour plot of the real part of $f(z)=\frac{1}{z}$? [closed]

I try to plot level curves of the real part of the complex function $f(z)=\frac{1}{z}$ with

ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5},
PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0}]


But I get It is acceptable though, there is a problem at the origin $(0,0)$. How can I improve the code?

• Try increasing the MaxRecursion option in ContourPlot. MaxRecursion -> 4 gives a pretty good result – Marchi Feb 14 '17 at 20:41
• You can try PlotPoints->100 option too – BlacKow Feb 14 '17 at 20:43
• @Marchi: thanks for your comment. That solves the problem. Would you turn your comment into an answer so that I can accept it? – Jack Feb 14 '17 at 23:06

We can solve the rendering issue by increasing the MaxRecursion option in ContourPlot.

ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5},
PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0}] From @BlacKow's comment, the same result can be achieved by increasing the number of PlotPoints:

ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5},
PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0},
PlotPoints -> 100] ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5},
PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0},
MaxRecursion -> 6, ColorFunction -> "Rainbow",
ClippingStyle -> Automatic, Frame -> False,
PerformanceGoal -> "Quality", WorkingPrecision -> 20,
PlotPoints -> 150, ImageSize -> 600] • This one is very nice! Thank you for your answer! – Jack Feb 15 '17 at 14:19