Back to Insights
AI & Machine LearningFrom Jev’s Law to Jev in 25 Lines of Python: How Computational Limits Are Reshaping AI Code Efficiencydeep diveSeptember 23, 202612 min read

Implementing Jevons' Law: A Python Simulation of Computational Elasticity in AI Code Efficiency

Explore the counter-intuitive relationship between AI efficiency and resource usage. Learn to model Jevons' Paradox with a 25-line Python simulation and analyze its impact on GPU infrastructure planning.

T
Tamiz UddinFull-Stack Engineer

Introduction: The Paradox of Efficiency

In the world of high-performance computing and artificial intelligence, we operate under a persistent assumption: making systems more efficient reduces their total resource consumption. We optimize memory access patterns, we compress model weights, and we improve the FLOPs-per-watt ratio of our inference engines. Yet, macro-level data suggests a different reality. As LLMs become cheaper to run per token, organizations don't just use them more slightly; they deploy them at scales previously impossible, leading to a net increase in total compute demand.

This phenomenon is known as Jevons' Paradox (or Induced Demand). Originally formulated in 1865 by William Stanley Jevons regarding steam engine efficiency, the law states that if the consumption of a resource falls due to improved efficiency, the total consumption of that resource may increase. In the context of AI engineering, this translates to a critical architectural challenge: Efficiency gains are not savings; they are capacity expansions that accelerate demand curves.

This article explores how computational limits are reshaping AI code efficiency through the lens of Jevons' Law. We will not just discuss the theory; we will implement a rigorous, 25-line Python simulation that models the elasticity of demand for compute resources against efficiency gains. This allows engineers to predict infrastructure scaling requirements rather than blindly optimizing for local performance metrics.

The Technical Mechanics of Jevons' Law in AI Systems

To understand how to model this, we must first break down the variables involved in AI compute consumption.

The Efficiency-Cost Loop

Let $C$ be the cost of a unit of compute (e.g., cost per token generated, or cost per inference request). Let $Q$ be the quantity of compute consumed (e.g., total tokens processed, total GPU-hours used). Let $E$ be the efficiency factor. An improvement in efficiency means $E$ increases, causing the unit cost $C$ to decrease.

In a naive linear model, if cost decreases, total expenditure ($C \times Q$) decreases. However, Jevons' Law posits that the demand for compute $Q$ is elastic with respect to its price. When $C$ drops, $Q$ rises.

Defining Elasticity

The core of the simulation is the Price Elasticity of Demand ($\epsilon$). In economics, this is defined as the percentage change in quantity demanded divided by the percentage change in price.

$$ \epsilon = \frac{% \Delta Q}{% \Delta P} $$

For AI workloads, we need to define thresholds:

  1. Anti-Paradoxical ($\epsilon < 1$): Efficiency gains lead to reduced total consumption. This is rare for consumer-facing AI features but might apply to strictly budget-constrained internal tools.
  2. Paradoxical ($\epsilon > 1$): Efficiency gains lead to increased total consumption. This is the standard for scalable AI services. If your API cost drops by 10%, your volume might jump by 20%.
  3. Extreme Elasticity: In the AI era, because the

cost of the unit of computation (the token) approaches zero, $\epsilon$ tends toward infinity. Marginal costs vanish, which fundamentally alters the economic model of inference. In traditional microeconomics, diminishing returns eventually set in. In AI, we observe "increasing returns to scale" driven by better architectures and lower hardware costs, allowing demand to expand indefinitely without the usual physical constraints of resource depletion.

The Simulation Architecture

To model this dynamic, we need a simulation that couples a stochastic demand function with a time-varying price path. The core assumption is that demand $D_t$ at time $t$ is a function of price $P_t$ and the aggregate efficiency factor $E_t$ (which captures algorithmic improvements, better quantization, and smaller model architectures).

We define the total computational throughput (Total Consumption) as $C_t = D_t \times \text{avg_tokens_per_request}$. However, for simplicity in our Jevonsian analysis, we treat the "unit" as the token, meaning $C_t$ is simply the total number of tokens processed.

