BRAGA

02 Writing02-02 Notes02-02-097

Power

Published 16 Apr 202612 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
log⁡a(xn)=nlog⁡ax\log_a(x^n) = n \log_a x
(1)

Deep Breakdown

What it tells me (Situation Awareness): The power rule for logarithms states that the exponent nn inside the argument of a log can be moved outside as a coefficient: log⁡a(xn)=nlog⁡ax\log_a(x^n) = n \log_a x. This is the single most frequently used log identity in statistics and machine learning. Key applications: (1) the log-likelihood of the normal distribution involves ln⁡(σ2)=2ln⁡σ\ln(\sigma^2) = 2\ln\sigma and ln⁡(σ−n)=−nln⁡σ\ln(\sigma^{-n}) = -n\ln\sigma; (2) the maximum likelihood estimator for variance involves ∂ln⁡σ/∂σ2\partial \ln\sigma / \partial \sigma^2, simplified via ln⁡(σ2)=2ln⁡σ⇒∂/∂(σ2)=1/σ2\ln(\sigma^2) = 2\ln\sigma \Rightarrow \partial/\partial(\sigma^2) = 1/\sigma^2; (3) in information theory, the Rényi entropy of order α\alpha uses ln⁡(∑ipiα)\ln(\sum_i p_i^\alpha); (4) in computing ln⁡(det⁡ A)=∑iln⁡λi\ln(\det\,\mathbf{A}) = \sum_i \ln\lambda_i for a PSD matrix (log-sum of eigenvalues), each λi\lambda_i may itself be a power; (5) the Box-Cox transformation is (xλ−1)/λ(x^\lambda - 1)/\lambda for λ≠0\lambda \ne 0, and ln⁡x\ln x as λ→0\lambda \to 0, which uses the power rule in deriving the limit; (6) combining terms: nln⁡x=ln⁡(xn)n\ln x = \ln(x^n) is used in reverse to collapse sums back into single log arguments. The rule also implies ln⁡x=ln⁡(x1/2)=(1/2)ln⁡x\ln\sqrt{x} = \ln(x^{1/2}) = (1/2)\ln x, and ln⁡(1/x)=ln⁡(x−1)=−ln⁡x\ln(1/x) = \ln(x^{-1}) = -\ln x (reciprocal rule).

Flowchart

log_a(x^n) = n *log_a(x) —power ruleProof: letlog_a(x) = p, sox = a^p. Thenx^n = a^(np).Taking log_a:log_a(x^n) = npExponent nmoves frominside to outsideas coefficientSpecial casen=1/2: ln(sqrt(x))= (1/2)*ln(x)Special casen=-1: ln(1/x) =-ln(x) —reciprocal ruleSpecial casen=2: ln(sigma^2)= 2*ln(sigma) —used inGaussianlog-likelihoodDA: normallog-likelihoodsimplification:ln(1/sigma^n) =-n*ln(sigma)DA: reversedirection: n*ln(x)= ln(x^n) —collapse sumsinto single logTRAP: appliesto theARGUMENTraised to apower, NOT thebaseTRAPCONTRAST:log_{a^n}(x) =(1/n)*log_a(x) —that is thebase-power rule

Real-world use

Where it is used

Gaussian log-likelihood: ln⁡f(x;μ,σ)=−12ln⁡(2πσ2)−(x−μ)22σ2\ln f(x;\mu,\sigma) = -\frac{1}{2}\ln(2\pi\sigma^2) - \frac{(x-\mu)^2}{2\sigma^2}. Expanding: −12ln⁡(2π)−12ln⁡(σ2)=−12ln⁡(2π)−ln⁡σ-\frac{1}{2}\ln(2\pi) - \frac{1}{2}\ln(\sigma^2) = -\frac{1}{2}\ln(2\pi) - \ln\sigma, using ln⁡(σ2)=2ln⁡σ\ln(\sigma^2) = 2\ln\sigma. For nn observations: ln⁡L=−n2ln⁡(2π)−nln⁡σ−12σ2∑(xi−μ)2\ln L = -\frac{n}{2}\ln(2\pi) - n\ln\sigma - \frac{1}{2\sigma^2}\sum(x_i - \mu)^2. The power rule turns ln⁡(σ2)\ln(\sigma^2) into 2ln⁡σ2\ln\sigma, making MLE differentiation straightforward. Combining log terms: multiple log terms like 3ln⁡x+2ln⁡y=ln⁡(x3y2)3\ln x + 2\ln y = \ln(x^3 y^2) (reverse power + product rule), simplifying expressions in gradient descent derivations.

