BRAGA

02 Writing02-02 Notes02-02-106

Inequality rule flip (negative)

Published 16 Apr 202610 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples

If a>ba > b and m<0m < 0, then am<bmam < bm and am<bm\frac{a}{m} < \frac{b}{m}

Deep Breakdown

What it tells me (Situation Awareness): When you multiply or divide both sides of an inequality by a negative number, the direction of the inequality reverses. Formally: if a>ba > b and m<0m < 0, then am<bmam < bm and a/m<b/ma/m < b/m. This is one of the most commonly violated rules in algebraic manipulation, and it is especially easy to overlook in DA/DS when dealing with gradient directions, sign-based loss transformations, and convex/concave function comparisons. Key appearances: (1) optimizing a loss function — minimizing f(θ)f(\theta) is equivalent to maximizing −f(θ)-f(\theta); when you write arg min⁡θf=arg max⁡θ(−f)\argmin_\theta f = \argmax_\theta (-f), the flip is implicit; (2) inequality constraints in linear programs — multiplying a constraint by −1-1 to convert ≥\ge to ≤\le (standard form) flips the sign and the direction; (3) confidence interval reversal — if you standardize by dividing by a negative quantity, the bounds reverse; (4) gradient sign analysis — if a gradient is negative, increasing a parameter decreases the loss; this sign flip is the inequality flip applied to the direction of change; (5) correlation sign — if Cov(X,Y)<0\text{Cov}(X, Y) < 0, then −Cov(X,Y)>0-\text{Cov}(X, Y) > 0, and any inequality involving the covariance flips when negated.

Flowchart

Inequality flip: a> b, m < 0 → am< bmProof: a > b →a-b > 0. Multiplyby m < 0: m(a-b)< 0 → ma < mbRule:multiply/divideby negative →directionreversesEquivalent: a/m< b/m when m <0 (division ismultiplication by1/m < 0)DA: min f = max(-f) — negatingobjectivereverses allinequalitiesDA: LP standardform — multiply>= constraint by-1 to get <= , flipDA: gradientdescent — ifgrad < 0, movingin positivedirectiondecreases lossTRAP: ruleapplies ONLYwhen m < 0; if m> 0 theinequality ispreservedTRAP: neverapply flip to m =0 — division byzero isundefined

Real-world use

Where it is used

Linear programming standard form: optimization problems are often written with ≥\ge constraints. Converting to ≤\le (standard form) requires multiplying by −1-1: aTx≥b\mathbf{a}^T \mathbf{x} \ge b becomes −aTx≤−b-\mathbf{a}^T \mathbf{x} \le -b. The inequality flips because the multiplier is −1<0-1 < 0. Gradient descent direction: if ∂L/∂θj<0\partial L / \partial \theta_j < 0, then increasing θj\theta_j (positive step) decreases LL. This is the flip in action: L<0⇒−L>0L < 0 \Rightarrow -L > 0, meaning the negated gradient points in the direction of steepest ascent.

Problem it solves

Many derivations involve multiplying both sides of an inequality by a negative quantity (a coefficient, a negative correlation, a negated weight). Without the flip rule, sign errors propagate silently, producing incorrect optimization directions, wrong confidence interval bounds, or inverted inequality constraints.

How it solves the problem

Proof: suppose a>ba > b, so a−b>0a - b > 0. Multiply both sides by m<0m < 0: m(a−b)<0m(a - b) < 0 (product of positive and negative is negative). Expanding: ma−mb<0ma - mb < 0, so ma<mbma < mb. For division: a/m=a⋅(1/m)a/m = a \cdot (1/m) and 1/m<01/m < 0 when m<0m < 0, so division is just multiplication by 1/m<01/m < 0, and the same flip applies.

Example in a business

