BRAGA

02 Writing02-02 Notes02-02-292

Affine Power Rule

Published 16 Apr 20268 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
∫(ax+b)n dx=(ax+b)n+1a(n+1)+C\int (ax+b)^n\,dx = \frac{(ax+b)^{n+1}}{a(n+1)} + C
(1)

Deep Breakdown

What it tells me (Situation Awareness): The affine power rule is the power rule extended to a linear argument: instead of integrating xnx^n, we integrate a shifted and scaled version (ax+b)n(ax+b)^n. The key change is the extra factor of 1a\frac{1}{a} in the denominator, which compensates for the chain rule: differentiating (ax+b)n+1(ax+b)^{n+1} brings out a factor of aa from the inside. In DA/DS, this rule appears whenever you integrate polynomial models built on shifted inputs: kernel density estimation with shifted bandwidth, computing areas under polynomial regression segments centered at non-zero points, integrating polynomial basis functions in spline models, and evaluating reliability functions of the form (1−λt)n(1 - \lambda t)^n.

Flowchart

YesNoIntegral: int(ax+b)^n dxn = -1?Use reciprocallog rule:(1/a)*ln|ax+b| +CIdentify a, b, nIncrementexponent: nbecomes n+1Divide by newexponent ANDby innerderivative aResult:(ax+b)^(n+1) /(a*(n+1)) + CVerify: d/dx [...] =(ax+b)^n

Real-world use

Where it is used

Whenever the integrand is a power of a linear expression ax+bax+b: polynomial regression with shifted features, evaluating spline basis integrals, computing areas under shifted parabolic segments, normalizing shifted polynomial density approximations, reliability theory (time-to-failure integrals).

Problem it solves

The plain power rule ∫un du=un+1/(n+1)\int u^n\,du = u^{n+1}/(n+1) assumes the argument is exactly xx (or a simple uu-substitution variable). When the argument is ax+bax+b, the substitution u=ax+bu = ax+b, du=a dxdu = a\,dx, so dx=du/adx = du/a, introduces the compensating factor 1/a1/a. The affine power rule packages this substitution into a single formula.

How it solves the problem

Let u=ax+bu = ax+b, so du=a dxdu = a\,dx, meaning dx=1adudx = \frac{1}{a}du.

Then:

∫(ax+b)n dx=∫un⋅dua=1a⋅un+1n+1+C=(ax+b)n+1a(n+1)+C\int (ax+b)^n\,dx = \int u^n\cdot\frac{du}{a} = \frac{1}{a}\cdot\frac{u^{n+1}}{n+1} + C = \frac{(ax+b)^{n+1}}{a(n+1)} + C
(2)

The factor 1/a1/a comes from the chain rule compensation. Verification: ddx ⁣[(ax+b)n+1a(n+1)]=(n+1)(ax+b)n⋅aa(n+1)=(ax+b)n\frac{d}{dx}\!\left[\frac{(ax+b)^{n+1}}{a(n+1)}\right] = \frac{(n+1)(ax+b)^n \cdot a}{a(n+1)} = (ax+b)^n

Example in a business

A polynomial regression model predicts revenue using a centered feature: y^=(2x−5)3\hat{y} = (2x - 5)^3 where xx is a normalized price index. To compute total predicted revenue over x∈[2,4]x \in [2, 4], we integrate: ∫24(2x−5)3 dx=[(2x−5)42⋅4]24=348−(−1)48=81−18=10\int_2^4 (2x-5)^3\,dx = \left[\frac{(2x-5)^4}{2 \cdot 4}\right]_2^4 = \frac{3^4}{8} - \frac{(-1)^4}{8} = \frac{81-1}{8} = 10.

The formula, piece by piece

∫(ax+b)n dx=(ax+b)n+1a(n+1)+C\int (ax+b)^n\,dx = \frac{(ax+b)^{n+1}}{a(n+1)} + C
(3)

