The Economic Machine - Ray Dalio's Model 

 

 

 

 

The Economic Machine - Ray Dalio's Model 

This simulation visualizes Ray Dalio's "Economic Machine"—a control theory model demonstrating how debt cycles drive economic booms and busts. The economy is visualized as a mechanical system: money flows through pipes to spin a gear (GDP), debt accumulates in a tank, and the system can crash when debt overflows.

The simulation uses a Control Theory Model with continuous feedback loops. The economy is visualized as a mechanical system where:

  • The Gear (GDP): Represents economic output. Its rotation speed equals GDP growth rate.
  • The Injection Valve (Central Bank): Pumps money into the system to increase GDP velocity.
  • The Friction Lever (Interest Rates): Applies brakes to slow down the economy and control inflation.
  • The Debt Tank: Accumulates debt as the economy grows. When full, triggers a crash (deleveraging).
  • The Sediment Layer: Represents long-term debt that hardens after each crash cycle.

NOTE: The key insight: Increasing money supply spins the gear faster, but also fills the debt tank. When the tank overflows, the system crashes regardless of inputs. This demonstrates Dalio's central thesis: short-term debt cycles create booms and busts, while long-term debt cycles build up over decades until a major reset is needed.

Mathematical Foundation

The Economic Machine model is a discrete-time solver for a system of coupled Ordinary Differential Equations (ODEs) using Euler's Method for numerical integration. While the code looks like simple variable updates (`+=`), it is mathematically implementing differential equations that govern the economy.

The simulation models three coupled ODEs:

1. The GDP Equation (Exponential Relaxation / First-Order Linear ODE):

dv/dt = (F - v) / τ

Where v is GDP Velocity, F is the Input Force (Money Supply / 10 + Base Productivity - Interest Rate / 5), and τ is the Time Constant (0.05 in discrete form).

In code: state.gdpVelocity += (targetVelocity - state.gdpVelocity) * 0.05;

Physics Meaning: This creates "Inertia." The economy cannot instantly jump to a new speed; it must accelerate towards it. This lag is what causes policy errors (over-correction).

2. The Debt Equation (Accumulation / Integral ODE):

dD/dt = v × f(r) × α - β

Where D is Total Debt, v is GDP velocity, f(r) is the Interest Rate factor ((20 - r) / 20), α is the Accumulation Rate (0.02), and β is the Repayment Rate (0.05).

In code: state.currentDebt += debtInflow - CONFIG.debtRepaymentRate;

Physics Meaning: This is an integral. The level of fluid (Debt) is the integral of the flow rate over time. Debt accumulates when GDP is high and interest rates are low, and drains naturally at a constant rate.

Why Interest Rates Have an Inverse Relationship with Debt Accumulation

This model uses Ray Dalio's "Short Term Debt Cycle" approach, which models the incentive to borrow (new credit creation), not the compound interest cost on existing debt. There are two different ways to view interest rates:

1. The "Credit Card" View (Intuitive): High interest rates mean existing debt grows faster because interest payments are high. This is what happens to your personal credit card balance.

2. The "Macroeconomic" View (This Model): Low interest rates act as "Cheap Fuel," incentivizing businesses and people to take out NEW loans. This models the behavior of the entire economy, not individual debtors.

The Logic of This Model: "The Incentive to Borrow"

In this simulation, the Interest Rate controls the Valve for new borrowing, not the interest accumulating on the existing debt pile. The equation term f(r) = (20 - r) / 20 creates an Inverse Relationship:

Scenario A: Free Money (0% Interest):

f(0) = (20 - 0) / 20 = 1.0 (100% Open Valve)

Result: Because money is "free," everyone borrows to buy houses, stocks, and factories. The "Debt Tank" fills up rapidly because of New Borrowing. This simulates the 2000s housing bubble or the 1920s stock market boom.

Scenario B: Tight Money (20% Interest):

f(20) = (20 - 20) / 20 = 0.0 (Valve Closed)

