Skip to content

A tale of two abstractions

Posted on:January 8, 2025 at 11:45 AM

Two expressions that describe the exact same concept - one in mathematical notation, one in code. Which feels more approachable to you?

math-code

These expressions represent Geometric Brownian Motion (GBM), a model used in finance to simulate how asset prices evolve under uncertainty. At first glance, the mathematical formula appears more daunting than the Python implementation, despite describing identical processes. Why?

Mathematics achieves remarkable compression through symbolism. A single σ encapsulates volatility, while Z represents an entire probability distribution. The beauty of math lies in this density - expressing complex ideas through minimal notation. But this compression comes at a cost: meaning becomes implicit, locked behind layers of mathematical literacy.

Code takes the opposite approach. It unpacks these dense ideas into explicit steps. portfolio_volatility tells us exactly what σ means. np.random.randn() makes Z concrete - it’s just a random number from a normal distribution. Code sacrifices elegant compression for clarity and actionability. This reflects a deeper truth about these two languages:

Neither approach is superior. Mathematics lets us reason about universal truths with elegant precision. Code lets us execute these truths in the real world. They’re complementary tools in our quest to understand and shape the world - one for thought, one for action. Next time you encounter a dense mathematical formula, remember: somewhere out there is a piece of code that makes those abstractions concrete. The challenge isn’t choosing between math or code - it’s learning to move fluently between both worlds.