0
$\begingroup$

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
$\endgroup$
  • $\begingroup$ Reduce[A - 2 B < 0 && n0 + n1 + n2 + n3 == 1]? $\endgroup$ – Sjoerd Smit Oct 20 at 18:38
1
$\begingroup$

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]]
$\endgroup$
1
$\begingroup$

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]

enter image description here

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.