# How to put a condition in 3d plotting

I have the following plotting question:

First I want to have 3D plot of Alpha respect to different values of p and l when we have

SuperStar[t] = (α*ρ*(t + l) - t)/(α*ρ - 1)

eq = (1 - α)^2 + (t^2*
p)/(((SuperStar[t] - l)*(SuperStar[t] - l - 2*t))*A) == 0

Plot3D[ (31104-g[α]) /.
Solve[eq && 0.2 <= α <= 1, α], {l, 1, 5}, {p, 10, 40}]


where t=12, l [2,5], ρ=0.8, p [10, 50], A=70

g[α]= 2304 + 10*(230.4 - 1.6*l^2) + (30*(-1.1368*^-13 + 1.136*^-13*α + l*(-7.105*^-15 + 2.*l)*α^2))
/(1.25 - 1.*α)^2 - (70*α*(360.0 - 2.5*l^2 - 576.*α + 230.4*α^2 + l*(-8.88*^-15 + 1.4*^-14*α
+ 7.105*^-15*α^2)))/(1.25 - 1.*α)^2 + 100*((720. - 576.*α - 48.*l*α)/(1.25 - 1.*α)
- 4*(0. + (112.49 + α*(-179.9 + 72.*α + l*(-15. + (11.99 + 0.5*l)*α)))/(1.25 - 1.*α)^2))
+ (288.*(-0.2 + α)*p)/(1 - α)


I want to see the effect of l and p on (31104-g[α]), but I want to restrict g[α] so that when α is less than 0.2 Mathematica calculate g[α=0.2]

Now i get a graph where there is nothing for α <= 0.2.

I hope that I explained the problem clearly.

• You have numerous undefined symbols in your first two lines of code. Unless they are defined, Plot3D will return nothing but an empty graph, if that. Please edit your Question to define all quantities, including g. Feb 8, 2015 at 15:31
• Dear @bbgodfery, thanks for the comment, I just defined them. hopefully my question is clear now. Feb 8, 2015 at 15:43
• Your equations contain both lower and upper case L. Are these meant to be the same variable? If so, please edit your equations accordingly. If not, please provide the value for lower case l. Additionally, g[α] is undefined. Feb 8, 2015 at 16:03
• Dear @bbgodfery, thanks again just edited. Feb 8, 2015 at 16:43

t = 12; ρ = 8/10; A = 70;
SuperStar[t] = (α ρ (t + L) - t)/(α ρ - 1);
eq = (1 - α)^2 + (t^2 p)/(((SuperStar[t] - L) (SuperStar[t] - L - 2 t))*A) == 0;
soln = Solve[eq && 0 <= α <= 1 && 10 <= p <= 100 && 1 <= L <= 10, α,  Reals];

Plot3D[Evaluate[Max[2/10, α] /. soln], {L, 1, 5}, {p, 10, 40},
BoxRatios -> 1, PlotRange -> {0, 1}, PlotPoints -> 60,
AxesLabel -> (Style[#, 16] & /@ { "L", "p", "\[Alpha]"})]


ClearAll[g1];
g1[L_, p_] :=  With[{α = Max[2/10, α] /. soln},
Simplify@Rationalize[(2304 + 10*(230.4 - 1.6*L^2) +
(30*(-1.1368*^-13 + 1.136*^-13*α +
L*(-7.105*^-15 + 2. L) α^2))/(1.25 - 1. α)^2 -
(70 α*(360.0 - 2.5*L^2 - 576. α + 230.4 α^2 +
L*(-8.88*^-15 + 1.4*^-14*α + 7.105*^-15*α^2)))/(1.25 - 1. α)^2 +
100 ((720. - 576.*α - 48. L α)/(1.25 - 1. α) -
4 (0. + (112.49 + α (-179.9 + 72. α +
L*(-15. + (11.99 + 0.5*L) α)))/(1.25 - 1. α)^2)) +
(288.*(-0.2 + α)* p)/(1 - α))]];

Plot3D[31104 - g1[L, p], {L, 1, 5}, {p, 10, 40},
BoxRatios -> 1, PlotPoints -> 60, AxesLabel -> (Style[#, 16] & /@ {"L", "p", "g1[L,p]"})]


• Dear @kguler, Thanks! could you just tell me why for larger value of p and l (if we change the interval to p[10, 60] and l[1,9]) , the graph doesnt show anything? Feb 8, 2015 at 17:51
• @Saman, try changing the definition of soln to soln = Solve[eq && 0 <= α <= 1 && 10 <= p <= 60 && 1 <= L <=9, α, Reals];
– kglr
Feb 8, 2015 at 18:02
• I changed that but nothing is shown e.g. when L=8 for p>30. I'm confused because it should plot based on Alpha=0.2. Feb 8, 2015 at 18:11
• @Saman, you need to re-evaluate g1 so that new solution for alpha is used in the defition of g1.
– kglr
Feb 8, 2015 at 18:24
• I did but still it gives me nothing. but thanks a lot it works perfectly for the interval I want (I might doing something wrong that i cannot get values for different intervals). one more question do you know if I can show the negative values in 3D plot differently (with different shade or have a transparent surface at {0,0,0} )? Feb 8, 2015 at 18:42