Each symbol:

  • (ax+b)(ax+b): the affine (linear) inner function; aa is the slope, bb is the intercept
  • aa: the coefficient of xx inside the brackets; appears in the denominator as the chain rule compensation
  • nn: the outer exponent, any real number except −1-1
  • (ax+b)n+1(ax+b)^{n+1}: the inner function raised to the incremented exponent
  • a(n+1)a(n+1): two-part denominator: aa from the chain rule, n+1n+1 from the power rule
  • CC: constant of integration When b=0b = 0: reduces to ∫(ax)n dx=(ax)n+1a(n+1)+C=anxn+1n+1+C\int (ax)^n\,dx = \frac{(ax)^{n+1}}{a(n+1)} + C = \frac{a^n x^{n+1}}{n+1} + C. When a=1a = 1: reduces to the plain shift ∫(x+b)n dx=(x+b)n+1n+1+C\int (x+b)^n\,dx = \frac{(x+b)^{n+1}}{n+1} + C.

The formula in words

"To integrate a linear expression raised to the power nn: raise the exponent by one and divide by the new exponent (exactly as in the basic power rule), but additionally divide by the coefficient aa of xx inside the brackets. The 1/a1/a factor compensates for the chain rule that would appear when differentiating the result."

Critical Concepts

  • Chain rule compensation: the 1/a1/a denominator factor is the exact correction for the aa that differentiation of (ax+b)(ax+b) would produce.
  • Derivation = u-substitution: this formula is shorthand for u=ax+bu = ax+b, du=a dxdu = a\,dx.
  • Case n=−1n = -1: yields ∫1ax+b dx=1aln⁡∣ax+b∣+C\int \frac{1}{ax+b}\,dx = \frac{1}{a}\ln|ax+b| + C (Reciprocal Logarithmic rule).
  • Verify always: differentiate the result to confirm the chain rule was handled correctly.
  • Definite integral: ∫αβ(ax+b)n dx=[(ax+b)n+1a(n+1)]αβ\int_{\alpha}^{\beta} (ax+b)^n\,dx = \left[\frac{(ax+b)^{n+1}}{a(n+1)}\right]_\alpha^\beta.

Step-by-step calculation (tiny example)

Compute ∫(3x+2)4 dx\int (3x+2)^4\,dx.

Step 1: Identify a, b, n a=3a = 3, b=2b = 2, n=4n = 4. Not −1-1, so formula applies.

Step 2: Apply the formula n+1=5n + 1 = 5. Result: (3x+2)53⋅5+C=(3x+2)515+C\frac{(3x+2)^5}{3 \cdot 5} + C = \frac{(3x+2)^5}{15} + C.

Step 3: Verify by differentiating ddx ⁣[(3x+2)515]=5(3x+2)4⋅315=15(3x+2)415=(3x+2)4\frac{d}{dx}\!\left[\frac{(3x+2)^5}{15}\right] = \frac{5(3x+2)^4 \cdot 3}{15} = \frac{15(3x+2)^4}{15} = (3x+2)^4

Step 4: Evaluate a definite example ∫01(3x+2)4 dx=[(3x+2)515]01=5515−2515=3125−3215=309315=206.2\int_0^1 (3x+2)^4\,dx = \left[\frac{(3x+2)^5}{15}\right]_0^1 = \frac{5^5}{15} - \frac{2^5}{15} = \frac{3125 - 32}{15} = \frac{3093}{15} = 206.2

Code examples

Beginner example (Python)

python
import numpy as np
from scipy import integrate

def affine_power_antiderivative(x: float, a: float, b: float, n: float) -> float:
    """F(x) = (ax+b)^(n+1) / (a*(n+1)). Undefined for n=-1 or a=0."""
    if abs(n + 1) < 1e-12:
        raise ValueError("n = -1: use (1/a)*ln|ax+b| instead.")
    if abs(a) < 1e-12:
        raise ValueError("a = 0: reduces to constant, not affine.")
    return (a * x + b) ** (n + 1) / (a * (n + 1))

def affine_power_definite(lo: float, hi: float, a: float, b: float, n: float) -> float:
    """int_lo^hi (ax+b)^n dx = F(hi) - F(lo)."""
    return (affine_power_antiderivative(hi, a, b, n) - affine_power_antiderivative(lo, a, b, n))