A data scientist is solving a portfolio allocation problem. The constraint is that expected return μTw≥Rmin\mu^T w \ge R_\text{min}. To feed this into a standard linear solver that expects ≤\le constraints, they multiply both sides by −1-1: −μTw≤−Rmin-\mu^T w \le -R_\text{min}. The inequality flips from ≥\ge to ≤\le because the multiplier is −1<0-1 < 0. This is one of the most routine transformations in constrained optimization.

The formula, piece by piece

Breaking the notation:

  • a>ba > b: the starting inequality — aa is strictly greater than bb.
  • m<0m < 0: the negative multiplier (or divisor).
  • am<bmam < bm: the result — after multiplying by the negative mm, the inequality direction reverses: previously larger amam is now smaller.
  • a/m<b/ma/m < b/m: same result for division — dividing by m<0m < 0 also reverses the direction. Why it reverses (intuitive): multiplying by a negative flips the number line.

If aa is to the right of bb on the number line, then mama is to the left of mbmb after reflecting about 00. Comparison of cases:

Condition Operation Inequality direction
m>0m > 0 multiply or divide preserved: a>b⇒am>bma > b \Rightarrow am > bm
m<0m < 0 multiply or divide reversed: a>b⇒am<bma > b \Rightarrow am < bm
m=0m = 0 multiply all become zero (trivial)
m=0m = 0 divide undefined

Non-strict version: if a≥ba \ge b and m<0m < 0, then am≤bmam \le bm (weak inequality with equality possible). TRAP: only for multiplication/division, not addition/subtraction. Adding or subtracting any real number (positive, negative, or zero) from both sides of an inequality never changes the direction: a>b⇒a+c>b+ca > b \Rightarrow a + c > b + c for any c∈Rc \in \mathbb{R}.

The formula in words

"Multiplying or dividing both sides of an inequality by a negative number reverses the direction. a>ba > b and m<0m < 0 gives am<bmam < bm. Always check the sign of the multiplier before deciding whether the inequality direction stays or flips. In optimization: negating an objective converts minimization to maximization (and vice versa). In LP: multiply ≥\ge constraint by −1-1 to get ≤\le (standard form), flipping direction. In gradient analysis: a negative gradient means the function decreases in the positive direction."

Critical Concepts

  1. Sign of multiplier determines direction: positive multiplier preserves inequality; negative multiplier reverses it. This is the complete rule. No exceptions (except m=0m = 0, where division is undefined and multiplication gives 0=00 = 0).
  2. Minimization–maximization duality: arg min⁡θf(θ)=arg max⁡θ(−f(θ))\argmin_\theta f(\theta) = \argmax_\theta (-f(\theta)). This implicit inequality flip is used constantly: the cross-entropy loss is minimized by maximizing the log-likelihood (which is −-cross-entropy). The negative multiplier here is −1-1.
  3. LP standard form conversions: aTx≥b\mathbf{a}^T\mathbf{x} \ge b becomes −aTx≤−b-\mathbf{a}^T\mathbf{x} \le -b. Both the coefficient vector and the right-hand side change sign. The direction flips from ≥\ge to ≤\le.
  4. Gradient descent sign logic: if ∂L∂θ>0\frac{\partial L}{\partial \theta} > 0, the parameter θ\theta should decrease (negative update). If ∂L∂θ<0\frac{\partial L}{\partial \theta} < 0, it should increase (positive update). The update θ←θ−η∂L∂θ\theta \leftarrow \theta - \eta \frac{\partial L}{\partial \theta} automatically handles this via the flip rule.
  5. TRAP: chain of flips: applying the flip rule twice (multiplying by two negatives, i.e., a positive) returns to the original direction.

Track each sign change explicitly to avoid accumulated errors in multi-step derivations.

Step-by-step calculation (tiny example)

Task: convert −3x>12-3x > 12 to a form with xx isolated.

Step 1: Identify the current state −3x>12-3x > 12. The coefficient of xx is −3<0-3 < 0.

