I want to draw a graph of the function that I specified using Piecewise
. Though I can draw a graph, I keep getting Min::nord
/Max::nord
errors saying invalid comparison with -xx + yy I
attempted. The followings are my codes.
ublb1[α_, H_, L_] := 1/2 (2 H - H^2 - 2 L + H L - H α + 2 L α -
H L α) -
1/2 Sqrt[-4 H^3 + H^4 + 4 H^2 L - 2 H^3 L + H^2 L^2 +
4 H^2 α + 2 H^3 α - 6 H^2 L α +
2 H^3 L α - 2 H^2 L^2 α - 3 H^2 α^2 +
2 H^2 L α^2 + H^2 L^2 α^2]
test[α_, H_, L_] :=
Piecewise[{{ublb1[α, H, L],
0 < L < H < 1 &&
2 L < H && (H - L)/(1 - H + H^2 - H L) <= α <= (
H^2 - 2 H L + H^2 L + L^2 - H L^2)/(H^2 - H L + L^2 - H L^2) &&
ublb1[α, H, L] ∈ Reals &&
ublb1[α, H, L] <= (1 - α) (1 - H) (H - L)}, {Null,
True}}]
Manipulate[
Plot[{test[α, H, L]}, {α, 0, 1}, AxesOrigin -> {0, 0},
PlotRange -> {0, 1}, AspectRatio -> 1, Frame -> True], {H, 0,
1}, {L, 0, H/2}]
I don't understand why I keep getting the errors about the comparison between the complex number and the real number even though I already include the condition ublb1[α, H, L] ∈ Reals && ublb1[α, H, L] <= (1 - α) (1 - H) (H - L)
.
Thanks for your support in advance.
ublb1[0.3, 0.5, 0.2]
is a complex number. It's coming from theSqrt
. For instance this is negative:With[{\[Alpha] = 0.3, H = 0.5, L = 0.2}, -4 H^3 + H^4 + 4 H^2 L - 2 H^3 L + H^2 L^2 + 4 H^2 \[Alpha] + 2 H^3 \[Alpha] - 6 H^2 L \[Alpha] + 2 H^3 L \[Alpha] - 2 H^2 L^2 \[Alpha] - 3 H^2 \[Alpha]^2 + 2 H^2 L \[Alpha]^2 + H^2 L^2 \[Alpha]^2 ]
Also you should writeublb1[\[Alpha]_, H_, L_] := ...
with underscores in the arguments ofublb1
as you're using SetDelayed like this. $\endgroup$