How to visualise (graphically) this optimization problem in Mathematica?

I have an optimization problem in the form

max $(a-\bar{a})(b-\bar{b})$

subject to $a+b=1$

Here $\bar{a}$ and $\bar{b}$ are known values and both of them are >0.

The solution is given by

$a=(1+\bar{a}-\bar{b})/2$

$b=(1-\bar{a}+\bar{b})/2$

I want to graphically portray this optimization problem. Any suggestion!!

• @Kuba, Thanks for your comment. I know that the optimisation problem can be solved symbolically. I just want to draw a graph. For example, the level lines $z_x$ of the objective function are hyperbolas centered at ($\bar{a},\bar{b}$) and having asymptotes at $a$ and $b$. We are looking for the largest $x$ such that $z_x$ meets the line $l: a+b-1=0$.This is the case when z_x touches the line. This will take place at the point $(a^*, b^*)$ where $a*=(1+\bar{a}-\bar{b})/2$ and $b*=(1-\bar{a}+\bar{b})/2$. I just want to have a graphical presentation of the above mentioned features. Commented Feb 26, 2016 at 9:15
• @Kuba, I am very new to Mathematica. How do we use EvaluationMonitor. Can you please give me an example for my optimization problem. Commented Feb 26, 2016 at 9:19

This is more of an extended comment/question. Are you looking for an interactive 3D representation? Below is a very incomplete example:

Manipulate[
aa = Table[-10 + 20 i/100, {i, 0, 100}];
a = (1 + abar - bbar)/2;
b = (1 - abar + bbar)/2;
Show[Plot3D[(aa - abar) (bb - bbar), {aa, -10, 10}, {bb, -10, 10},
BoundaryStyle -> None, MeshStyle -> LightGray,
PlotStyle -> Opacity[0.2], SphericalRegion -> True,
RotationAction -> "Clip", AspectRatio -> Full,
PlotRange -> {{-10, 10}, {-10, 10}, All}],
Graphics3D[{Thickness[0.01],
Line[Table[{aa[[i]],
1 - aa[[i]], (aa[[i]] - abar) (1 - aa[[i]] - bbar)}, {i, 1,
101}]]}],
ListPointPlot3D[{{abar, bbar, -10}}, PlotStyle -> PointSize[0.03]],
ListPointPlot3D[{{a, b, (a - abar) (b - bbar)}},
PlotStyle -> {Red, PointSize[0.03]}]],
{{abar, 0, "\!$$\*OverscriptBox[\(a$$, $$_$$]\)"}, -10, 10,
Appearance -> "Labeled"},
{{bbar, 0, "\!$$\*OverscriptBox[\(b$$, $$_$$]\)"}, -10, 10,
Appearance -> "Labeled"},
TrackedSymbols :> {abar, bbar}]


As a start, here's a geometric picture of the problem:

Manipulate[
Graphics[
{Line[{{-3, 4}, {4, -3}}],
{Blue, Opacity[0.5], Rectangle @@ p},
Text,
{{{HoldForm@OverBar[a], HoldForm@OverBar[b]}, {HoldForm@a, HoldForm@b}},
p,
{{-1.5, -2.5}, {1.5, 2.5}}
}]
},
PlotRange -> {{-3, 5}, {-3, 5}},
Axes -> True],
{{p, {{2, 3}, {0.5, 0.5}}}, {-3, -3}, {5, 5}, Locator,
TrackingFunction ->
((p = {Clip[First[#], {0, 4}],                (* constrains {a-bar, b-bar} *)
Last@# + (1 - Total[Last@#])/2}) &)}   (* constrains {a, b} *)
]


I'm not sure exactly what all one might like to see demonstrated. It may be clear to the intended audience that when the rectangle is a perfect square the area $(a-\bar{a})(b-\bar{b})$ is a local maximum.

If not, one could show (graphically) that the differential of the area is proportional to the difference of the two sides of the rectangle that are adjacent to {a, b}. Thus we get a local extrema when the sides are equal and therefore when the area is a square.