2
$\begingroup$
 p11[x_, δ_, b11_] := 1/x^4 + (2 b11)/x^2 + 4/x - 4 b11 x - 
  1/(1 + (-1 + x^3) (1 + δ)^3)^(4/3) - (
  2 b11)/(1 + (-1 + x^3) (1 + δ)^3)^(2/3) - 
  4/(1 + (-1 + x^3) (1 + δ)^3)^(1/3) + 
  4 b11 (1 + (-1 + x^3) (1 + δ)^3)^(1/3)
Plot3D[p11[x, 0.01, b11]/0.01, {x, 1, 4}, {b11, 0, 0.5}, 
 Boxed -> False, AxesLabel -> {x, b11, p}, Mesh -> 5, 
 PlotLegends -> Automatic, BoundaryStyle -> Thick, AxesStyle -> Black,
  ViewPoint -> {-1.2, -2, 1.5}, 
 Ticks -> {{0, 2, 4}, Automatic, {5, 10}}, BoxRatios -> {1, 1, 1}]

enter image description here

Q:I want to show the maximum(or the peak) in red color, and the minmum(or the Valley) in blue.

color the local maximum region and the local minimum region

I want to see the location of the vally in colors, and how it changes with b11. I wonder if ColorFunction can do this? Can MMA color the nearby area of local extreme value in different color with others?

enter image description here

just like this

enter image description here

The extremum can be found like this Abs[D[p11[x, 0.01, b11], x]]=0.

$\endgroup$
5
  • 1
    $\begingroup$ You could use something like Show[(* plot *), Graphics3D[{{Red, Sphere[(* max location *), 0.02]}, {Blue, Sphere[(* min location *), 0.02]}}]]. $\endgroup$ Commented Oct 25, 2017 at 8:41
  • $\begingroup$ Thank you for your suggestion! But I want to know how the function p[]-x change with b11 from 3Dplot, not the number solutions. $\endgroup$
    – keanhy
    Commented Oct 25, 2017 at 9:23
  • 1
    $\begingroup$ Now what you sought, but I prefer: ColorFunction -> "Rainbow". $\endgroup$ Commented Oct 25, 2017 at 15:19
  • $\begingroup$ Related question: mathematica.stackexchange.com/q/94595 $\endgroup$
    – m_goldberg
    Commented Oct 25, 2017 at 16:27
  • 2
    $\begingroup$ You don't have local extrema in the regions you outline $\endgroup$
    – m_goldberg
    Commented Oct 26, 2017 at 2:32

2 Answers 2

3
$\begingroup$
p3d = Plot3D[p11[x, 0.01, b11]/0.01, {x, 1, 4}, {b11, 0, 0.5}, 
     Boxed -> False, AxesLabel -> {x, b11, p}, Mesh -> 5, 
     PlotLegends -> Automatic, BoundaryStyle -> Thick, 
     AxesStyle -> Black, ViewPoint -> {-1.2, -2, 1.5}, 
     Ticks -> {{0, 2, 4}, Automatic, {5, 10}}, BoxRatios -> {1, 1, 1}];

{min, max} = #[p3d[[1, 1]], Last] & /@ {MinimalBy, MaximalBy};
Show[p3d, Graphics3D[{PointSize[.05], Blue, Point@ First @ min, Red, Point@ First @ max}]]

enter image description here

$\endgroup$
4
  • $\begingroup$ Better to use Sphere than Point in 3D don't you think? $\endgroup$
    – m_goldberg
    Commented Oct 25, 2017 at 16:23
  • $\begingroup$ @m_goldberg, I agree; but plain Sphere gives ellipsoids, and felt lazy to find the right values for the second argument:) $\endgroup$
    – kglr
    Commented Oct 25, 2017 at 16:31
  • $\begingroup$ In such cases I use Ellipsoid to adjust the markers to spherical. $\endgroup$
    – m_goldberg
    Commented Oct 25, 2017 at 16:36
  • $\begingroup$ Sorry about my bad description, I just redescribe the question. Can MMA color the nearby area of local extreme value in different color just like the third picture? $\endgroup$
    – keanhy
    Commented Oct 26, 2017 at 1:48
3
$\begingroup$

The plot really looks better with spheres marking the extrema. And since kglr doesn't want to take the time to write the code to make such markers, I will will supply it.

p11[x_, δ_, b11_] := 
  1/x^4 + (2 b11)/x^2 + 4/x - 4 b11 x - 1/(1 + (-1 + x^3) (1 + δ)^3)^(4/3) - 
  (2 b11)/(1 + (-1 + x^3) (1 + δ)^3)^(2/3) - 4/(1 + (-1 + x^3) (1 + δ)^3)^(1/3) + 
  4 b11 (1 + (-1 + x^3) (1 + δ)^3)^(1/3)

surface = 
  Plot3D[p11[x, 0.01, b11]/0.01, {x, 1, 4}, {b11, 0, 0.5},
    Boxed -> False, AxesLabel -> {x, b11, p}, Mesh -> 5, 
    PlotLegends -> Automatic, BoundaryStyle -> Thick, 
    AxesStyle -> Black, ViewPoint -> {-1.2, -2, 1.5}, 
    Ticks -> {{0, 2, 4}, Automatic, {5, 10}}, BoxRatios -> {1, 1, 1}]

{min, max} = 
  Chop[#[surface[[1, 1]], Last] & /@ {MinimalBy, MaximalBy}, 10^-5][[All, 1]]

extrema =
  With[{r = .03 (max - min)}, 
    Graphics3D[{Blue, Ellipsoid[min, r], Red, Ellipsoid[max, r]}]];

Show[surface, extrema, PlotRange -> All]

plot

r is computed from the formula

 r = scaleFactor {xRange, yRange, zRange} = scaleFactor (max - min)

where scalarFactor is picked by eye.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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