Result: Money is too expensive. Nobody takes out a new loan. The "Debt Tank" stops filling because new borrowing ceases. This simulates the 1980s Volcker era or the European debt crisis.

Why GDP Velocity (v) is in the Debt Equation

The term v × f(r) × α implies that Debt grows fastest during a Boom.

The Speculative Bubble Effect:

  • If the economy is hot (v is high) AND money is cheap (r is low), debt accumulation explodes.
  • This simulates a Speculative Bubble. People aren't just borrowing; they are borrowing because the economy is moving fast (FOMO - Fear Of Missing Out).
  • When GDP is low, even cheap money doesn't lead to much borrowing (nobody invests in a recession).
  • When GDP is high, everyone wants to invest, and cheap money makes it easy. This creates a feedback loop: boom → borrowing → more boom → more borrowing → crash.

Summary for Mental Model:

  • This term measures: The rate of New Credit Creation (borrowing incentives).
  • It does NOT measure: The compound interest cost on existing debt.
  • The "Trap": To make the GDP gear spin fast, you must lower rates. But lowering rates opens the "New Debt Valve." You are forced to choose between a slow economy or a debt-fueled bubble.

NOTE: In reality, both effects happen simultaneously: (1) Low rates encourage new borrowing (this model), and (2) High rates make existing debt harder to service (not in this model). This simulation focuses on (1) to demonstrate Dalio's "Short Term Debt Cycle" where booms are driven by cheap credit, not by compound interest on old debt. If you wanted to add the "Debt Service Cost" effect, you could modify the repayment term to decrease when rates are high, making debt harder to pay off during tight monetary policy.