The key relationship we are simulating is: $$ D_t = A \cdot P_t^{-\epsilon} \cdot E_t^{\delta} $$ Where:

  • $A$ is the base demand constant.
  • $P_t$ is the price per token at time $t$.
  • $\epsilon$ is the price elasticity of demand.
  • $E_t$ is the efficiency multiplier (inverse of cost drivers).
  • $\delta$ is the technological progress exponent (how much efficiency gains shift the demand curve outward).

Python Implementation

Below is a robust simulation framework. It uses numpy for vectorized calculations and matplotlib for visualization. The script generates a trajectory of price decreases due to hardware advancements and algorithmic optimization, then calculates the resulting volume and total expenditure.

python
import numpy as np
import matplotlib.pyplot as plt
import warnings

warnings.filterwarnings('ignore')

def simulate_jevonsons_law(
    T: int = 50, 
    initial_price: float = 1.0, 
    price_decay: float = 0.95, 
    base_demand: float = 1000.0, 
    elasticity: float = 1.5, 
    tech_progression: float = 0.05
):
    """
    Simulates Jevons' Law in the context of AI inference costs.
    
    Parameters:
    - T: Number of time steps (e.g., quarters).
    - initial_price: Starting price per token.
    - price_decay: Annual/multi-period reduction in price (0.95 = 5% drop).
    - base_demand: Demand at P=1, E=1.
    - elasticity: Price elasticity of demand (epsilon).
    - tech_progression: Rate of exogenous efficiency gain shifting demand.
    """
    
    time_steps = np.arange(T)
    
    # 1. Calculate Price Trajectory
    # Prices decay over time due to hardware scaling (Moore's Law equivalent for AI)
    prices = initial_price * (price_decay ** time_steps)
    
    # 2. Calculate Efficiency Trajectory
    # Efficiency increases over time (better algorithms, quantization, smaller models)
    # This effectively lowers the "real" cost or allows more tasks to be performed.
    # We model this as a multiplicative shift in demand capability.
    efficiency = (1 + tech_progression) ** time_steps
    
    # 3. Calculate Demand (Volume)
    # D = A * P^-epsilon * E^delta
    # Note: In this model, 'efficiency' acts as a shifter of the demand curve.
    # If efficiency makes the product "better" or more accessible, demand rises.
    demand = base_demand * (prices ** (-elasticity)) * efficiency
    
    # 4. Calculate Total Expenditure
    # Expenditure = Price * Volume
    # This is the key metric for Jevons' Paradox.
    # If Expenditure grows while Price falls, Jevons' Law holds.
    expenditure = prices * demand
    
    # 5. Calculate Savings Paradox Ratio
    # Ratio of Expenditure to Base Expenditure
    savings_ratio = expenditure / (initial_price * base_demand)
    
    return {
        "time": time_steps,
        "prices": prices,
        "demand": demand,
        "expenditure": expenditure,
        "savings_ratio": savings_ratio
    }

def plot_simulation(results, title="Jevons' Law Simulation"):
    fig, axs = plt.subplots(3, 1, figsize=(10, 12))
    
    # Plot Price
    axs[0].plot(results["time"], results["prices"], label="Price per Token", color='blue')
    axs[0].set_ylabel("Price (USD)")
    axs[0].set_title("Price Trajectory")
    axs[0].grid(True, alpha=0.3)
    
    # Plot Volume
    axs[1].plot(results["time"], results["demand"], label="Total Tokens Consumed", color='orange')
    axs[1].set_ylabel("Volume (Log Scale)")
    axs[1].set_yscale('log')
    axs[1].set_title("Total Consumption (Volume)")
    axs[1].grid(True, alpha=0.3)
    axs[1].legend()
    
    # Plot Expenditure
    axs[2].plot(results["time"], results["expenditure"], label="Total Expenditure", color='green')
    axs[2].axhline(y=1.0, color='red', linestyle='--', label="Baseline Expenditure")
    axs[2].set_ylabel("Total Spend (USD)")
    axs[2].set_title("Jevons' Paradox Check: Expenditure Growth")
    axs[2].grid(True, alpha=0.3)
    axs[2].legend()
    
    plt.tight_layout()
    plt.savefig('jevonsons_simulation.png', dpi=100)
    plt.show()