Problem it solves

Without the power rule, expressions like ln⁡(σ−n)\ln(\sigma^{-n}) would require treating them as ln⁡\ln of a complex fraction, applying the quotient rule, and then additional algebra. With the power rule: ln⁡(σ−n)=−nln⁡σ\ln(\sigma^{-n}) = -n\ln\sigma directly, one step.

How it solves the problem

Proof: let log⁡ax=p\log_a x = p, so x=apx = a^p by definition. Then xn=(ap)n=anpx^n = (a^p)^n = a^{np}. Taking log⁡a\log_a of both sides: log⁡a(xn)=log⁡a(anp)=np=n⋅log⁡ax\log_a(x^n) = \log_a(a^{np}) = np = n \cdot \log_a x. The key step is (ap)n=anp(a^p)^n = a^{np} — the power of a power rule for exponents.

Example in a business

A data scientist is computing the MLE for the standard deviation σ\sigma of a Gaussian model of customer spending. The log-likelihood includes −n2ln⁡σ2-\frac{n}{2}\ln\sigma^2. They apply the power rule: ln⁡σ2=2ln⁡σ\ln\sigma^2 = 2\ln\sigma, giving −nln⁡σ-n\ln\sigma. Differentiating with respect to σ\sigma: ∂(−nln⁡σ)/∂σ=−n/σ\partial(-n\ln\sigma)/\partial\sigma = -n/\sigma. Setting to zero and combining with the other derivative term gives σ^2=1n∑(xi−μ^)2\hat{\sigma}^2 = \frac{1}{n}\sum(x_i - \hat{\mu})^2. Without the power rule, the differentiation would require the chain rule through σ2\sigma^2, adding an unnecessary layer.

The formula, piece by piece

Breaking the notation:

  • log⁡a\log_a: logarithm base aa — the function applied to the argument xnx^n.
  • xnx^n: argument — xx raised to the power nn. Requires x>0x > 0 (since log⁡a\log_a needs positive argument).
  • nn: the exponent — moves from the argument to a coefficient. Can be any real number: integer, fraction, negative.
  • nlog⁡axn \log_a x: the result — nn times the log of the base argument xx. Special cases:
  • n=1/2n = 1/2: ln⁡x=ln⁡(x1/2)=12ln⁡x\ln\sqrt{x} = \ln(x^{1/2}) = \frac{1}{2}\ln x. Used in the square-root transformation of variances.
  • n=−1n = -1: ln⁡(1/x)=ln⁡(x−1)=−ln⁡x\ln(1/x) = \ln(x^{-1}) = -\ln x. The reciprocal rule — used in log-odds, likelihood ratios.
  • n=2n = 2: ln⁡(x2)=2ln⁡x\ln(x^2) = 2\ln x for x>0x > 0. Used in variance log-parameterization.
  • n=0n = 0: ln⁡(x0)=ln⁡(1)=0=0⋅ln⁡x\ln(x^0) = \ln(1) = 0 = 0 \cdot \ln x.

Trivially consistent. Reverse direction (equally important): nln⁡x=ln⁡(xn)n\ln x = \ln(x^n). Used to combine separate log terms back into a single argument. TRAP: confuse with the base-power rule: log⁡an(x)=1nlog⁡ax\log_{a^n}(x) = \frac{1}{n}\log_a x is a different identity. The power rule log⁡a(xn)=nlog⁡ax\log_a(x^n) = n\log_a x moves the exponent of the argument; the base-power rule moves the exponent of the base. Common confusion in entropy-base conversion problems. TRAP: xnx^n requires x>0x > 0 for fractional nn: if n=1/2n = 1/2 and x<0x < 0, x1/2x^{1/2} is not real. The rule always requires x>0x > 0.

The formula in words

