The Story of the Mathematics of Machine Learning Book
How I accidently wrote a 700-page textbook because I couldn’t stop posting on Twitter
Writing online about mathematics and machine learning started as a creative hobby for me, a way to recharge my batteries after cofounding a failed startup that burned my savings and two years of my life.
I have always had a passion for teaching. Even as an undergrad, I often found myself explaining the material to my coursemates. In my third year, I became a teaching assistant, teaching probability theory to students only one year below me. Later, as a researcher in a computational biology group, I used to give spontaneous lectures on (guess what) the mathematics of machine learning, sometimes even helping my grad student colleagues prepare for calculus and linear algebra exams.
The conventional advice is “don’t follow your dreams, do whatever makes you the most money.” But I’m not a conventional person. I walk my path, not others’. So, in 2021, I started a project with no promise of money, only a promise of personal fulfillment. A dream.
It turned out to be the most rewarding decision I have ever made.
Before you read on: we are running a fundraising campaign in December with a 30% forever discount for new paid subscribers. We are aiming for 1000 members, and we are halfway with 550 currently.
■■■■■▢▢▢▢▢ 55%
Every new paid subscription will contribute to the following milestones:
600 paid subscribers → Exclusive mini-course (Q2 2026)
The topic of the first mini-course will be “Mathematics of Machine Learning”.
700 paid subscribers → Another exclusive mini-course (Q4 2026)
A second mini-course with a different expert/angle. The idea is to slowly build an extensive “course library” for members.
800 paid subscribers → Dedicated Manim animator
We’ll bring on a Manimator so more articles come with clean, high-quality animations that make the concepts instantly click.
1,000 paid subscribers → Full-time writer
This is the big one. With a full-time writer on the team, we can ship more deep dives, more courses, and more structured learning tracks throughout 2026.
If you upgrade now, you’re not just supporting what exists today; you’re helping shape what we can build next year.
Back in early 2021, most of the machine learning community was active on Twitter, and I enjoyed spending time on the platform, feeling the pulse of the tech world. So, it was a good place to start writing online. (We are living a different life now. COVID, the war in Ukraine, and Trump: Season One & Season Two changed so much in our lives. But that’s a topic for another day.)
Even though Twitter used to have a 280-character limit per tweet, one way to circumvent this was to publish threads, that is, a chain of replies. Writing threads about math and machine learning on Twitter felt like a silly idea at first, but the more I thought of it, the more it made sense. A 280-character limit per tweet is not just a restriction; it’s a format that encouraged me to break down complex topics into short and clear chunks.
It’s almost like poetry. Think of your favorite poems, and how they turn the deepest of thoughts into a couple of sentences with rhythm.
On top of it, quality technical content was rare on Twitter. Most of the creators were riding the current hype wave to maximize engagement, hopping from topic to topic like skipping stones on water. In 2020, it was frontend development. 2021: crypto. 2022: generative AI. 2023: LLMs. 2024: vector databases. 2025: agentic AI.
I wanted none of that. Instead of shaping my content to my audience, I wanted to shape my audience to my content. To teach and lift up, not to appease.
So I started creating threads about math, and they immediately became a smash hit. My follower count exploded. It took me three years to get 300 followers, but only three months to get from 300 to 1000. And around three more months from 1000 to 10.000.
Here’s one of the first ones. (I think it was the one that put me above 1000 followers for the first time.)
I was pumping out thread after thread, and soon, I realized that I’m practically writing a book.
Could I write a book? Should I? Creating the ultimate learning resource on the mathematics of machine learning has been my dream since my undergrad years, so I was excited about even the idea.
One of the biggest mistakes we made in our startup was not validating the product as early as possible by asking people to pay for it. We spent a year and a half in development, only to realize that no one is interested in what we are building. So, I set up a Gumroad page and announced the early access program for the Mathematics of Machine Learning in August 2021. The idea was simple: the early access costs $25, and you get the chapters as I write them.
My expectations were low (probably for the first time in my life), but the results immediately blew me away (probably for the first time, too). 33 sales in the first couple of hours, totaling $825; 94 sales in August, totaling $2350. This was about double my postdoctoral researcher salary, so I was shocked.
There I was, posting my random math posts online, and people were paying money to keep going.
Idea validated.
(Another one of my startup mistakes: start a small project. Well, after four years of writing, it’s safe to say that I did not learn from that one.)
I was committed to finishing the book, publishing a new chapter every two years or so. However, this was a full-time job, and I severely underestimated the amount of marketing I needed to make at least a couple of sales, just to get by.
Marketing was not my forte (I still suck at it), so I did what I was best at: published in-depth math explanations on Twitter, inserting a link to the early access of my book at the end. This worked decently: I earned around $1000-$2000 each month, which was enough for me (this was my only source of income), but now I had a problem. My work essentially doubled. I spent every other day on my content marketing, slowing down progress.
In hindsight, this was a blessing in disguise. As a side effect, I learned to write clear and engaging technical content, improving the quality of my book-to-be.
The constant pressure to publish and sell forged my visual style as well. Illustrations perfectly complement technical explanations, so I began to put an insane amount of time into my drawings.
By now, my time was split even more: 1/3 for book writing, 1/3 for social media content, and 1/3 for illustrations. The progress became even slower, but every minute spent on the drawings was well worth it. You loved them, and my visuals ended up defining my work.
(Oh, and contrary to popular belief, I don’t use Manim; I draw my illustrations in Inkscape.)
Everything changed when Elon Musk purchased Twitter and changed the algorithm overnight. Growth halted, threads buried, impressions crashed and burned, and because Twitter was my only source of readers, my revenue went from $1000-$2000 to $300-$600 per month. On top of all that, the extreme inflation in Hungary (where I live) doubled the cost of living. My situation was highly suboptimal.
I’m not the person who ever gives up. So, I adapted to the situation.
There was this new and rapidly growing platform called Substack that had a lot of promise:
Creators are directly connected to their audiences via email, which is a big deal because the platform cannot pull the rug out from under you, just like Twitter did.
There’s no algorithm to serve; it’s just you and me. If you enjoy my content, you subscribe to receive all my posts. They won’t be buried in a transient timeline feed; you can always find them in your inbox.
The long form is better suited for technical content.
The paid subscription model adds another revenue stream, independent of how my book’s early access performs.
So, I started my journey with The Palindrome.
I love Substack. It’s my favorite platform by far, and I’m committed to building the No. 1 science publication here. (We are currently #32 in the science category.)
On the other hand, my focus was split even more. Now, in addition to writing the book, I had to write a long-form post here, with exclusive content for my paid subscribers. I spread myself too thin. Even though The Palindrome was growing nicely (with around a thousand subscribers a month), my progress on the book ground to a halt.
Four years into writing and two years into my Substack journey, I realized that I’m writing two books: one about mathematics and one about machine learning. And the math part is already finished! By that time, the content was well over a thousand pages.
Two of the most common questions I used to get about my book:
“Is it finished yet?”
“Will there be a physical version?”
Suddenly, I realized that finding a publisher would solve almost all of my problems. I won’t have to split my time between writing a book, marketing the early access, and growing a Substack.
If I can find a publisher who can turn my early access draft into a beautiful book, I would be happy to sign with them. Soon after, I was introduced to Packt by someone I won’t name here (if you are reading this, I’ll be forever grateful), and I have been working with them ever since.
This was my first time working with a publisher. I have always been an independent person, and there’s nothing I value more than freedom. So, I was cautious first, but my experience has been nothing short of awesome. The amount of work hours they put into this book was incredible, turning my Jupyter Notebooks into a beautiful 700-page LaTeX project. (I even remember prompting one of the editors around 1 AM his time, and getting a reply within minutes.)
After six more months of intense re-reading, editing, formatting, and re-reading a couple more times, the Mathematics of Machine Learning was released on 2025, May 29th, and it became an instant success.
It was you who made it all possible. You, who are reading this newsletter, are putting in an insane amount of energy into learning hard things like mathematics and the internals of machine learning. Thank you!
We are just getting started.
Even when you are struggling with a particular challenge, let it be technical, theoretical, practical, or even personal, know this: you’ll succeed. There is always a way.
The people who lifted me up
You know the common wisdom: you are the average of the people you surround yourself with.
I was always lucky with my friends. Along the way, there were quite a few of them who I have a lot to thank for, who made the book significantly better.
was one of the first friends I made on Twitter (if not the first), and he was a massive inspiration for me. I loved his content and decided to give writing a shot myself. Here we are, five years later. If you are a regular reader, you know how great Alejandro’s content is: he is a regular contributor to The Palindrome (you can find his lectures here) and runs The Computist Journal, which I wholeheartedly recommend.The person I learned the most from was
, one of the biggest tech accounts on Twitter, and the founder of ml.school. Watching him grow his follower count from 1000 to 500.000 has been both inspirational and instructive. As a content creator, I'm following in the footsteps of Santiago.I remember checking out one of his first machine learning videos, watching him explain complex topics on hand-drawn illustrations. Check it out:

This is brilliant. His simple illustrations did the job perfectly, probably took only a couple of minutes to make (in contrast to my figures, which take significantly more), and they create a visual style unique to Santiago. He moves from idea to execution at the speed of light, never compromising on quality and value.
Fun fact: he was one of the first five members of the Mathematics of Machine Learning early access, and he supported me on my journey from the beginning. It’s not an accident that I asked him to write the foreword for the book. I consider him my mentor, and I have a lot to thank him for.
was another friend I made on Twitter. Nowadays, he is mainly here on Substack with , but we met during my Twitter days, supporting each other in our quest for fame and fortune. We are still in touch, discussing random wild ideas like a 3D printer side business or moving from Twitter to Substack.I would also like to thank the Packt team and the book reviewers (Tushar, Matthew, Shravan, Amit, Deepayan, Kushal, and Ankur); they have been very kind to me from the first moment and put in an insane amount of work on the book. Without them, the book wouldn’t be half as good as it is.
In the past couple of months,
has been the other driving force behind the incredible growth of The Palindrome. We got in touch around the release of the book, and soon realized that our skillsets complement each other perfectly: I can focus on content, and he can put it in front of as many of you as possible.The growth has been off the charts since then: the number of subscribers doubled, and the number of paid subscribers increased sixfold!
I’m committed to the future of The Palindrome. We’ll be the #1 science publication on Substack someday.
Finally, I owe everything to my mother, whom I lost just when I started to write the book. One of our last conversations was about me mentioning the idea of a book to her, and she telling me to go for it.
Everyone in my life tried to talk me down of my ambitious goals all the time: “you should become a lawyer/doctor/software developer instead of a mathematician” (but I’m interested in mathematics), “starting a company is too risky” (yes I know), “you cannot make a living with writing online about mathematics” (maybe, but I don’t care), “writing a book is too much work” (but it’s worth it).
Everyone, except my mother. She was the only one who knew that if there’s a will, there’s a way.
Thanks, Mom! You are inside every line I write.






Bro what is the death metal band tshirt you are wearing?
Wow Tivadar... lovely post, awesome journey!