6
$\begingroup$

The plot below shows branch cut along Re[z]=0 line, however, the corners are smoothed. Is there a trick to help it spend more effort on computing higher quality exclusions?

Cranking up PlotPoints has no effect here

enter image description here

expr[z_] = Expectation[1/(z - x), x \[Distributed] UniformDistribution[]]; Plot3D[Im@expr[z] /. z -> (x + I y), {x, -1/2, 3/2}, {y, -1/2, 1/2},(*Enhanced plot options*)PlotRange -> {-5, 5}, PlotPoints -> 150,(*Increased for better resolution*) MaxRecursion -> 5,(*Higher recursion for better singularity capture*)(*Color scheme t\ hat emphasizes extremes*) ColorFunction -> (ColorData["TemperatureMap"][ Rescale[#3, {10, -10}, {0, 1}]] &), ColorFunctionScaling -> False,(*Exclusions to handle singularities*) ExclusionsStyle -> {None, Directive[Red, Thick]},(*Enhanced mesh for contour visualization*) MeshFunctions -> {#3 &}, Mesh -> {Range[-3, 3, .5]}, MeshStyle -> {{Opacity[0.5], Darker[Blue]}, {Opacity[0.3], Gray}},(*Visual styling*) PlotStyle -> Directive[Specularity[White, 10], Opacity[0.95]], ClippingStyle -> None, Exclusions -> {Im[Sqrt[x + I y]] == 0}, Lighting -> {{"Ambient", GrayLevel[0.3]}, {"Directional", White, ImageScaled[{0, 0, 2}]}, {"Directional", White, ImageScaled[{1, 1, 1}]}},(*Labels and formatting*) PlotLabel -> Style["Stieltjes Transform of Uniform", FontSize -> 16, FontWeight -> Bold], AxesLabel -> {Style["Re[z]", FontSize -> 14, Bold], Style["Im[z]", FontSize -> 14, Bold], Style["Im[f(z)]", FontSize -> 14, Bold]},(*View and layout*) BoxRatios -> {1, 1, 0.6}, ViewPoint -> {-2.5, 2.5, 1.8}, ViewVertical -> {0, 0, 1}, PlotTheme -> "Detailed",(*Additional styling*) Background -> GrayLevel[0.95], ImageSize -> Large, AxesStyle -> Directive[Black, Thickness[0.002]], Boxed -> False, FaceGrids -> None, BaseStyle -> {FontFamily -> "Helvetica"}] 

Background: this visualizes the https://en.wikipedia.org/wiki/Stieltjes_transformation to recover UniformDistribution[0,1]

$\endgroup$
2
  • $\begingroup$ Did you try MaxRecursions? $\endgroup$ Commented Jun 7 at 17:04
  • $\begingroup$ @UlrichNeumann yes, it's at 5, raising it to 7 didn't seem to show any difference $\endgroup$ Commented Jun 7 at 17:06

2 Answers 2

6
$\begingroup$

The "smoothing" comes from a gap created by Exclusions. Sketch the pieces separately and combine:

Show[ Plot3D[Im@expr[z] /. z -> (x + I y), {x, -1/2, 3/2}, {y, -1/2, 0},(*Enhanced plot options*)PlotRange -> {-5, 5}, PlotPoints -> 150,(*Increased for better resolution*) MaxRecursion -> 7,(*Higher recursion for better singularity capture*)(*Color scheme\ that emphasizes extremes*) ColorFunction -> (ColorData["TemperatureMap"][ Rescale[#3, {10, -10}, {0, 1}]] &), ColorFunctionScaling -> False,(*Exclusions to handle singularities*) ExclusionsStyle -> {None, Directive[Red, Thick]},(*Enhanced mesh for contour visualization*) MeshFunctions -> {#3 &}, Mesh -> {Range[-3, 3, .5]}, MeshStyle -> {{Opacity[0.5], Darker[Blue]}, {Opacity[0.3], Gray}}, (*Visual styling*) PlotStyle -> Directive[Specularity[White, 10], Opacity[0.95]], ClippingStyle -> None, Exclusions -> {Im[Sqrt[x + I y]] == 0}, Lighting -> {{"Ambient", GrayLevel[0.3]}, {"Directional", White, ImageScaled[{0, 0, 2}]}, {"Directional", White, ImageScaled[{1, 1, 1}]}},(*Labels and formatting*) PlotLabel -> Style["Stieltjes Transform of Uniform", FontSize -> 16, FontWeight -> Bold], AxesLabel -> {Style["Re[z]", FontSize -> 14, Bold], Style["Im[z]", FontSize -> 14, Bold], Style["Im[f(z)]", FontSize -> 14, Bold]},(*View and layout*) BoxRatios -> {1, 1, 0.6}, ViewPoint -> {-2.5, 2.5, 1.8}, ViewVertical -> {0, 0, 1}, PlotTheme -> "Detailed",(*Additional styling*) Background -> GrayLevel[0.95], ImageSize -> Large, AxesStyle -> Directive[Black, Thickness[0.002]], Boxed -> False, FaceGrids -> None, BaseStyle -> {FontFamily -> "Helvetica"}], Plot3D[Im@expr[z] /. z -> (x + I y), {x, -1/2, 3/2}, {y, 0, 1/2},(*Enhanced plot options*)PlotRange -> {-5, 5}, PlotPoints -> 150,(*Increased for better resolution*) MaxRecursion -> 7,(*Higher recursion for better singularity capture*)(*Color scheme\ that emphasizes extremes*) ColorFunction -> (ColorData["TemperatureMap"][ Rescale[#3, {10, -10}, {0, 1}]] &), ColorFunctionScaling -> False,(*Exclusions to handle singularities*) ExclusionsStyle -> {None, Directive[Red, Thick]},(*Enhanced mesh for contour visualization*) MeshFunctions -> {#3 &}, Mesh -> {Range[-3, 3, .5]}, MeshStyle -> {{Opacity[0.5], Darker[Blue]}, {Opacity[0.3], Gray}}, (*Visual styling*) PlotStyle -> Directive[Specularity[White, 10], Opacity[0.95]], ClippingStyle -> None, Exclusions -> {Im[Sqrt[x + I y]] == 0}, Lighting -> {{"Ambient", GrayLevel[0.3]}, {"Directional", White, ImageScaled[{0, 0, 2}]}, {"Directional", White, ImageScaled[{1, 1, 1}]}},(*Labels and formatting*) PlotLabel -> Style["Stieltjes Transform of Uniform", FontSize -> 16, FontWeight -> Bold], AxesLabel -> {Style["Re[z]", FontSize -> 14, Bold], Style["Im[z]", FontSize -> 14, Bold], Style["Im[f(z)]", FontSize -> 14, Bold]},(*View and layout*) BoxRatios -> {1, 1, 0.6}, ViewPoint -> {-2.5, 2.5, 1.8}, ViewVertical -> {0, 0, 1}, PlotTheme -> "Detailed",(*Additional styling*) Background -> GrayLevel[0.95], ImageSize -> Large, AxesStyle -> Directive[Black, Thickness[0.002]], Boxed -> False, FaceGrids -> None, BaseStyle -> {FontFamily -> "Helvetica"}], ParametricPlot3D[{{x, 0, Im@expr[z] /. z -> (x + I (-$MachineEpsilon))}, {x, 0, Im@expr[z] /. z -> (x + I (+$MachineEpsilon))}}, {x, -1/2, 3/2}, PlotStyle -> Directive[Red, Thick]], PlotRange -> All] 

enter image description here


@azerbajdzan's modification of the singular locus can be implemented in the method in my comment. Since the method is a simpler approximation, I thought I'd include both:

expr[z_] = Expectation[1/(z - x), x \[Distributed] UniformDistribution[]]; ParametricPlot3D[ {x, y^3/(1/2)^2, Im@expr[z] /. z -> (x + I y^3/(1/2)^2)}, {x, -1/2, 3/2}, {y, -1/2, 1/2},(*Enhanced plot options*) PlotRange -> {Automatic, Automatic, {-5, 5}} , PlotPoints -> 25 , MaxRecursion -> 4 ,(*Color scheme that emphasizes extremes*) ColorFunction -> (ColorData["TemperatureMap"][ Rescale[#3, {4, -4}, {0, 1}]] &), ColorFunctionScaling -> False,(*Exclusions to handle singularities*) ExclusionsStyle -> {None, Directive[Red, Thick]},(*Enhanced mesh for contour visualization*) MeshFunctions -> {#3 &}, Mesh -> {Range[-3, 3, .5]}, MeshStyle -> {{Opacity[0.5], Darker[Blue]}, {Opacity[0.3], Gray}},(*Visual styling*) PlotStyle -> Directive[Specularity[White, 10], Opacity[0.95]] (*,ClippingStyle->None*) , Exclusions -> {{Im[z] == 0, 0 <= Re[z] <= 1} /. z -> x + I y} , Lighting -> {{"Ambient", GrayLevel[0.3]}, {"Directional", White, ImageScaled[{0, 0, 2}]}, {"Directional", White, ImageScaled[{1, 1, 1}]}},(*Labels and formatting*) PlotLabel -> Style["Stieltjes Transform of Uniform", FontSize -> 16, FontWeight -> Bold], AxesLabel -> {Style["Re[z]", FontSize -> 14, Bold], Style["Im[z]", FontSize -> 14, Bold], Style["Im[f(z)]", FontSize -> 14, Bold]},(*View and layout*) BoxRatios -> {1, 1, 0.6}, ViewPoint -> {-2.5, 2.5, 1.8}, ViewVertical -> {0, 0, 1}, PlotTheme -> "Detailed",(*Additional styling*) Background -> GrayLevel[0.95], ImageSize -> Large, AxesStyle -> Directive[Black, Thickness[0.002]], Boxed -> False, FaceGrids -> None, BaseStyle -> {FontFamily -> "Helvetica"}] 

enter image description here

$\endgroup$
3
  • $\begingroup$ Another way that seems sufficient and faster: ParametricPlot3D[{x, y^3/(1/2)^2, Im@expr[z] /. z -> (x + I y^3/(1/2)^2)}..., PlotPoints -> 25, MaxRecursion -> 4...]. $\endgroup$ Commented Jun 7 at 17:58
  • $\begingroup$ Can you include the full command for parametric plot? $\endgroup$ Commented Jun 7 at 20:50
  • $\begingroup$ @YaroslavBulatov The only thing missing was your def. of expr[z], which I've added now. (I copied the code and tested -- it worked.) $\endgroup$ Commented Jun 7 at 22:06
5
$\begingroup$

I used Michael E2 trick on dividing the plot into two halves.

My contribution is just that I believe exclusion should be only rectangle without lateral lines.

Exclusions -> {{y == 0, 0 <= x <= 1}}

Although it does not works since we divided the plot along exclusion so I added rectangle afterwards.

Another contribution is changing color function to (since OP did not used whole range of colors) :

ColorFunction -> (ColorData["TemperatureMap"][(#3 + Pi)/(2 Pi)] &)

I also changed lighting to:

Lighting -> {{"Ambient", White}}

because I do not like when plot changes its colors when rotating when OP used Directional light.

expr[z_] = Expectation[1/(z - x), x \[Distributed] UniformDistribution[]]; Show[Plot3D[ Im@expr[z] /. z -> (x + I y), {x, -1/2, 3/2}, {y, Sequence @@ #},(*Enhanced plot options*)PlotRange -> {-5, 5}, PlotPoints -> 150,(*Increased for better resolution*) MaxRecursion -> 5,(*Higher recursion for better singularity capture*)(*Color \ scheme that emphasizes extremes*) ColorFunction -> (ColorData["TemperatureMap"][(#3 + Pi)/( 2 Pi)] &), ColorFunctionScaling -> False,(*Exclusions to handle singularities*) ExclusionsStyle -> {None, Directive[Red, Thick]},(*Enhanced mesh for contour visualization*) MeshFunctions -> {#3 &}, Mesh -> {Range[-3, 3, .5]}, MeshStyle -> {{Opacity[0.5], Darker[Blue]}, {Opacity[0.3], Gray}},(*Visual styling*) PlotStyle -> Directive[Specularity[White, 10], Opacity[0.95]], ClippingStyle -> None, Exclusions -> {{y == 0, 0 <= x <= 1}}, Lighting -> {{"Ambient", White}},(*Labels and formatting*) PlotLabel -> Style["Stieltjes Transform of Uniform", FontSize -> 16, FontWeight -> Bold], AxesLabel -> {Style["Re[z]", FontSize -> 14, Bold], Style["Im[z]", FontSize -> 14, Bold], Style["Im[f(z)]", FontSize -> 14, Bold]},(*View and layout*) BoxRatios -> {1, 1, 0.6}, ViewPoint -> {-2.5, 2.5, 1.8}, ViewVertical -> {0, 0, 1}, PlotTheme -> "Detailed",(*Additional styling*) Background -> GrayLevel[0.95], ImageSize -> Large, AxesStyle -> Directive[Black, Thickness[0.002]], Boxed -> False, FaceGrids -> None, BaseStyle -> {FontFamily -> "Helvetica"}] & /@ {{-1/2, 0}, {0, 1/2}}, Graphics3D[{EdgeForm[Directive[Red, Thick]], FaceForm[None], Polygon[{{0, 0, Pi}, {1, 0, Pi}, {1, 0, -Pi}, {0, 0, -Pi}}]}], PlotRange -> {{-1/2, 3/2}, {-1/2, 1/2}, {-5, 5}}] 

enter image description here

$\endgroup$
1
  • $\begingroup$ Exclusions -> {{y == 0, 0 <= x <= 1}} works on the method in my comment under my answer. I added it to my answer, in case the comment was too vague with all the ...s. (+1) $\endgroup$ Commented Jun 7 at 19:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.