3. The Inflation Equation (Newton's Law of Cooling / Lumped Capacitance Model):

dT/dt = Q - k × T

Where T is Inflation Heat, Q is the heat generation rate (from monetization and high GDP), and k is the cooling constant (0.2).

In code: state.inflationHeat += heatGeneration - CONFIG.heatDissipationRate;

Physics Meaning: Heat naturally dissipates if you stop adding energy. This creates the "cooling off" period required between bursts of money printing. When monetization stops, inflation cools down over time.

Heat Generation Threshold: Heat starts generating passively when GDP velocity exceeds 8 (lowered from 10 for sensitivity). This represents the Phillips Curve effect: pushing for maximum growth inevitably generates inflation. With Money Supply at 100%, GDP velocity reaches ~10.5, generating passive heat of (10.5 - 8) × 0.2 = 0.5 per frame. Combined with reduced cooling (0.2 instead of 0.3), heat now accumulates during normal booms, not just when monetizing.

NOTE: The code uses Euler's Method (first-order numerical integration) for simplicity and performance. For a web visualization, this is computationally cheap and sufficient for the visual effect. Higher-order methods like Runge-Kutta 4 (RK4) could be used for smoother integration, but Euler's method is adequate for this educational simulation.

The Cycles: The simulation models two types of debt cycles:

  • Short-term Debt Cycle (5-8 years): Boom → Bust → Recovery. Debt fills the tank, crashes when full, drains during deleveraging, then the cycle repeats.
  • Long-term Debt Cycle (75-100 years): After each crash, "sediment" (hardened debt) accumulates at the bottom of the tank. This reduces available capacity, making each subsequent cycle more fragile until a major reset is needed.

The Debt Cycle Mechanism

Dalio's Economic Machine models how debt cycles drive economic booms and busts. The simulation demonstrates three key phases:

1. The Short-term Debt Cycle (Boom → Bust → Recovery):

  1. Boom Phase: Central bank increases money supply (opens valve). GDP velocity increases (gear spins faster). Debt accumulates as the economy grows (tank fills).
  2. Bust Phase: When debt tank fills to capacity, the system crashes (deleveraging). GDP velocity drops rapidly (gear stops). Interest rates can't help because the problem is too much debt, not too little money.
  3. Recovery Phase: During deleveraging, debt drains from the tank. The gear slowly starts spinning again as debt decreases. Eventually, recovery begins and the cycle repeats.

Critical Understanding: Debt is Destroyed, Not Repaid

During a crash, debt decreases via Default, not Repayment. This is a fundamental difference:

  • Repayment: I owe you $100. I work hard, earn $100, and give it to you. The debt is gone, and you have the money. The economy keeps functioning.
  • Default: I owe you $100. I go bankrupt. I say "I cannot pay." The debt is erased from the ledger. But the money is also lost. You (the lender) now have $0. The economy suffers.

In the simulation, when the debt tank "drains" during a crash, it represents bankruptcies and defaults, not people working hard to pay off loans. The fast-draining liquid represents assets being destroyed. This is why the GDP gear stops spinning—the economy suffers from the defaults.

The Sediment Problem: Even though debt crashes down rapidly during defaults, it stops when it hits the Sediment layer. This represents debt that cannot be defaulted on:

  • Sovereign debt (countries can't easily default on bonds)
  • Pension obligations (government promises to retirees)
  • "Too Big To Fail" bailouts (systemically important institutions get rescued)

This is why the "Long Term Debt Cycle" is harder to manage—even after massive crashes, the debt floor (sediment) remains high and continues to grow.

2. The Long-term Debt Cycle (Sediment Accumulation):

After each crash, not all debt drains. Some debt "hardens" into "sediment" at the bottom of the tank. This sediment represents long-term structural debt that persists across cycles. Each cycle adds more sediment, reducing the available capacity for future growth. Eventually, the tank becomes mostly sediment, making the economy extremely fragile.

3. Beautiful Deleveraging (Monetization):

The only way to reduce sediment (long-term debt) without crashing the economy is through "monetization"—the central bank essentially "prints money" to reduce debt levels. However, this generates inflation heat. If the heat exceeds 100%, the currency collapses (hyperinflation game over). The challenge is to balance debt reduction with inflation control.

The Control Theory Model

This simulation uses a control theory approach—continuous feedback loops with lag effects:

  • Driving Force: Money supply (injection valve) increases GDP velocity
  • Resistance Force: Interest rates (friction lever) decrease GDP velocity
  • Side Effect: High GDP with low interest rates → Rapid debt accumulation
  • Lag Effect: Inflation follows money supply changes with a delay (6-12 month lag in real economies)
  • Feedback Loop: Debt accumulation → Capacity constraint → Crash → Recovery → Repeat

Why Control Theory? The economy is a complex feedback system. Control theory models capture the dynamic interactions between money supply, interest rates, GDP, debt, and inflation. Unlike equilibrium models, control theory shows how the system behaves over time, including the inevitable cycles.

Real-World Examples
  • 2008 Financial Crisis: Debt tank overflowed after decades of accumulating debt. Required massive deleveraging (Quantitative Easing).
  • Long-term Cycle: US debt-to-GDP ratio has been rising since 1980. Each recession adds more structural debt (sediment).
  • Beautiful Deleveraging: Post-2008, Fed used QE to monetize debt, preventing deflation but keeping interest rates low for years.
  • Hyperinflation Risk: Countries like Zimbabwe and Venezuela show what happens when monetization goes too far (heat exceeds 100%).
The Lesson

The Economic Machine demonstrates that short-term fixes create long-term problems. Increasing money supply boosts GDP immediately, but fills the debt tank. Low interest rates make borrowing attractive, accelerating debt accumulation. Eventually, the system becomes so fragile that even small shocks trigger crashes. The only escape is "Beautiful Deleveraging"—careful monetization that reduces debt without destroying the currency.

50
5.0%
GDP Velocity:
0.0
Total Debt:
0/100
Sediment (Long-term):
0
Inflation Heat:
0%
Cycle Count:
0
Status: Normal

SYSTEM DERIVATIVES

dv/dt (Growth): +0.000
dD/dt (Debt Flow): +0.000
dT/dt (Heat): +0.000
GDP vs Debt vs Inflation Over Time

 

Usage Example

Follow these steps to explore Ray Dalio's Economic Machine and understand debt cycles:

  1. Initial Setup: When you first load the simulation, you'll see a mechanical representation of the economy:
    • The Gear (Center): Represents GDP. Its rotation speed equals GDP growth rate.
    • The Injection Valve (Left): Pumps money into the system. Openness controlled by Money Supply slider.
    • The Friction Lever (Right): Brakes the gear. Pressure controlled by Interest Rate slider.
    • The Debt Tank (Bottom): Accumulates debt as the economy grows. Contains liquid debt (blue/red) and sediment (brown).
  2. Start the Simulation: Click "Run" to begin the economic cycle. Watch how:
    • The gear starts rotating (GDP increases)
    • Money particles flow from the valve (green dots)
    • The debt tank fills as the economy grows
    • The gear color changes based on inflation heat (green → orange → red → white)
  3. The Short-term Cycle: Observe the boom → bust → recovery cycle:
    • Boom Phase: Increase Money Supply slider. Watch GDP velocity increase (gear spins faster). Debt accumulates in the tank.
    • Bust Phase: When debt tank fills to capacity (100), the system crashes. Gear stops spinning, status shows "Deleveraging...".
    • Recovery Phase: During deleveraging, debt drains from the tank. When it reaches the sediment level, recovery begins and the cycle repeats.
  4. The Long-term Cycle (Sediment): After each crash, observe:
    • Brown "sediment" accumulates at the bottom of the tank (long-term structural debt)
    • Sediment level increases by 10 after each crash, reducing available capacity
    • After 3-4 cycles, the tank becomes mostly sediment, making the economy extremely fragile
    • Money printing becomes less effective when sediment is high (liquidity trap)
  5. Beautiful Deleveraging (Monetize Debt): When sediment builds up:
    • Press and hold the "MONETIZE DEBT" button (red emergency button)
    • Watch sediment level decrease (good), but inflation heat increases rapidly at 2.0 per frame (dangerous, increased from 1.5)
    • Steam particles appear when monetizing (inflation generation)
    • Strategy: Pulse the button - reduce sediment a little, let heat cool (at 0.2 per frame), then repeat
    • Warning: If heat exceeds 100%, hyperinflation occurs (game over)
    • Note: Heat also accumulates passively when GDP velocity > 8, even without monetization (Phillips Curve effect)
  6. Watch the Chart: The time series chart shows the cycles visually:
    • Green line (GDP): Shows economic output. Rises during boom, drops during bust.
    • Red line (Debt): Shows total debt. Fills during boom, drains during bust, but never goes below sediment level.
    • Orange line (Inflation): Shows inflation heat (0-100%). Rises when GDP velocity > 8 or when monetizing debt. Demonstrates the Phillips Curve: maximum growth inevitably generates inflation.
    • You'll see the cycles repeating with debt floor rising over time
  7. Observe the Telemetry Panel: The top-right corner shows real-time rates of change (d/dt) for the three key variables:
    • dv/dt (Growth): Shows GDP acceleration. Positive (green) = economy accelerating, Negative (red) = economy decelerating. When stable, hovers near +0.000 (steady state).
    • dD/dt (Debt Flow): Shows debt accumulation rate. Positive (red) = debt increasing, Negative (green) = debt decreasing. Even when you stop printing money, this might stay positive due to accumulated velocity.
    • dT/dt (Heat): Shows inflation change rate. Positive (red) = inflation rising (dangerous), Negative (green) = inflation cooling (safe). When monetizing, watch this spike!
    • Educational Value: This panel visualizes the underlying differential equations. When you adjust controls, you'll see the rates change immediately (derivatives), even though the actual values (GDP, Debt, Heat) take time to catch up. This demonstrates that Acceleration precedes Velocity in differential systems.
  8. Experiment with Controls: Try different combinations:
    • High Money Supply + Low Interest Rate: Fast boom, rapid debt accumulation, inflation heat builds up (GDP > 8 threshold), quick crash
    • Low Money Supply + High Interest Rate: Slow growth, slower debt accumulation, inflation stays low, but economy struggles
    • Balanced Approach: Moderate settings allow longer cycles with manageable debt growth and moderate inflation
    • Beautiful Deleveraging: Use Monetize Debt strategically to reduce sediment without overheating (heat spikes to 2.0 per frame when monetizing)
    • Phillips Curve Effect: Observe that pushing Money Supply to 100% (max speed) causes inflation to slowly rise even without monetization, demonstrating the trade-off between growth and inflation

Tip: The key insight is that debt cycles are inevitable. Increasing money supply boosts GDP immediately, but fills the debt tank faster. Low interest rates make borrowing attractive, accelerating debt accumulation. Eventually, the system becomes so fragile that even small shocks trigger crashes. The only escape is "Beautiful Deleveraging"—careful monetization that reduces long-term debt without destroying the currency through hyperinflation.

Parameters

Followings are short descriptions on each parameter
  • Money Supply (0-100): Controls how much money flows into the economy (valve openness). Higher values increase GDP velocity (gear spins faster) but accelerate debt accumulation. Represents central bank monetary policy (QE, money printing).
  • Interest Rate (0-20%): Controls the friction/brake on the economy. Higher values slow GDP velocity (brake the gear) but reduce debt accumulation. Represents central bank interest rate policy. Low rates encourage borrowing (more debt), high rates discourage borrowing (less debt but slower growth).
  • GDP Velocity: The rotation speed of the gear, representing economic growth rate. Calculated as: (Money Supply / 10) + Base Productivity - (Interest Rate / 5). Higher velocity = faster economic growth.
  • Total Debt (0-100): The total debt level in the tank (liquid + sediment). When it reaches 100, the system crashes. Comprises short-term debt (liquid, blue/red) and long-term debt (sediment, brown).
  • Sediment Level (Long-term Debt): Hardened debt that persists across cycles. Increases by 10 after each crash, representing structural debt that never fully drains. Reduces available capacity for future growth. When sediment exceeds 60% of tank capacity, money printing becomes less effective (liquidity trap).
  • Inflation Heat (0-100%): The "temperature" of the economy. Increases passively when GDP velocity > 8 (Phillips Curve effect), and rapidly when monetizing debt. Dissipates naturally over time (0.2 per frame, reduced from 0.3 to make heat linger). If heat exceeds 100%, hyperinflation occurs (currency collapse, game over). Gear color changes based on heat: Green (normal) → Orange (warm) → Red (hot) → White (critical). With Money Supply at 100%, heat will slowly accumulate even without monetization, demonstrating that maximum growth inevitably generates inflation.
  • Cycle Count: The number of short-term debt cycles (boom → bust → recovery) completed. Each cycle adds sediment, making the system more fragile over time.
  • Base Productivity: Natural GDP growth rate without monetary stimulus (0.5). Represents real productivity growth from innovation, population growth, etc.
  • Debt Accumulation Rate: How fast debt builds up per unit of GDP velocity (0.02). Higher GDP with lower interest rates → faster debt accumulation.
  • Debt Repayment Rate: Natural debt drainage rate (0.05). Represents normal debt repayment. Only affects liquid debt, not sediment.
  • Crash Drain Rate: Accelerated debt drainage during deleveraging (3.0x normal rate). Represents forced debt reduction during economic crashes.

Buttons and Controls

Followings are short descriptions on each control
  • Run/Stop: Toggles the simulation. When running, the button shows "Stop" and turns red. Click to pause and observe the current economic state. The simulation runs continuously at 60 FPS.
  • Reset: Stops the simulation and resets all state variables to initial values. Clears debt history and statistics. Use this to start fresh experiments.
  • MONETIZE DEBT (Emergency Button): The "Beautiful Deleveraging" mechanism. Press and hold to reduce sediment (long-term debt) but increase inflation heat. Strategy: Pulse the button - reduce sediment a little, let heat cool down, then repeat. If heat exceeds 100%, hyperinflation occurs (game over). This is the only way to reduce long-term debt without waiting for crashes.
  • Money Supply Slider (0-100): Controls the injection valve openness. Higher values pump more money into the economy, increasing GDP velocity but accelerating debt accumulation. Real-world equivalent: Central bank quantitative easing (QE) or money printing.
  • Interest Rate Slider (0-20%): Controls the friction lever (brake) on the economy. Higher values slow GDP growth but reduce debt accumulation. Lower values encourage borrowing (more debt) but boost growth. Real-world equivalent: Central bank interest rate policy.

Interaction and Visualization

  • Mechanical Visualization:
    • The Gear: Large central gear representing GDP. Rotation speed = GDP velocity. Color changes with inflation heat (green → orange → red → white). Shakes during crash/hyperinflation.
    • Injection Valve: Left side pipe dripping money (green particles) onto the gear. Openness based on Money Supply slider. More money = more particles = faster gear rotation.
    • Friction Lever: Right side brake pressing against the gear. Pressure based on Interest Rate slider. More friction = slower gear rotation.
    • Debt Tank: Bottom reservoir containing debt. Blue liquid = normal debt, red liquid = near overflow, brown layer = sediment (long-term debt). Liquid sloshes slightly for realism.
    • Steam Effect: When monetizing, white steam particles rise from the debt tank, representing inflation generation.
    • Temperature Gauge: Top-left corner shows inflation heat level. Yellow = normal, Orange = warning, Red = critical.
  • Economic Dynamics:
    • Money supply increase → GDP velocity increases → Gear spins faster
    • Interest rate increase → GDP velocity decreases → Gear spins slower
    • High GDP + Low Interest → Rapid debt accumulation → Tank fills quickly
    • Debt tank full → System crashes → Deleveraging begins → Debt drains → Recovery → Cycle repeats
    • Each crash adds sediment → Long-term debt builds → System becomes fragile
    • Monetization reduces sediment but increases heat → Risk of hyperinflation
  • Statistics Panel: Real-time display of:
    • GDP Velocity (current rotation speed, updated continuously)
    • Total Debt (current debt level / maximum capacity)
    • Sediment Level (long-term structural debt that persists)
    • Inflation Heat (temperature of the economy, 0-100%)
    • Cycle Count (number of boom-bust cycles completed)
    • Status (Normal, Warning, Deleveraging, or HYPERINFLATION!)
  • GDP vs Debt vs Inflation Chart: Time series visualization showing:
    • Green line: GDP velocity over time (shows booms and busts)
    • Red line: Total debt over time (shows accumulation and deleveraging)
    • Orange line: Inflation heat (0-100%) over time (shows inflation dynamics)
    • Demonstrates the debt cycles and how debt floor rises over time
    • Shows correlation between GDP growth, debt accumulation, and inflation (Phillips Curve)
    • Inflation line shows passive heat generation when GDP > 8, and spikes when monetizing debt
  • Telemetry Panel (System Derivatives): Top-right corner HUD showing real-time rates of change (d/dt):
    • dv/dt (Growth): GDP acceleration rate. Green = positive (economy accelerating), Red = negative (economy decelerating). When system is stable, hovers at +0.000 (steady state where d/dt = 0).
    • dD/dt (Debt Flow): Debt accumulation rate. Red = positive (debt increasing), Green = negative (debt decreasing). Shows net flow into/out of the debt tank.
    • dT/dt (Heat): Inflation change rate. Red = positive (inflation rising), Green = negative (inflation cooling). Spikes when monetizing debt.
    • Educational Value: This panel visualizes the underlying differential equations in real-time. When you adjust the Money Supply slider, you'll see dv/dt spike immediately (acceleration), even though the gear (velocity) hasn't sped up yet. This demonstrates the key concept that Acceleration precedes Velocity in differential systems. The panel also shows equilibrium states—when the system is stable, all derivatives approach +0.000, teaching the concept of Steady State where d/dt = 0.