Consider the polar coordinates function of a circle centered at $(2,0)$ with a radius of $\sqrt 2$:
$$\rho(\theta)=\left\{\quad \begin{array}{c} 2 \cos \theta +\sqrt{2-4 \sin ^2\theta} \\ 2 \cos \theta -\sqrt{2-4 \sin ^2\theta} \\ \end{array} \right.,\quad \theta\in[\dfrac{\pi}{4},\dfrac{\pi}{4}]$$
Visualization:
PolarPlot[{2 Cos[t] + Sqrt[2 - 4 Sin[t]^2],
2 Cos[t] - Sqrt[2 - 4 Sin[t]^2]}, {t, -Pi/4, Pi/4},
PlotStyle -> {Red, Blue}, PlotRange -> {{0, 3.5}, {-1.5, 1.5}},
Epilog -> {{PointSize -> .02, Point[{{1, 1}, {1, -1}}]}, {Green,
Dashed, Line[{{0, 1}, {1, 1}, {1, -1}, {0, -1}}]}, {Purple,
Line[{{1, 1}, {0, 0}, {1, -1}}]}}, AxesStyle -> Arrowheads[.03],
PlotRangePadding -> Scaled[.05], ImageSize -> 600]
Where the blue and red arcs represents different part of the piecewise defined circle.
However, in Mathematica, when expand the plot domain of $\theta$ to $[-\pi,\pi]$, either piecewise of it gives a whole circle:
p1 = PolarPlot[{2 Cos[t] + Sqrt[2 - 4 Sin[t]^2]}, {t, -Pi, Pi},
PlotStyle -> {Red}, PlotRange -> {{0, 3.5}, {-1.5, 1.5}},
Epilog -> {{PointSize -> .02, Point[{{1, 1}, {1, -1}}]}, {Green,
Dashed, Line[{{0, 1}, {1, 1}, {1, -1}, {0, -1}}]}, {Purple,
Line[{{1, 1}, {0, 0}, {1, -1}}]}}, AxesStyle -> Arrowheads[.03],
PlotRangePadding -> Scaled[.05], ImageSize -> 400];
p2 = PolarPlot[{2 Cos[t] - Sqrt[2 - 4 Sin[t]^2]}, {t, -Pi, Pi},
PlotStyle -> {Blue}, PlotRange -> {{0, 3.5}, {-1.5, 1.5}},
Epilog -> {{PointSize -> .02, Point[{{1, 1}, {1, -1}}]}, {Green,
Dashed, Line[{{0, 1}, {1, 1}, {1, -1}, {0, -1}}]}, {Purple,
Line[{{1, 1}, {0, 0}, {1, -1}}]}}, AxesStyle -> Arrowheads[.03],
PlotRangePadding -> Scaled[.05], ImageSize -> 400];
Grid[{{p1,p2}}]
What special technique has been used in Mathematica when handling complex values of the function? How to let Mathematica ignore those complex values (not to plot them)?
p1 = PolarPlot[{2 Cos[t] + Sqrt[2 - 4 Sin[t]^2]}, {t, -Pi, Pi}, RegionFunction -> ((2 - 4 Sin[#1]^2) > 0 &)]
$\endgroup$Re[...]
not achieve what you want? Or usingPiecewise
? $\endgroup$ContourPlot3D[ z == Sin[(x z - 1/2)^2 + 2 x y^2 - z/ 10] Exp[-(x - 1/2 - Exp[z - y])^2 + y^2 - z/5 + 3], {x, -1, 7}, {y, -2, 2}, {z, -1, 2}, PlotTheme -> "Classic"]
$\endgroup$