# Check whether a given quantity is negative

Given four numbers $$n0, n1, n2, n4$$ such that $$n1+n2+n3+n4 = 1$$. How can we check the sign of $$A - 2 B$$ (where $$A$$ and $$B$$ are defined below), i.e., whether this quantity is positive or negative?

A = (n0 + n1 - n2 - n3)^2;
B = (n0 - n1)^2 + (n2 - n3)^2;

Expand[A - 2 B]

Out[21]= -n0^2 + 6 n0 n1 - n1^2 - 2 n0 n2 - 2 n1 n2 - n2^2 -
2 n0 n3 - 2 n1 n3 + 6 n2 n3 - n3^2

• Reduce[A - 2 B < 0 && n0 + n1 + n2 + n3 == 1]? – Sjoerd Smit Oct 20 at 18:38

Try

sgn[n0_?NumericQ, n1_?NumericQ, n2_?NumericQ, n3_?NumericQ] := Module[{A = (n0 + n1 - n2 - n3)^2,B = (n0 - n1)^2 + (n2 - n3)^2},Sign[A - 2 B]]


You can make visualization to roughly understand what values of n0, n1,n2, n3 correspond to A-2 B being positive or negative.

A = (n0 + n1 - n2 - n3)^2;
B = (n0 - n1)^2 + (n2 - n3)^2;

Simplify[A - 2 B, n0 + n1 + n2 + n3 == 1]

(* -1 - 8 n1^2 + 8 n2 n3 - 8 n1 (-1 + n2 + n3) *)

RegionPlot3D[-1 - 8 n1^2 + 8 n2 n3 - 8 n1 (-1 + n2 + n3) > 0,
{n1, -10, 10}, {n2, -10, 10}, {n3, -10, 10},
AxesLabel -> Automatic, PlotPoints -> 50, BaseStyle -> 12]


Empty space in picture represent region where A-2 B < 0.