# Using MaxValue and MinValue with two constraints

This is my code below. I'm trying to find the min and max values of z0value1 in the range of cmin<c<cmaxthat satisfies the equation and the inequality inside the Max,MinValue functions. I tried plotting the graph for the equation v0==... so from seeing that, I'm expecting z0value1 to be in the range of around [0.000335,0.000346]. How do I make my MinValue, MaxValue functions work properly?

### Update

v0 = 5*10^-9;
{avalue, bvalue} = {0.00123, 0.00109};
{cmin, cmax} = {0.000814, 0.00109};

z0min =
MinValue[
{z0value1,
v0 == 2/3 π avalue^2 bvalue + 2/3 π avalue^2 c -
(π avalue^2 (2 c^3 - 3 c^2 z0value1 + z0value1^3))/(3 c^2)
&& cmin < c < cmax},
c];

z0max =
MaxValue[
{z0value1,
v0 == 2/3 π avalue^2 bvalue + 2/3 π avalue^2 c -
(π avalue^2 (2 c^3 - 3 c^2 z0value1 + z0value1^3))/(3 c^2)
&& cmin < c < cmax},
c];

{z0min, z0max}

{MinValue[
{z0value1,
1/200000000 ==
3.45379*10^-9 + 3.16861*10^-6 c -
(1.58431*10^-6 (2 c^3 - 3 c^2 z0value1 + z0value1^3))/c^2
&& 0.000814 < c < 0.00109},
c],
MaxValue[
{z0value1,
1/200000000 ==
3.45379*10^-9 + 3.16861*10^-6 c -
(1.58431*10^-6 (2 c^3 - 3 c^2 z0value1 + z0value1^3))/c^2
&& 0.000814 < c < 0.00109},
c]}

ContourPlot[
v0 == 2/3 π avalue^2 bvalue +
2/3 π avalue^2 c - (π avalue^2 (2 c^3 - 3 c^2 z0value1 +
z0value1^3))/(3 c^2), {c, cmin, cmax}, {z0value1, 0.00033,
0.00035}, FrameLabel -> {c, z0value1}] • What do you mean by "How do I make my MinValue, MaxValue functions work properly? ". MinValue and MaxValue are built-in function, not your functions. You don't have any function definitions in your posted code. Jan 13 '17 at 6:37
• My bad. bad wording. I meant how do I get the output that I want by using those functions(or anything else) because they don't give me any output..
– Jun
Jan 13 '17 at 6:40
• Ok yes good point, I editted it.
– Jun
Jan 13 '17 at 7:03

The objective function as given has no dependence on c. The code will work if z0value1 is made into an independent variable.

v0 = 5*10^-9;
{avalue, bvalue} = {0.00123, 0.00109};
{cmin, cmax} = {0.000814, 0.00109};

z0min = MinValue[{z0value1,
v0 == 2/3 Pi avalue^2 bvalue +
2/3 Pi avalue^2 c - (Pi avalue^2 (2 c^3 -
3 c^2 z0value1 + z0value1^3))/(3 c^2) &&
cmin < c < cmax}, {c, z0value1}];

z0max = MaxValue[{z0value1,
v0 == 2/3 Pi avalue^2 bvalue +
2/3 Pi avalue^2 c - (Pi avalue^2 (2 c^3 -
3 c^2 z0value1 + z0value1^3))/(3 c^2) &&
cmin < c < cmax}, {c, z0value1}];

{z0min, z0max}

(* {-0.00203336, 0.0016974} *)


Check the corresponding plot looks plausible

ContourPlot[
v0 == 2/3 Pi avalue^2 bvalue +
2/3 Pi avalue^2 c - (Pi avalue^2 (2 c^3 - 3 c^2 z0value1 +
z0value1^3))/(3 c^2), {c, cmin, cmax}, {z0value1, z0min,
z0max}, FrameLabel -> {c, z0value1},
Epilog -> {Red, PointSize[Medium],
Point[{{cmax, z0min}, {cmax, z0max}}]}] 