"log⁡a(xn)=nlog⁡ax\log_a(x^n) = n\log_a x: the exponent on xx moves out to become a multiplier on the log. In plain language: 'log of xx to the nn' equals 'nn times log of xx'. Reverse: 'nn times log of xx' equals 'log of xx to the nn'. Use this to: pull exponents out of log arguments (simplify), push coefficients in to create a single log argument (combine). Dominant use: simplify log-likelihoods of Gaussian, exponential, and power-law distributions."

Critical Concepts

  1. Exponent moves to coefficient: log⁡a(xn)=nlog⁡ax\log_a(x^n) = n\log_a x. The power nn goes from inside the argument to outside as a multiplicative factor. The reverse is equally important: nlog⁡ax=log⁡a(xn)n\log_a x = \log_a(x^n).
  2. Reciprocal rule is a special case: ln⁡(1/x)=ln⁡(x−1)=−ln⁡x\ln(1/x) = \ln(x^{-1}) = -\ln x. This is the n=−1n = -1 case. It is used constantly in likelihood ratios, entropy terms, and KL divergence.
  3. Gaussian MLE: the normal log-likelihood −n2ln⁡(2πσ2)=−n2ln⁡(2π)−nln⁡σ-\frac{n}{2}\ln(2\pi\sigma^2) = -\frac{n}{2}\ln(2\pi) - n\ln\sigma uses the power rule to split σ2\sigma^2 as 2ln⁡σ2\ln\sigma. This separates the σ\sigma-dependent term for clean differentiation.
  4. Contrast with base-power rule: log⁡a(xn)=nlog⁡ax\log_a(x^n) = n\log_a x (argument power). log⁡an(x)=1nlog⁡ax\log_{a^n}(x) = \frac{1}{n}\log_a x (base power). These look similar but behave oppositely: argument power multiplies, base power divides.
  5. No analog for sums: log⁡a((x+y)n)=nlog⁡a(x+y)\log_a((x+y)^n) = n\log_a(x+y) — this is fine (the whole sum is raised to nn).

But log⁡a(xn+yn)≠n(log⁡ax+log⁡ay)\log_a(x^n + y^n) \ne n(\log_a x + \log_a y) — sum of powers inside is NOT the same as power of sum.

Step-by-step calculation (tiny example)

Task: simplify ln⁡(σ−5)\ln(\sigma^{-5}) and evaluate at σ=2\sigma = 2.

Step 1: Recognize the power form σ−5\sigma^{-5} is σ\sigma raised to the power n=−5n = -5.

Step 2: Apply the power rule ln⁡(σ−5)=−5⋅ln⁡σ\ln(\sigma^{-5}) = -5 \cdot \ln\sigma.

Step 3: Evaluate at σ=2\sigma = 2 −5⋅ln⁡2=−5×0.6931=−3.4657-5 \cdot \ln 2 = -5 \times 0.6931 = -3.4657.

Step 4: Verify directly σ−5=2−5=1/32=0.03125\sigma^{-5} = 2^{-5} = 1/32 = 0.03125. ln⁡(0.03125)≈−3.4657\ln(0.03125) \approx -3.4657.

Step 5: Reverse direction — combine 3ln⁡2+2ln⁡33\ln 2 + 2\ln 3 3ln⁡2=ln⁡(23)=ln⁡83\ln 2 = \ln(2^3) = \ln 8. 2ln⁡3=ln⁡(32)=ln⁡92\ln 3 = \ln(3^2) = \ln 9. Sum: ln⁡8+ln⁡9=ln⁡(8×9)=ln⁡72≈4.2767\ln 8 + \ln 9 = \ln(8 \times 9) = \ln 72 \approx 4.2767. Verify: 3×0.6931+2×1.0986=2.0794+2.1972=4.27663 \times 0.6931 + 2 \times 1.0986 = 2.0794 + 2.1972 = 4.2766.

Code examples

Beginner example (Python)

python
# Power rule for logs: log_a(x^n) = n * log_a(x)
import math
import numpy as np


def log_power_rule(x: float, n: float, base: float = math.e) -> float:
    """
    Apply the power rule: log_base(x^n) = n * log_base(x).

    Args:
        x: Argument (x > 0).
        n: Exponent (any real number).
        base: Logarithm base (default: e for natural log).

    Returns:
        n * log_base(x).
    """
    return n * math.log(x, base)


