Contents
If , then (equality at )
Deep Breakdown
What it tells me (Situation Awareness): This is the unit form of the AM-GM (Arithmetic Mean–Geometric Mean) inequality specialized to the pair . The arithmetic mean of and is , and their geometric mean is . AM-GM states that AM ≥ GM, so , which gives , with equality exactly when , i.e., . The direct algebraic proof: . Dividing by gives . In DA/DS, this inequality appears in: (1) convexity arguments — the function is convex on with global minimum at ; (2) bounding terms in optimization — showing that a ratio and its reciprocal always sum to at least 2 is used in saddle-point analysis; (3) the softplus lower bound — (related argument); (4) deriving the AM-GM inequality for two arbitrary positive numbers and : set , getting , which gives ; (5) economic models where the ratio of two quantities (e.g., supply to demand) and its inverse both appear, bounding their combined effect.
Flowchart
Real-world use
Where it is used
Bounding regularization terms: in some formulations of elastic net regularization or ratio-based penalties, a model involves terms of the form where are positive parameters. The unit AM-GM guarantees this is always at least 2, preventing the loss from going to zero through cancellation. Ratio analysis in A/B testing: when comparing conversion rate to , the sum is always at least 2, regardless of which group performs better — this is a sanity check on symmetry.
Problem it solves
Given that two positive quantities appear as a ratio and its reciprocal in a loss or objective function, the unit AM-GM immediately gives a tight lower bound of 2, achieved only when the two quantities are equal. This tells you the minimum value of that component of the objective and where equality holds.
How it solves the problem
Starting from the always-true inequality : . Adding to both sides: . Since , divide by : . Equality holds iff , i.e., . The proof is elementary but the result is tight (the bound 2 is achieved).
Example in a business
A data scientist analyzes a pricing optimization problem where the revenue-to-cost ratio and cost-to-revenue ratio both appear in the objective. If and the objective includes , the unit AM-GM guarantees with equality when revenue equals cost (break-even). This immediately shows the minimum attainable value of without calculus, and reveals that any deviation from break-even (either profit or loss) increases .
The formula, piece by piece
Breaking the notation:
- : any positive real number ( is required).
- : the reciprocal of .
- : the sum of a number and its reciprocal.
- : the lower bound — the sum is always at least 2.
- Equality at : the unique point where , so the sum reaches exactly 2. Connection to general AM-GM for two positive terms and : let (with ). Then , giving . Multiplying both sides by : , or equivalently , which is the standard two-term AM-GM. The curve for :
- (minimum).
- .
- .
- .
- Symmetric under : . TRAP: if , the inequality reverses: for .
The proof fails at the division step because dividing by negative flips the inequality. The unit AM-GM applies only to .
The formula in words
"For any positive : plus its reciprocal is always at least 2. Minimum is exactly 2, achieved only at . Proof: , expand, divide by . Use this to: immediately bound a sum of a ratio and its inverse; identify the break-even or balanced point (where both are equal to 1); recognize convex bowl shape with minimum at . TRAP: required."
Critical Concepts
- Proof from perfect square: is the simplest path. Always nonnegative. Expanding and dividing by gives the result in two lines. This is the prototypical "subtract then square" technique for proving inequalities.
- Minimum value and location: the global minimum of on is , achieved at . This can be confirmed by calculus: ; (concave up, so is a minimum).
- Symmetry under reciprocal: — replacing with gives the same value. So , .
- Link to general AM-GM: substituting into the unit form gives , and multiplying by gives — the standard two-term AM-GM.
- Convexity implication: is strictly convex on .
This matters in optimization: any objective that includes has a unique minimum at and guarantees no local minima other than the global one.
Step-by-step calculation (tiny example)
Task: verify for and find where equality holds.
Step 1: Compute for .
Step 2: Compute for .
Step 3: Check equality condition . Verify: .
Step 4: Trace the proof for . . Dividing by : .
Code examples
Beginner example (Python)
# Unit AM-GM: x + 1/x >= 2 for x > 0, equality at
x = 1
import math
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
def unit_am_gm(x: float) -> float:
""" Compute x + 1/x and verify the AM-GM lower bound. Args: x: Positive real number (x > 0). Returns: x + 1/x. """
if x <= 0:
raise ValueError("x must be positive")
return x + 1 / x # Verify across a range of values
print("Unit AM-GM: x + 1/x >= 2")
test_vals = [0.01, 0.1, 0.5, 0.9, 1.0, 1.1, 2.0, 5.0, 10.0, 100.0]
print(f"{'x':>8} {'1/x':>8} {'x+1/x':>8} {'>=2?':>6} {'gap':>8}")
for x in test_vals:
val = unit_am_gm(x)
gap = val - 2.0
print(f"{x:>8.4f} {1/x:>8.4f} {val:>8.4f} {str(val >= 2 - 1e-12):>6} {gap:>8.6f}") # Prove via perfect square
print("\nProof via (x-1)^2 >= 0:")
for x in [0.5, 1.0, 3.0]:
sq = (x - 1) ** 2
lhs = x ** 2 + 1
rhs = 2 * x
ratio = unit_am_gm(x)
print(f" x={x}: (x-1)^2={sq:.4f} >= 0; x^2+1={lhs:.4f} >= 2x={rhs:.4f}; x+1/x={ratio:.4f} >= 2") # Symmetry: f(x) = f(1/x)
print("\nSymmetry: f(x) = f(1/x)")
for x in [2.0, 3.0, 0.25, 7.0]:
print(f" f({x}) = {unit_am_gm(x):.6f} f(1/{x}) = {unit_am_gm(1/x):.6f} equal: {abs(unit_am_gm(x) - unit_am_gm(1/x)) < 1e-10}") # TRAP: x < 0 reverses the inequality
print("\nTRAP: x < 0 reverses inequality (x + 1/x <= -2)")
for x in [-0.5, -1.0, -2.0, -5.0]:
val = x + 1/x
print(f" x={x:5.1f}: x+1/x = {val:.4f} (>= -2: {val >= -2}; <= -2: {val <= -2})")Beginner example (R)
# Unit AM-GM in R: x + 1/x >= 2 for x > 0
unit_am_gm <- function(x) { if (any(x <= 0)) stop("x must be positive") x + 1 / x
} # Verify
test_vals <- c(0.01, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0)
cat(sprintf("%-8s %-8s %-8s %s\n", "x", "1/x", "x+1/x", ">=2?"))
for (x in test_vals) { val <- unit_am_gm(x)
cat(sprintf("%-8.4f %-8.4f %-8.4f %s\n", x, 1/x, val, val >= 2 - 1e-12))
} # Proof check
cat("\nProof: (x-1)^2 >= 0\n")
for (x in c(0.5, 1.0, 3.0)) { cat(sprintf(" x=%.1f: (x-1)^2=%.4f x^2+1=%.4f 2x=%.4f x+1/x=%.4f\n", x, (x-1)^2, x^2+1, 2*x, unit_am_gm(x)))
} # Minimum at
x = 1
x_grid <- seq(0.1, 5, by=0.01)
f_vals <- unit_am_gm(x_grid)
cat(sprintf("\nMinimum of x+1/x: %.4f at x = %.4f\n", min(f_vals), x_grid[which.min(f_vals)]))Professional example (Python)
import numpy as np
import pandas as pd # Scenario: bounding a ratio-based objective in a supply-chain optimization
# where both supply/demand and demand/supply ratios appear
# Unit AM-GM gives an immediate lower bound without calculus
np.random.seed(42)
N_PRODUCTS = 50 # Simulate supply and demand for 50 products
supply = np.random.uniform(100, 500, N_PRODUCTS)
demand = np.random.uniform(80, 600, N_PRODUCTS)
def ratio_plus_reciprocal(supply: np.ndarray, demand: np.ndarray) -> np.ndarray:
""" Compute x + 1/x where x = supply / demand. By unit AM-GM: x + 1/x >= 2 for all x > 0, with equality iff supply == demand (balanced). Args: supply: Array of supply quantities (> 0). demand: Array of demand quantities (> 0). Returns: Array of supply/demand + demand/supply values (each >= 2). """
ratio = supply / demand
return ratio + 1 / ratio # equiv: supply/demand + demand/supply
def imbalance_score(supply: np.ndarray, demand: np.ndarray) -> np.ndarray:
""" Imbalance score: how far each product deviates from the AM-GM minimum. Score = (x + 1/x) - 2 >= 0, with 0 indicating perfect balance. Args: supply: Supply array. demand: Demand array. Returns: Array of imbalance scores (all >= 0). """
return ratio_plus_reciprocal(supply, demand) - 2.0
ratios = supply / demand
am_gm_values = ratio_plus_reciprocal(supply, demand)
imbalance_scores = imbalance_score(supply, demand)
report_df = pd.DataFrame({ "supply": supply[:10].round(1), "demand": demand[:10].round(1), "ratio_s_d": ratios[:10].round(4), "s_d_plus_d_s": am_gm_values[:10].round(4), "imbalance": imbalance_scores[:10].round(4), "above_2": (am_gm_values[:10] >= 2 - 1e-10),
})
print("Unit AM-GM: supply/demand + demand/supply >= 2 (equality iff balanced)")
print("=" * 72)
print(report_df.to_string(index=False))
print(f"\nAll values >= 2: {(am_gm_values >= 2 - 1e-10).all()}")
print(f"Min value: {am_gm_values.min():.6f} (theoretical minimum: 2.0)")
print(f"Mean imbalance: {imbalance_scores.mean():.4f}")
print(f"Most balanced: product #{np.argmin(imbalance_scores)+1} " f"(supply={supply[np.argmin(imbalance_scores)]:.1f}, " f"demand={demand[np.argmin(imbalance_scores)]:.1f})")
print(f"Least balanced: product #{np.argmax(imbalance_scores)+1} " f"(imbalance score = {imbalance_scores.max():.4f})")
print(f"\nAM-GM lower bound check: sum(above-min values) = " f"{(am_gm_values - 2).sum():.4f} >= 0 ({(am_gm_values - 2 >= 0).all()})")Professional example (R)
# AM-GM unit: x + 1/x >= 2 for x > 0 (supply/demand balance score)
supply <- c(50, 80, 30)
demand <- c(50, 40, 60)
am_gm_values <- supply / demand + demand / supply
imbalance_scores <- am_gm_values - 2
cat("AM-GM: supply/demand + demand/supply >= 2\n")
print(data.frame(supply = supply, demand = demand, am_gm = am_gm_values, imbalance = imbalance_scores))
cat(sprintf("Most balanced: product #%d Least: #%d\n", which.min(imbalance_scores), which.max(imbalance_scores)))Source: domain knowledge