Step 2: Divide both sides by −3-3 Dividing by −3<0-3 < 0 flips the inequality direction. −3x−3<12−3\frac{-3x}{-3} < \frac{12}{-3}.

Step 3: Simplify x<−4x < -4.

Step 4: Verify with a specific value Take x=−5<−4x = -5 < -4. Check original: −3(−5)=15>12-3(-5) = 15 > 12. Take x=−3>−4x = -3 > -4. Check original: −3(−3)=9≯12-3(-3) = 9 \not> 12, so it is correctly excluded.

Step 5: Contrast with positive coefficient If the problem were 3x>123x > 12: dividing by 3>03 > 0 gives x>4x > 4 (direction preserved). The difference is purely the sign of the divisor.

Code examples

Beginner example (Python)

python
# Inequality flip when multiplying/dividing by a negative number
import numpy as np

def multiply_inequality(a: float, b: float, m: float) -> dict:
    """ Multiply both sides of a > b by m and check if direction is preserved. Args: a: Left-hand side value (a > b assumed). b: Right-hand side value. m: Multiplier. Returns: Dictionary with original and transformed inequality info. """
    assert a > b, "Requires a > b"
    am, bm = a * m, b * m
    return { "original": f"{a} > {b}", "multiplier": m, "transformed": f"{am:.4f} {'>' if am > bm else '<' if am < bm else '='} {bm:.4f}", "flipped": m < 0, "am_gt_bm": am > bm, }   # Demonstrate the rule
print("Inequality flip: a > b and m < 0 → am < bm")
a, b = 5.0, 2.0
cases = [3.0, 1.0, -1.0, -3.0, 0.5, -0.5]
for m in cases:
    result = multiply_inequality(a, b, m)
print(f" m={m:5.1f}: {result['original']} → {result['transformed']} " f"(flipped: {result['flipped']})")   # Solving -3x > 12
print("\nSolving -3x > 12:")
print(" Divide by -3 (negative) → flip direction: x < 12/(-3) = -4")
x_vals = [-6.0, -5.0, -4.0, -3.0, -2.0]
for x in x_vals:
    lhs = -3 * x
in_sol = x < -4
lhs_ok = lhs > 12
print(f" x={x:5.1f}: -3x={lhs:7.1f} satisfies original (-3x>12): {lhs_ok} " f"satisfies solution (x<-4): {in_sol} consistent: {lhs_ok == in_sol}")   # Minimization to maximization (the most common flip in ML)
print("\nMin f = Max(-f):")

def f(x: np.ndarray) -> np.ndarray:
    """Quadratic: f(x) = (x-3)^2 + 1."""
    return (x - 3) ** 2 + 1
x_grid = np.linspace(0, 6, 100)
f_vals = f(x_grid)
neg_f = -f_vals
min_f_idx = np.argmin(f_vals)
max_neg_f_idx = np.argmax(neg_f)
print(f" argmin f(x): x = {x_grid[min_f_idx]:.4f} (f = {f_vals[min_f_idx]:.4f})")
print(f" argmax (-f(x)): x = {x_grid[max_neg_f_idx]:.4f} (-f = {neg_f[max_neg_f_idx]:.4f})")
print(f" Same location: {abs(x_grid[min_f_idx] - x_grid[max_neg_f_idx]) < 0.1}")

Beginner example (R)

r
# Inequality flip in R: multiply/divide by negative → reverse direction # Demonstrate
cat("Inequality flip: a > b, m < 0 → am < bm\n")
a_val <- 5; b_val <- 2
multipliers <- c(3, 1, -1, -3, 0.5, -0.5)
for (m in multipliers) { am <- a_val * m; bm <- b_val * m
  direction <- ifelse(am > bm, ">", ifelse(am < bm, "<", "="))
  cat(sprintf(" m=%5.1f: %d > %d → %.2f %s %.2f (flipped: %s)\n", m, a_val, b_val, am, direction, bm, m < 0))
}  # Solve -3x > 12
cat("\nSolve -3x > 12: x < -4 (flip on dividing by -3)\n")
for (x in c(-6, -5, -4, -3, -2)) { lhs <- -3 * x
  in_sol <- x < -4
  cat(sprintf(" x=%2d: -3x=%4d > 12: %s x<-4: %s consistent: %s\n", x, lhs, lhs > 12, in_sol, (lhs > 12) == in_sol))
}