# Test cases
cases = [
    (0, 1, 3.0, 2.0, 4.0),    # int (3x+2)^4 from 0 to 1
    (0, 2, 2.0, 0.0, 3.0),    # int (2x)^3 from 0 to 2
    (1, 3, 1.0, -1.0, 2.0),   # int (x-1)^2 from 1 to 3
]
for lo, hi, a, b, n in cases:
    analytic = affine_power_definite(lo, hi, a, b, n)
    numerical, _ = integrate.quad(lambda x, aa=a, bb=b, nn=n: (aa*x+bb)**nn, lo, hi)
    print(f"int_({lo},{hi}) ({a}x+{b})^{n}: "
          f"analytic={analytic:.6f}, numerical={numerical:.6f}, "
          f"match={abs(analytic-numerical)<1e-8}")

Beginner example (R)

r
affine_power_antiderivative <- function(x, a, b, n) {
  if (abs(n + 1) < 1e-12) stop("n = -1: use (1/a)*ln|ax+b| rule.")
  if (abs(a) < 1e-12) stop("a = 0: not affine.")
  (a * x + b)^(n + 1) / (a * (n + 1))
}
affine_power_definite <- function(lo, hi, a, b, n) {
  affine_power_antiderivative(hi, a, b, n) - affine_power_antiderivative(lo, a, b, n)
}

# Test cases
cases <- list(c(0, 1, 3, 2, 4), c(0, 2, 2, 0, 3), c(1, 3, 1, -1, 2))
for (tc in cases) {
  lo <- tc[1]; hi <- tc[2]; a <- tc[3]; b <- tc[4]; n <- tc[5]
  analytic <- affine_power_definite(lo, hi, a, b, n)
  numerical <- integrate(function(x) (a*x+b)^n, lower=lo, upper=hi)$value
  cat(sprintf("int_(%g,%g) (%gx+%g)^%g: analytic=%.6f, num=%.6f, match=%s\n", lo, hi, a, b, n, analytic, numerical, isTRUE(all.equal(analytic, numerical, tol=1e-7))))
}

Professional example (Python)

python
"""
Affine power rule for integrating polynomial spline basis functions.

Natural cubic splines use piecewise polynomials over knot-defined intervals.
Each piece is a cubic polynomial in (x - knot_i), an affine power of degree 3.
Computing the integral of a spline (e.g., for expected value under a spline PDF)
uses the affine power rule repeatedly on each segment.

Here we fit a monotone cubic spline to a conversion rate curve and
compute the area under it over a price range.
"""
import numpy as np
from scipy import integrate
from scipy.interpolate import PchipInterpolator

# Simulated conversion rate vs. price (monotone decreasing)
price_knots = np.array([10.0, 20.0, 30.0, 40.0, 50.0, 60.0])
conv_rate = np.array([0.82, 0.71, 0.58, 0.43, 0.29, 0.17])

# Piecewise cubic hermite spline (C1-continuous, monotone)
spline = PchipInterpolator(price_knots, conv_rate)

# Goal: expected conversion rate over price range [15, 55] = (1/width) * integral
lo_price = 15.0
hi_price = 55.0
width = hi_price - lo_price

# Numerical integral of spline (affine cubics on each segment)
area, error = integrate.quad(spline, lo_price, hi_price)
expected_conversion = area / width
print(f"Price range: [{lo_price}, {hi_price}]")
print(f"Integral of spline: {area:.6f}")
print(f"Expected conversion rate: {expected_conversion:.4f}")
print(f"Integration error estimate: {error:.2e}")

# Show per-segment analytic contributions (affine power rule)
segments = list(zip(price_knots[:-1], price_knots[1:]))
print("\nPer-segment integral (spline evaluated numerically on each):")
total_check = 0.0
for seg_lo, seg_hi in segments:
    seg_area, _ = integrate.quad(spline, seg_lo, seg_hi)
    total_check += seg_area
    print(f" [{seg_lo:.0f}, {seg_hi:.0f}]: area = {seg_area:.6f}")

# The segments cover the full knot range [10, 60]
full_area, _ = integrate.quad(spline, price_knots[0], price_knots[-1])
print(f" Sum of segments: {total_check:.6f} (matches full integral: "
      f"{abs(total_check - full_area) < 1e-8})")

Source: MFB p. 206

#calculus#integral-calculus#standard-integrals

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