# Maximizing symbolic expression

How can I maximize the following symbolic expression in Mathematica, assuming that $da, db \ge 0$?

$\delta(a,b,da,db) = ((a \pm da) (b \pm db)) (1 + y) - ab$

My problem on the first place is that I don't know how to represent a meaningful $\pm$ operator in Mathematica, since PlusMinus is just an eye candy which performs formatting only:

\[Delta] = ((a + PlusMinus[da])(b + PlusMinus[db])) (1 + y) - ab;


I want something like

Subscript[\[Delta], 0] = ((a + da)*(b + db)) (1 + y) - (a*b);
Subscript[\[Delta], 1] = ((a - da)*(b + db)) (1 + y) - (a*b);
Subscript[\[Delta], 2] = ((a + da)*(b - db)) (1 + y) - (a*b);
Subscript[\[Delta], 3] = ((a - da)*(b - db)) (1 + y) - (a*b);
\[Delta] =
Max[Subscript[\[Delta], 0], Subscript[\[Delta], 1],
Subscript[\[Delta], 2], Subscript[\[Delta], 3]];

• Here its considered helpful and polite show your own efforts and share your coded equations and code attempts in a well formatted form, so we can quickly see the problem you are facing. Please help us to help you and edit your question accordingly. – rhermans May 31 '18 at 9:29
• @rhermans If you read my question, it is clear that I ask because I have do not even know how to represent the expression in Mathematica. How would I proceed? – plasmacel May 31 '18 at 9:32
• You want to maximize \[Delta][y] or \[Delta][y,a,b]? In addition it is not clear what the use of PlusMinus stands for. Do you want to maximize four variations of \[Delta] ? – Ulrich Neumann May 31 '18 at 9:59
• @UlrichNeumann I updated my answer, but yeah, I want to generate four variations and determine the one which produces the maximum value. – plasmacel May 31 '18 at 10:05
• BTW, You should avoid using Subscript while defining symbols (variables). Subscript[x, 1] is not a symbol, but a composite expression where Subscript is an operator without built-in meaning. You expect to do $x_1=2$ but you are actually doing Set[Subscript[x, 1], 2] which is to assign a Downvalue to the oprator Subscript and not an Ownvalue to an indexed x as you may intend. Read how to properly define indexed variables here – rhermans May 31 '18 at 22:13

Ok here is an approach. This function takes an expression in the first argument and changes the signs of all the variables listed in the second argument, for all possible Tuples

ToggleSign[expr_, vars_] := ReplaceAll[
expr
, Map[
Rule[#1, #2 #1] &
, {vars, #}
] &
, Tuples[
{-1, 1}
, Length[vars]
]
]
]


So now you can just do

Max[
ToggleSign[
((a + da)*(b + db)) (1 + y) - (a*b)
, {da, db}
]
]

Max[-a b + (a - da) (b - db) (1 + y), -a b + (a + da) (b - db) (1 +
y), -a b + (a - da) (b + db) (1 + y), -a b + (a + da) (b +
db) (1 + y)]


Get conditions for the order of the equations {d1,d2,d3,d4}.

Regard all permutations.

perm = Permutations[{d4, d3, d2, d1}]

perm2 = Less @@ # & /@ perm

perm3 = ToString[#] & /@ perm2

{d1 = ((a + da)*(b + db)) (1 + y) - (a*b),
d2 = ((a - da)*(b + db)) (1 + y) - (a*b),
d3 = ((a + da)*(b - db)) (1 + y) - (a*b),
d4 = ((a - da)*(b - db)) (1 + y) - (a*b)}

Table[Simplify[{perm3[[i]],
Reduce[perm2[[i]] && da > 0 && db > 0 && y > -1, {a, b, da, db},
Reals]}, da > 0 && db > 0 && y > -1], {i, 1,
Length[perm2]}] // TableForm 