# Verify rule: log_a(x^n) vs direct computation math.log(x**n, a)
test_cases = [
    (4.0, 2.0, math.e),    # ln(16) = 2*ln(4)
    (2.0, 3.0, 2.0),       # log_2(8) = 3
    (5.0, -1.0, math.e),   # ln(1/5) = -ln(5)
    (9.0, 0.5, math.e),    # ln(3) = 0.5*ln(9)
    (2.0, 5.0, 10.0),      # log10(32) = 5*log10(2)
]
print("Power rule: log_a(x^n) = n * log_a(x)")
print(f"{'x':>6} {'n':>5} {'base':>6} {'direct':>10} {'rule':>10} {'match':>6}")
for x, n, base in test_cases:
    direct = math.log(x**n, base)
    rule = log_power_rule(x, n, base)
    print(f"{x:>6.2f} {n:>5.1f} {base:>6.4f} {direct:>10.6f} {rule:>10.6f} {str(abs(direct - rule) < 1e-10):>6}")

# Special cases
print("\nSpecial cases:")
x = 4.0
print(f" Reciprocal: ln(1/{x}) = -ln({x}) = {math.log(1/x):.6f} = {-math.log(x):.6f}")
print(f" Sqrt: ln(sqrt({x})) = 0.5*ln({x}) = {math.log(math.sqrt(x)):.6f} = {0.5*math.log(x):.6f}")
print(f" Square: ln({x}^2) = 2*ln({x}) = {math.log(x**2):.6f} = {2*math.log(x):.6f}")

# Reverse direction: combine n*ln(x) → ln(x^n)
print("\nReverse: combine 3*ln(2) + 2*ln(3) = ln(2^3 * 3^2) = ln(72)")
combined = 3 * math.log(2) + 2 * math.log(3)
direct = math.log(72)
print(f" Computed: {combined:.6f} Direct: {direct:.6f} Match: {abs(combined - direct) < 1e-10}")

# Gaussian log-likelihood simplification
print("\nGaussian log-likelihood: -n*ln(sigma) from ln(sigma^(-n))")
sigma = 2.5
n = 100
direct_term = math.log(sigma**(-n))
rule_term = -n * math.log(sigma)
print(f" sigma={sigma}, n={n}: ln(sigma^(-n))={direct_term:.6f} -n*ln(sigma)={rule_term:.6f} match={abs(direct_term - rule_term) < 1e-9}")

Beginner example (R)

r
# Power rule in R: log_a(x^n) = n * log_a(x)
log_power_rule <- function(x, n, base = exp(1)) {
  n * log(x, base = base)
}

# Verify
test_cases <- list(
  c(x=4, n=2, base=exp(1)),
  c(x=2, n=3, base=2),
  c(x=5, n=-1, base=exp(1)),
  c(x=9, n=0.5, base=exp(1))
)
cat(sprintf("%-6s %-5s %-8s %-10s %-10s %s\n", "x", "n", "base", "direct", "rule", "match"))
for (tc in test_cases) {
  x <- tc["x"]; n <- tc["n"]; base <- tc["base"]
  direct <- log(x^n, base = base)
  rule <- log_power_rule(x, n, base)
  cat(sprintf("%-6.2f %-5.1f %-8.4f %-10.6f %-10.6f %s\n", x, n, base, direct, rule, abs(direct - rule) < 1e-10))
}

# Gaussian simplification
sigma <- 2.5; n_obs <- 100
direct_ll_term <- log(sigma^(-n_obs))
rule_ll_term <- -n_obs * log(sigma)
cat(sprintf("\nGaussian: ln(sigma^(-n)) = -n*ln(sigma)\n"))
cat(sprintf(" direct=%.6f rule=%.6f match=%s\n", direct_ll_term, rule_ll_term, abs(direct_ll_term - rule_ll_term) < 1e-9))

Professional example (Python)

python
import numpy as np
import pandas as pd
import math
from typing import NamedTuple

