Go Concurrency Pattern: The Sieve of Eratosthenes Pipeline

    ← Monte Carlo Pi | Series Overview | Mandelbrot Set → The Problem: Finding Primes with Filters The Sieve of Eratosthenes is an ancient algorithm for finding prime numbers. The concurrent version creates a pipeline of filters: each prime spawns a goroutine that filters out its multiples. The Algorithm: Generate sequence: 2, 3, 4, 5, 6, 7, 8, 9, 10, … Take first number (2), it’s prime, filter all multiples of 2 Take next number (3), it’s prime, filter all multiples of 3 Take next number (5), it’s prime, filter all multiples of 5 Repeat until desired count The Beauty: Each prime creates its own filter. Numbers flow through a pipeline of increasingly selective filters. What passes through all filters must be prime. ...

    February 2, 2025 · 11 min · Rafiul Alam

    Go Concurrency Pattern: Monte Carlo Pi Estimation

    ← Login Counter | Series Overview | Sieve of Eratosthenes → The Problem: Computing Pi by Throwing Darts Imagine a square dartboard with a circle inscribed inside it. Throw random darts at the square. The ratio of darts landing inside the circle to total darts thrown approaches π/4. Why? Mathematics: Square side length: 2 (from -1 to 1) Square area: 4 Circle radius: 1 Circle area: π × 1² = π Ratio: π/4 Throw 1 million darts, multiply by 4, and you’ve estimated π. More darts = better estimate. This is Monte Carlo simulation: using randomness to solve deterministic problems. ...

    January 30, 2025 · 10 min · Rafiul Alam

    Go Concurrency Pattern: The Mandelbrot Set

    ← Sieve of Eratosthenes | Series Overview | Collatz Explorer → The Problem: Rendering Fractals in Parallel The Mandelbrot set is defined by a simple iterative formula: Start with z = 0 Repeatedly compute z = z² + c If |z| exceeds 2, the point escapes (not in the set) Color each pixel by iteration count The beauty: Each pixel is completely independent. Perfect for parallelism! The challenge: Some pixels escape in 5 iterations, others take 1000+. This creates load imbalance-some workers finish instantly while others grind away. ...

    January 27, 2025 · 11 min · Rafiul Alam

    Mixed Strategies: Why You Should Be Unpredictable

    Mixed Strategies: Why You Should Be Unpredictable You’ve learned about dominant strategies and Nash equilibria in pure strategies. But what happens when there’s no pure strategy Nash equilibrium? What if being predictable is your worst enemy? Welcome to the world of mixed strategies - where randomness becomes your most powerful weapon. The Problem with Being Predictable Imagine you’re a goalkeeper facing a penalty kick. You can dive left or right. The striker can shoot left or right. If you both go the same way, the striker scores. If you guess correctly, you save. ...

    January 23, 2025 · 6 min · Rafiul Alam

    Nash Equilibrium Explained in 5 Minutes

    John Nash won the Nobel Prize for an idea so simple you can explain it in 5 minutes. Yet this idea revolutionized economics, predicted Cold War outcomes, explains why you’re stuck in traffic, and even helps explain evolution. Let’s understand Nash Equilibrium-the most important concept in game theory. The Core Idea (In One Sentence) A Nash Equilibrium is a situation where no player can improve their outcome by changing their strategy alone-everyone is doing the best they can given what everyone else is doing. ...

    January 22, 2025 · 8 min · Rafiul Alam

    What is Game Theory? A Simple Introduction

    Have you ever wondered why gas stations on the same corner charge similar prices? Or why countries engage in arms races even though both would be better off spending less on weapons? Or why you and your friends can’t decide where to eat, even though everyone wants to go somewhere? These situations all involve strategic decision-making-and that’s exactly what game theory studies. What is Game Theory? Game theory is the mathematical study of strategic interactions. It’s a framework for understanding situations where your best choice depends on what others choose, and their best choice depends on what you choose. ...

    January 22, 2025 · 6 min · Rafiul Alam

    Game Theory 101: What is a 'game' in mathematics?

    When most people hear the word “game,” they think of fun activities like chess, poker, or video games. But in mathematics, a “game” has a much broader and more precise meaning. Game theory studies strategic situations where the outcome depends not just on your choices, but on the choices of others too. What Makes Something a “Game”? In game theory, a game is any situation where: Multiple decision-makers (called “players”) interact Each player has choices (called “strategies”) they can make Each combination of choices leads to an outcome with specific rewards or costs (called “payoffs”) Players care about these outcomes and try to make rational decisions The beauty of this definition is that it applies to far more than board games. Business competition, political negotiations, evolutionary biology, and even social dilemmas are all “games” in the mathematical sense. ...

    January 21, 2025 · 5 min · Rafiul Alam

    Payoff Matrices: How to visualize any two-player game

    If you want to master game theory, you need to master payoff matrices. They’re the single most important tool for analyzing two-player games, and once you understand them, you’ll see strategic situations everywhere. A payoff matrix is simply a table that shows every possible outcome of a game and what each player gets in each scenario. But this simple visualization unlocks powerful insights about human behavior, business strategy, and why rational people sometimes make seemingly irrational choices. ...

    January 21, 2025 · 7 min · Rafiul Alam

    Why Rational Players Sometimes Lose: The Paradox of Game Theory

    Here’s one of the most unsettling discoveries in mathematics: perfectly rational players, each acting in their own self-interest, can all end up worse off than if they had acted irrationally. This isn’t a flaw in game theory-it’s a feature of reality that game theory reveals. This paradox explains traffic jams, arms races, overfishing, climate change negotiations, and why businesses sometimes engage in destructive price wars. Understanding it will change how you see human cooperation (and its failures). ...

    January 21, 2025 · 9 min · Rafiul Alam

    Go Concurrency Pattern: The Collatz Explorer

    ← Mandelbrot Set | Series Overview The Problem: The Simplest Unsolved Math Problem The Collatz conjecture (3n+1 problem) is deceptively simple: Start with any positive integer n If n is even: divide by 2 If n is odd: multiply by 3 and add 1 Repeat until you reach 1 The conjecture: Every positive integer eventually reaches 1. Example (n=12): 12 → 6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1 The mystery: This has been verified for numbers up to 2^68, but never proven. It’s one of mathematics’ most famous unsolved problems. ...

    January 20, 2025 · 12 min · Rafiul Alam