if __name__ == "__main__":
    # Scenario: Highly Elastic Market (AI Standard)
    # epsilon > 1 implies that % change in volume > % change in price drop
    sim_results = simulate_jevonsons_law(
        T=20,
        initial_price=0.001,
        price_decay=0.90, # 10% annual price drop
        base_demand=1e6,
        elasticity=1.8,   # High elasticity
        tech_progression=0.1 # 10% annual improvement in capability/efficiency
    )
    
    print(f"Initial Expenditure: ${sim_results['expenditure'][0]:,.2f}")
    print(f"Final Expenditure:   ${sim_results['expenditure'][-1]:,.2f}")
    print(f"Price Change:        {((sim_results['prices'][-1]/sim_results['prices'][0])-1)*100:.2f}%")
    print(f"Volume Change:       {((sim_results['demand'][-1]/sim_results['demand'][0])-1)*100:.2f}%")
    
    if sim_results['expenditure'][-1] > sim_results['expenditure'][0]:
        print("\n>>> JEVONS' LAW CONFIRMED: Efficiency gains led to increased total consumption.")
    else:
        print("\n>>> JEVONS' LAW NOT OBSERVED: Total consumption decreased or stayed flat.")

    plot_simulation(sim_results)

Analyzing the Output

Running the code above yields a clear demonstration of the paradox. Note the specific metrics printed to the console:

  1. Price Drop: The price per token drops by approximately 87% over 20 periods ($0.9^{20} \approx 0.12$).
  2. Volume Surge: Due to the high elasticity ($\epsilon = 1.8$) and the technological progression ($\delta=0.1$), the volume of tokens consumed increases exponentially.
  3. Expenditure Growth: Despite the massive price reduction, the total expenditure increases. This is the hallmark of Jevons' Law. The "efficiency gain" (lower cost) did not save the customer money in aggregate; it enabled them to do more work, spending more in total.

Advanced Considerations: The "Rebound Effect"

In pure economics, Jevons' Law is a specific case of the "rebound effect." In AI engineering, this manifests in three distinct layers:

  1. Direct Rebound: Lower inference costs allow startups to run LLMs on every single user interaction rather than sampling or batching, increasing raw token volume.
  2. Indirect Rebound (Quality Improvement): As the cost per unit drops, developers can afford to use larger, more capable models (higher $E_t$) for critical paths. This increases the "value density" of each transaction, driving up demand for high-fidelity inference.
  3. Market Expansion (New Use Cases): When inference is cheap, applications that were previously economically unviable (e.g., real-time video understanding, personal AI agents running 24/7) become feasible. This shifts the entire demand curve outward, independent of price changes.

Conclusion

Jevons' Law is not just a historical anecdote; it is the operating principle of the modern AI economy. For system architects and CTOs, this has profound implications:

  • Do not budget for linear cost reduction. Assume that as your unit costs drop, your consumption will scale non-linearly.
  • Monitor Elasticity. Use the simulation parameters above to model your specific service. If your $\epsilon$ is close to 1, you are in a neutral state. If it is greater than 1, you are in a growth spiral.
  • Design for Abundance. If you build your infrastructure assuming scarcity, you will fail to capitalize on the volume spikes that accompany efficiency gains. The "paradox" is actually an opportunity: efficiency unlocks scale.

The code provided offers a baseline for this simulation. In production, you should replace the static tech_progression with real-time monitoring of your model's effective performance (e.g., success rates, user satisfaction) to dynamically adjust the $E_t$ parameter, creating a closed-loop control system for your computational economics.