Professional example (Python)

python
import numpy as np
import pandas as pd   # Scenario: LP standard form conversion and gradient descent direction analysis
# Demonstrates inequality flip rule in two common DA/DS contexts
np.random.seed(42)   # Part 1: LP constraint conversion (>= to <=)
print("LP Standard Form: a^T x >= b → (-a)^T x <= -b (flip when multiplying by -1)")
print("=" * 68)
constraints_ge = [ {"name": "min return", "coeffs": [0.06, 0.04, 0.08], "rhs": 0.05}, {"name": "max risk", "coeffs": [-0.02, -0.03, -0.01], "rhs": -0.025}, {"name": "budget", "coeffs": [1.0, 1.0, 1.0], "rhs": 1.0},
]
rows = []
for c in constraints_ge:
    coeffs_neg = [-v for v in c["coeffs"]]
rhs_neg = -c["rhs"]
rows.append({ "constraint": c["name"], "original_form": f"[{', '.join(f'{v:.2f}' for v in c['coeffs'])}]·x >= {c['rhs']:.3f}", "standard_form": f"[{', '.join(f'{v:.2f}' for v in coeffs_neg)}]·x <= {rhs_neg:.3f}", "flip_applied": True, })
lp_df = pd.DataFrame(rows)
print(lp_df.to_string(index=False))   # Part 2: gradient descent sign analysis
print("\n\nGradient descent: update = theta - eta * grad")
print("grad < 0 → theta increases (positive step), grad > 0 → theta decreases (negative step)")
print("-" * 68)

def quadratic_gradient(theta: float, mu: float = 3.0) -> float:
    """Gradient of f(theta) = (theta - mu)^2: f'(theta) = 2*(theta - mu)."""
    return 2 * (theta - mu)
LEARNING_RATE = 0.1
MU = 3.0
theta_vals = np.array([0.5, 1.5, 2.5, 3.0, 3.5, 4.5, 5.5])
rows_gd = []
for theta in theta_vals:
    grad = quadratic_gradient(theta, MU)
update = -LEARNING_RATE * grad   # flip: negative gradient → positive update
theta_new = theta + update
rows_gd.append({ "theta": round(theta, 2), "gradient": round(grad, 4), "update": round(update, 4), "theta_new": round(theta_new, 4), "grad_sign": "negative (move right)" if grad < 0 else "positive (move left)" if grad > 0 else "zero (at min)", })
gd_df = pd.DataFrame(rows_gd)
print(gd_df.to_string(index=False))
print(f"\nConclusion: update = -eta * grad implements the flip rule.")
print(f" When grad < 0: update > 0 → theta increases (moves toward minimum at {MU})")
print(f" When grad > 0: update < 0 → theta decreases (moves toward minimum at {MU})")

Professional example (R)

r
# Gradient descent:
update = -eta * grad (flip when multiplying by negative)
MU <- 3.0
eta <- 0.1
thetas <- c(0, 1, 2, 4, 5)
rows <- lapply(thetas, function(theta) { grad <- 2 * (theta - MU) update <- -eta * grad data.frame(theta = theta, grad = grad, update = update, direction = if (grad < 0) "increase" else "decrease")
})
gd_df <- do.call(rbind, rows)
cat("Gradient descent: update = -eta * grad\n")
print(gd_df)
cat("When grad < 0: update > 0 → theta increases toward minimum.\n")

Source: 1300 p. 22

#algebra#powers-roots-and-inequalities#equations-and-inequalities

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close