# Scenario: compute and decompose the normal log-likelihood using the power rule
# Demonstrates how ln(sigma^2) = 2*ln(sigma) and ln(sigma^{-n}) = -n*ln(sigma)
# simplify the MLE derivation and gradient computation
np.random.seed(42)
N_OBS = 200
TRUE_MU = 5.0
TRUE_SD = 2.0
data = np.random.normal(TRUE_MU, TRUE_SD, N_OBS)


class NormalLogLikelihood(NamedTuple):
    """Components of the normal log-likelihood, separated using the power rule."""
    constant_term: float   # -(n/2)*ln(2*pi)
    sigma_term: float      # -n*ln(sigma) via power rule: ln(sigma^{-n}) = -n*ln(sigma)
    residual_term: float   # -(1/(2*sigma^2)) * sum((xi - mu)^2)
    total: float           # sum of all terms


def compute_normal_log_likelihood(
    data: np.ndarray,
    mu: float,
    sigma: float,
) -> NormalLogLikelihood:
    """
    Compute the decomposed normal log-likelihood.

    Applies power rule:
        ln(sigma^{-n}) = -n*ln(sigma)   [n = len(data)]
        ln((2*pi*sigma^2)^{-n/2}) = -(n/2)*ln(2*pi) - n*ln(sigma)

    Args:
        data: Observed data array.
        mu: Mean parameter.
        sigma: Standard deviation parameter (sigma > 0).

    Returns:
        NormalLogLikelihood with decomposed terms and total.
    """
    n = len(data)
    constant_term = -(n / 2) * math.log(2 * math.pi)
    sigma_term = -n * math.log(sigma)   # power rule: ln(sigma^{-n}) = -n*ln(sigma)
    residual_term = -0.5 * np.sum((data - mu) ** 2) / sigma**2
    total = constant_term + sigma_term + residual_term
    return NormalLogLikelihood(constant_term, sigma_term, residual_term, total)


# Evaluate MLE grid
sigma_grid = np.linspace(0.5, 5.0, 80)
mu_hat = data.mean()   # MLE for mu = sample mean
results = [compute_normal_log_likelihood(data, mu_hat, s) for s in sigma_grid]
totals = np.array([r.total for r in results])
best_sigma = sigma_grid[np.argmax(totals)]
best_ll = results[np.argmax(totals)]

# Power rule verification: ln(sigma^2) vs 2*ln(sigma)
power_check = pd.DataFrame({
    "sigma": sigma_grid[::10].round(3),
    "ln(sigma^2)": np.log(sigma_grid[::10] ** 2).round(6),
    "2*ln(sigma)": (2 * np.log(sigma_grid[::10])).round(6),
    "difference": (np.log(sigma_grid[::10]**2) - 2*np.log(sigma_grid[::10])).round(12),
})
print("Normal log-likelihood with power rule: ln(sigma^{-n}) = -n*ln(sigma)")
print("=" * 68)
print(f" MLE mu: {mu_hat:.4f} (true: {TRUE_MU:.4f})")
print(f" MLE sigma (grid): {best_sigma:.4f} (true: {TRUE_SD:.4f})")
print(f" Sample std: {data.std(ddof=1):.4f}")
print(f"\nDecomposed log-likelihood at MLE sigma={best_sigma:.4f}:")
print(f" constant term (-(n/2)*ln(2pi)): {best_ll.constant_term:.4f}")
print(f" sigma term (-n*ln(sigma)): {best_ll.sigma_term:.4f}")
print(f" residual term: {best_ll.residual_term:.4f}")
print(f" total: {best_ll.total:.4f}")
print(f"\nPower rule verification: ln(sigma^2) = 2*ln(sigma)")
print(power_check.to_string(index=False))

Professional example (R)

r
# ln(sigma^2) = 2*ln(sigma) (power rule)
set.seed(42)
sigmas <- c(0.5, 1, 2, 5)
power_check <- data.frame(sigma = sigmas, ln_sigma_sq = log(sigmas^2), two_ln_sigma = 2*log(sigmas), match = abs(log(sigmas^2) - 2*log(sigmas)) < 1e-10)
cat("Power rule: ln(sigma^2) = 2*ln(sigma)\n")
print(power_check)

Source: 1300 p. 20

#algebra#exponentials-and-logarithms#definition-and-properties

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