# How do I Maximize over a Cuboid region?

So, I want to, say, find a maximum value of $|x_1x_3+x_1x_4+x_2x_3-x_2x_4|$ in a unit cube in 4D; how do I do that?

I've tried

NMaximize[Abs[a*c + a*d + b*c - b*d], {a, b, c, d } in Cuboid[{0, 0, 0, 0}]],

but it said that

a in Cuboid[{0,0,0,0}] is not a valid variable;

I also tried doing

Maximize[Abs[a* c + b* c + a *d - b* d], {{a, 0, 1}, {b, 0, 1}, {c, 0, 1}, {d, 0, 1}} ],

but did not prevail as well.

What is the correct syntax for this?

## 1 Answer

NMaximize[
Abs[a*c + a*d + b*c - b*d], {a, b, c, d} \[Element]
Cuboid[{0, 0, 0, 0}]]


(* {2., {a -> 1., b -> 1., c -> 1., d -> 1.}} *)

• Oh, so that's how you write $\in$... Thanks! May 17, 2016 at 18:11
• @Akiiino. Alternatively, hit the escape button, type elem, and hit the escape button again. May 17, 2016 at 18:14
• @Akiiino... gosh, so not even an upvote? May 17, 2016 at 18:14
• @DavidG.Stork sort of waiting for the site to allow me to accept the answer... But yeah, definitely no upvote now May 17, 2016 at 18:16