Say goodbye to paying $200 for AI textbooks that skip the intuition and leave you more confused than when you started.
An AI engineer spent years filling notebooks with first-principles explanations of maths, computing, and AI the kind that build real understanding instead of just getting you through an exam.
In 2025, he shared those notes with a few friends preparing for interviews at DeepMind, OpenAI, and Nvidia. They all got in, and they all perform well in their roles today.
Now he has open-sourced the entire thing as a free, unconventional textbook called the Maths, CS & AI Compendium, covering 18 chapters from vectors and calculus all the way through GPU programming, inference optimization, quantum ML, and AI for biology.
The six foundational chapters are live right now, covering vectors, matrices, calculus, statistics, probability, and machine learning with the kind of intuition-first writing that most academic textbooks never bother to include.
The remaining chapters on transformers, computer vision, audio, multimodal learning, autonomous systems, CUDA, systems design, and edge inference are coming next.
The notes that opened doors at the best AI labs in the world are now free for every curious practitioner on the internet.
Apache 2.0 License. 100% Open Source.
Elon Musk: “If you want to recruit talented and driven people, you must state the mission, the problem to solve, and show you’re willing to pour blood, sweat, and tears into it with a convincing reason why it matters.
Motivation comes from three things: enjoying the work itself, fair financial rewards, and knowing the work will make a real difference in the world.”
The World Is Not Linear: A Field Guide to the Laws That Quietly Run Everything
Most smart people don’t fail because they’re dumb.
They fail because they apply clean logic to a messy world — and the world punishes that mistake with a smile.
The messy truth is that modern life is shaped less by individual intent and more by systems: incentives, competition, scaling effects, path dependence, and statistical weirdness. These systems produce outcomes that feel unfair or mysterious until you learn the underlying “laws” — a set of lenses that let you predict how things actually behave.
This is not about becoming cynical. It’s about becoming accurate.
Once you internalize these lenses, you start noticing that most disagreements aren’t about values. They’re about which hidden force you think dominates:
Do incentives matter more than morals?
Do networks scale value more than craftsmanship?
Do rare events matter more than averages?
Do systems evolve, or can they be designed?
This article is a guided map through those forces — told as one story.
1) The seduction of “doing the obvious thing”
Imagine you’re in charge of improving something important: a company, a city, a hospital, a school, a product, maybe even your own life.
You do what responsible people do: you define a goal.
You pick a metric.
And you tell everyone: we’re going to win on this number.
This is where the first trap snaps shut.
Goodhart’s Law: the metric stops being real
When a measure becomes a target, it stops being a good measure.
Before it became a target, the metric was an instrument: a thermometer.
After it becomes a target, it becomes a game.
Hospitals improve “wait times” by changing intake rules. Companies improve “engagement” by nudging addiction. Schools improve test scores by teaching to the test. Police departments improve crime stats by changing what counts as a crime.
Not because anyone is evil. Because the system rewards it.
The principal–agent problem: the doers don’t pay
This is the deeper engine under Goodhart.
The person deciding is not the person suffering the consequences.
Executives chase quarterly optics; employees deal with the chaos.
Politicians chase election cycles; citizens live with the long-term effects.
Managers chase easy metrics; customers absorb the frustration.
Once you see principal–agent problems, you start seeing why seemingly intelligent organizations keep doing self-destructive things: the incentives are miswired.
The Cobra Effect: perverse incentives grow cobras
Sometimes this miswiring gets darkly funny.
Reward outcomes and people will manufacture the appearance of outcomes.
In the original parable, a colonial government offered a bounty for dead cobras — and people began breeding cobras.
This isn’t historical trivia; it’s a universal pattern:
Reward bug counts → people file junk bugs.
Reward convictions → plea bargains + overcharging.
Reward content volume → SEO sludge.
Reward “delivery” → rushed work + tech debt.
The world is full of cobra farms.
2) Why fixing things often makes them worse
Okay, so: choose better metrics, align incentives, done.
Not quite.
Because even well-intentioned fixes trigger the next law: second-order effects.
Chesterton’s Fence: don’t remove constraints you don’t understand
You walk into an old system and see “stupid rules.”
You want to clean house.
You want to simplify.
But: why is that rule there?
Don’t remove a fence until you know why it was built.
A lot of institutional weirdness is scar tissue from past disasters.
The rule might be dumb — but if you don’t understand it, you don’t know what disaster you’re re-inviting.
This is why naive reformers are dangerous: they confuse “not understanding a thing” with “the thing being pointless.”
Gall’s Law: complex systems must grow from simple working ones
Even if the fence is removable, you still hit the next problem:
A complex system that works is always evolved from a simple system that worked.
This demolishes a common fantasy: that you can design complexity from scratch.
Most large redesigns fail for one reason:
They try to create a finished organism instead of growing a living embryo.
If the system matters, you don’t “implement” the final form.
You build something simpler that works.
Then you iterate.
Gall’s law is harsh, but kind: it explains why so many ambitious “transformations” flame out.
3) Efficiency doesn’t save you (and sometimes consumes you)
Now suppose you do manage to improve a system.
You make it cheaper, faster, more efficient.
Surely this reduces resource usage?
Often, no.
Jevons Paradox: efficiency increases total consumption
When you make something more efficient, you often make people use more of it.
Make lighting cheaper → people illuminate more spaces.
Make driving more fuel-efficient → people drive farther.
Make computing cheaper → people compute vastly more.
Efficiency doesn’t always shrink the pie. It can expand it.
This is one of the most important and least emotionally intuitive truths about progress: efficiency changes behavior.
4) Some things don’t get more efficient — and get expensive forever
Now meet the mirror image of Jevons: not everything can get dramatically more productive.
Some work is bottlenecked by time, humans, and attention.
Baumol’s Cost Disease: sectors that don’t scale inflate
A string quartet takes as long to play Beethoven as it did 200 years ago.
A therapist can’t 10× their clients without breaking the thing.
A teacher can’t “scale” classroom attention the way software scales distribution.
Meanwhile, other industries do scale — manufacturing, computing, logistics.
So as society grows richer, productivity sectors get cheaper and cheaper…
and human-time sectors get relatively more expensive.
That’s why:
healthcare
education
legal services
childcare
eldercare
…feel like they eat the world.
Baumol isn’t “a problem to solve” so much as a physics constraint: certain value comes from human presence. And presence doesn’t compress easily.
5) The invisible accelerant: networks
At this point you might feel like everything is doom and friction. It’s not.
Some forces make systems wildly better as they grow.
The biggest one is networks.
Metcalfe’s Law: value scales with connections
A phone is useless alone.
A fax machine is useless alone.
A social app is useless without other humans.
As users increase, connections increase faster than users do.
That creates accelerating value.
Reed’s Law: groups scale even faster than connections
But it’s not just one-to-one links.
Once people can form groups — communities, coalitions, companies, subcultures — the number of potential groupings explodes.
That’s Reed’s law: group-forming networks can scale with frightening speed.
This is why networked platforms can go from “niche” to “dominant” almost overnight: the product isn’t just features — it’s the social graph.
6) Progress has a heartbeat: learning curves
Not all progress comes from networks. Some comes from repetition.
Wright’s Law: cost falls with cumulative production
This is the law behind why solar, batteries, and manufacturing tech get cheaper and cheaper:
Every doubling of cumulative production yields a predictable cost reduction.
The implications are enormous:
the future is shaped by what we manufacture at scale
volume is not just output; it’s learning
building the thing teaches you to build the thing better
Strategy through Wright’s law becomes: maximize learning rate.
Not “be brilliant,” but “iterate relentlessly.”
7) Cooperation is rare — and competition forces ugliness
Now we move from economics into game theory and moral physics.
Even with good metrics, good redesign, good scaling…
Sometimes the system makes people do bad things.
Prisoner’s Dilemma: defecting is rational
If you and I cooperate, we both win.
But if I suspect you might defect, I should defect first.
So we both defect.
We both lose.
This structure appears everywhere:
labor vs management
nations vs nations
companies vs companies
roommates
siblings
Twitter discourse
It’s tragedy-by-incentives.
Moloch: the god of coordination failure
“Moloch” is the poetic version of the same idea:
systems where competition forces everyone into worse behavior, even if nobody wants it.
No one wants the attention economy.
But creators compete for attention.
Platforms compete for engagement.
So everyone converges on outrage and addiction.
Moloch doesn’t need villains.
It only needs incentives.
8) The biggest mistake smart people make: believing in averages
Now we arrive at the statistical heart of why forecasts fail.
Most planning assumes the world behaves like a bell curve: most outcomes are near the average, extremes are rare.
In many domains, that’s false.
Fat tails: extremes happen way more than you think
In fat-tailed worlds, the “average” is a comforting lie.
Outliers dominate:
venture returns
blockbuster movies
bestselling authors
company outcomes
war and peace
pandemics
market crashes
In a fat-tailed world:
one event can erase ten years of progress
or create it overnight
Black swans: surprise + impact + fake hindsight
A black swan isn’t just an outlier.
It’s an outlier we didn’t know how to model.
The signature of black swans is:
huge impact
surprise beforehand
“it was obvious” afterward
We are story machines. We can rationalize anything after it happens.
Survivorship bias: you’re studying the winners
This is why business advice is mostly nonsense.
We read biographies of billionaires and imitate their habits — forgetting the cemetery of equally hardworking, equally smart people who lost.
Survivorship bias turns randomness into “wisdom.”
A good thinker always asks:
what am I not seeing because it died?
9) The final set of tools: tradeoffs, simplicity, and time
After you’ve internalized incentives, scaling, networks, and tail risk, you earn the right to something important:
Less ideology.
More judgment.
That’s what these last lenses provide.
Pareto efficiency: every improvement has a cost
At some point, you stop making “free” gains and enter a world of tradeoffs.
If you want more of A, you give up B.
This is what breaks utopian thinking:
more safety can mean less liberty
more speed can mean less quality
more fairness can mean less efficiency
more growth can mean more inequality
Smart people aren’t the ones who avoid tradeoffs.
They’re the ones who name the tradeoff out loud.
Occam’s Razor: don’t add gears without proof
Now that you’re thinking in systems, you could easily overcomplicate.
Occam is your brake pedal:
prefer the simplest explanation that predicts.
It’s not “simplicity is truth.”
It’s: don’t hallucinate complexity.
Lindy: time is the best filter we have
In fragile worlds, “new” is often a synonym for “untested.”
The Lindy effect says:
the longer something has survived, the longer it’s likely to survive.
Ideas, books, institutions, even practices:
time is a stress test.
Lindy isn’t anti-innovation. It’s pro-robustness.
Comparative advantage: specialization beats self-reliance
Finally, comparative advantage gives you the social version of Occam.
Even if you’re worse at everything than someone else…
trade can still make both better off,
because efficiency comes from relative differences.
That lens dissolves a lot of macho self-sufficiency myths.
So what does this worldview do?
It does three things.
First: it replaces naive optimism with durable optimism
Not “everything will work out.”
But: we can build systems that don’t collapse under their own incentives.
Second: it changes what you fear
Not competitors.
Not critics.
Not even failure.
You start fearing:
bad metrics
misaligned incentives
brittle complexity
tail risks
coordination failure
Which are the real predators.
Third: it gives you a usable strategy
A decision-making style that looks like this:
Start simple (Gall)
Measure carefully (Goodhart)
Align incentives (principal–agent)
Expect adaptation (cobra effect)
Respect old constraints (Chesterton)
Model scaling honestly (Metcalfe/Reed/Wright)
Don’t assume efficiency saves you (Jevons/Baumol)
Prepare for tails (fat tails / black swans)
Don’t trust winner stories (survivorship bias)
Name tradeoffs and keep models simple (Pareto + Occam + Lindy)
That list is more than theory.
It’s a survival kit for reality.
Closing: the meta-law
If I had to compress this entire worldview into one sentence, it would be:
Outcomes come from incentives and scaling under uncertainty—not from intentions and plans.
Most people live inside stories.
This toolkit makes you live inside systems.
And once you do, you become harder to fool — including by yourself.
@karpathy Hello sir, can you tell me, how do you view life and death? if all of us are going to die some day, from your perspective, what gives life meaning?
My newsletter recently crossed 90,000 subscribers.
Here are the 10 most-read articles:
1. LeetCode was HARD until I Learned these 15 Patterns: https://t.co/dFv9UPKFUB
2. How I Mastered Data Structures and Algorithms: https://t.co/CmpD3qPXxt
3. What is Scalability: https://t.co/Gbpjax2C5L
4. System Design was HARD until I Learned these 30 Concepts: https://t.co/yyRaLx1sKz
5. 20 Patterns to Master Dynamic Programming: https://t.co/A1GZ9dj9dC
6. Design a URL Shortener: https://t.co/p1AjJXMLZi
7. Basic OOP Concepts Explained with Code: https://t.co/amRKFxcmq7
8. How to Start LeetCode in 2025: https://t.co/6fw1TFyty0
9. Design WhatsApp: https://t.co/b7nEUcloFQ
10. What are ACID Transactions in Databases: https://t.co/eQBBIIMElH
Subscribe for more such articles every week.
Thanks to everyone who has already joined 🙏