<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sohaib Hassan</title>
    <description>The latest articles on DEV Community by Sohaib Hassan (@sohaibhasan).</description>
    <link>https://dev.to/sohaibhasan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3904232%2F0bbbd102-d2b6-4d54-b49e-4fc22e68ecbc.png</url>
      <title>DEV Community: Sohaib Hassan</title>
      <link>https://dev.to/sohaibhasan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sohaibhasan"/>
    <language>en</language>
    <item>
      <title>Every AI Answer Is a Bet: What I Learned Teaching Stanford's Probability for AI</title>
      <dc:creator>Sohaib Hassan</dc:creator>
      <pubDate>Sat, 24 Oct 2026 15:38:15 +0000</pubDate>
      <link>https://dev.to/sohaibhasan/every-ai-answer-is-a-bet-what-i-learned-teaching-stanfords-probability-for-ai-3elb</link>
      <guid>https://dev.to/sohaibhasan/every-ai-answer-is-a-bet-what-i-learned-teaching-stanfords-probability-for-ai-3elb</guid>
      <description>&lt;p&gt;Ask an AI a question and watch the words arrive, one after another. It feels like the machine is looking something up. It is not. At every step, the model is placing a bet. Given everything written so far, it assigns a probability to each possible next token, picks one, and moves on. The paragraph you finally read is a chain of weighted guesses, and the quality of the whole answer depends on how well those guesses were calibrated. It is also why asking the same question twice can give you two different answers.&lt;/p&gt;

&lt;p&gt;We are used to computers being certain. A calculator never hesitates over 7 times 8. But the systems now writing our emails, reading our medical scans and ranking our search results live inside uncertainty, and the mathematics of living inside uncertainty is probability.&lt;/p&gt;

&lt;p&gt;That is why a Stanford course called Probability for AI exists, and why I am proud to be a small part of it. I am a section leader in the course, and this post is what I have learned so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Course in One Paragraph
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pai.stanford.edu" rel="noopener noreferrer"&gt;Probability for AI&lt;/a&gt; is a free online course created by Chris Piech, an Assistant Professor (Teaching) of Computer Science at Stanford and a Faculty Affiliate of Stanford HAI, the university's institute for human-centered AI (&lt;a href="https://profiles.stanford.edu/christopher-piech" rel="noopener noreferrer"&gt;his Stanford profile&lt;/a&gt;). Piech describes it as a course that teaches you "the math language that AI speaks." Stanford HAI describes it as a &lt;a href="https://x.com/StanfordHAI/status/2099882630418485584" rel="noopener noreferrer"&gt;six-week program&lt;/a&gt; for anyone who wants to understand how AI works, not just how to use it, with no prerequisites and no experience needed.&lt;/p&gt;

&lt;p&gt;"Not just how to use it" is the whole point. Anyone can call an API. Understanding why an answer came out the way it did, why it is sometimes confidently wrong, and how much to trust it, requires the language of probability. And although the course welcomes beginners, it does not stay shallow. In my section, we go deep into how probability actually does its work inside AI.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Ended Up in the Room
&lt;/h2&gt;

&lt;p&gt;I was selected as a section leader out of more than 2,700 participants from over 70 countries. A section is a small group where students work through the week's ideas together and get to ask questions. Mine is made up of working professionals and technologists from around the world.&lt;/p&gt;

&lt;p&gt;I do it alongside a full-time job and all the usual weight of daily responsibilities, and it asks for real effort every single week. But I am enjoying this journey seriously, and being trusted to teach in a Stanford course is an honor I do not take lightly.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Question That Shows Why Probability Matters
&lt;/h2&gt;

&lt;p&gt;Try this one. It is the kind of question the course trains you to answer correctly.&lt;/p&gt;

&lt;p&gt;A medical screening test catches 95 percent of people who have a certain condition. It also gives a false alarm for 5 percent of healthy people. The condition affects 1 percent of the population. You take the test and it comes back positive. What is the chance you actually have the condition?&lt;/p&gt;

&lt;p&gt;Most people say about 95 percent. The real answer is about 16 percent.&lt;/p&gt;

&lt;p&gt;Imagine 10,000 people. Of them, 100 have the condition and 95 of those test positive. Of the 9,900 healthy people, 5 percent, which is 495, also test positive. So among the 590 people with a positive result, only 95 are truly sick. That is roughly one in six.&lt;/p&gt;

&lt;p&gt;Nothing in that calculation is advanced. Yet our intuition gets it badly wrong, and the same mistake hides inside AI systems that flag fraud, detect disease or screen applicants. If you build or use such systems, this is basic literacy, not a luxury.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 1: Same Prompt, Twice
&lt;/h2&gt;

&lt;p&gt;Week 1 opened with something every AI user has quietly noticed: ask the same question twice and you may get two different answers. Why?&lt;/p&gt;

&lt;p&gt;In our section, we explored it with a toy language model small enough to hold in your head. Give it the prompt "A sleepy robot dreams about" and it has exactly five possible outputs: electric sheep (44 percent), counting stars (20), sample spaces (14), counting outcomes (13) and robot puppies (9). Each call picks one at random, independently of the last.&lt;/p&gt;

&lt;p&gt;So what is the chance that two calls give two different outputs? Three simple rules are enough: NOT, OR and AND. The chance that both calls give the same output is the sum of each output's probability squared, which comes to 0.2782. The chance of two different outputs is 1 minus that, about 72 percent. Even a model with a clear favorite disagrees with itself most of the time.&lt;/p&gt;

&lt;p&gt;Then came a question that catches almost everyone. "Robot puppies" appears with a 9 percent chance on each call. How many calls until you are more likely than not to see it at least once? The tempting answer adds the chances: six calls, 6 times 9 percent, is 54 percent. But those chances overlap, so adding them overcounts. The right way is to ask for the chance of never seeing it. That is 0.91 on each call, so 0.91 multiplied by itself n times. After six calls the real chance is only 43 percent. It takes eight calls to pass 50 percent.&lt;/p&gt;

&lt;p&gt;Finally, we met the dial that every AI tool hides behind a slider: temperature. It raises each probability to the power 1/T and rescales them so they add up to 1. Here it is in a few lines of Python, applied to the first-word chances of our toy model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mf"&gt;0.44&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.09&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;  &lt;span class="c1"&gt;# first word: electric, counting, sample, robot
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;with_temperature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# raise each chance to the power 1/T
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;     &lt;span class="c1"&gt;# rescale so they add up to 1
&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;with_temperature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# 0.5 [0.5863 0.3298 0.0594 0.0245] 0.4567
# 1   [0.44   0.33   0.14   0.09  ] 0.3302
# 2   [0.3469 0.3005 0.1957 0.1569] 0.2736
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last number on each line is the chance that two calls start with the same word. At T = 0.5, "electric" climbs from 44 to about 59 percent, "robot" shrinks from 9 to about 2.5 percent, and two calls match about 46 percent of the time. At T = 2, the chances even out and two calls match only about 27 percent of the time. In real models, the same thing is done by dividing the logits by T before the softmax, which is mathematically the same operation.&lt;/p&gt;

&lt;p&gt;The randomness setting in an AI tool is not magic. It is probability, rescaled.&lt;/p&gt;

&lt;p&gt;I turned this section into a detailed solutions PDF with every step worked out, and a Manim animation so that students could revisit the ideas at their own pace, long after the live session ended.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 2: The Palpatine Poll
&lt;/h2&gt;

&lt;p&gt;In Week 2, our section centered on a problem called the Palpatine Poll, and it was my favorite kind of problem: simple mathematics wrapped around a clever idea.&lt;/p&gt;

&lt;p&gt;The question is how you measure something people will not say out loud. If you ask directly, many will hide the truth. The trick is called a list experiment. Split people into two groups. Show the first group a list of a few harmless statements and ask only how many they agree with, never which ones. Show the second group the same list with one sensitive statement added, and ask the same question. Nobody reveals a single individual answer, yet the second group's average count comes out higher, and that gap estimates how many people agree with the sensitive statement.&lt;/p&gt;

&lt;p&gt;Underneath this trick sit two of the most useful ideas in probability. A single yes or no answer is a Bernoulli random variable, the simplest random event there is. Add up many of them and you get a binomial distribution, which tells you not only the expected count but also how much it is likely to wobble from one group of people to the next. That wobble is what separates a trustworthy estimate from a lucky one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where This Shows Up in Your ML Work
&lt;/h3&gt;

&lt;p&gt;Every time a team reports that a model is "90 percent accurate," they are reporting a binomial experiment: run the model on &lt;code&gt;n&lt;/code&gt; test examples and count how many it gets right. Treat each test example as an independent trial with a 90 percent chance of success, and you can compute exactly how much the reported number will wobble:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;scipy.stats&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;binom&lt;/span&gt;

&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt;  &lt;span class="c1"&gt;# the model's true accuracy
&lt;/span&gt;
&lt;span class="c1"&gt;# Chance the observed accuracy lands between 84% and 96% on 100 test examples
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;96&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;binom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;83&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;            &lt;span class="c1"&gt;# about 0.97
&lt;/span&gt;
&lt;span class="c1"&gt;# Chance it lands within 0.6 points of 90% on 10,000 test examples
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9060&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;binom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8939&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# about 0.96
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On 100 examples, the number correct will land anywhere from about 84 to 96 in roughly 97 out of 100 runs. On 10,000 examples, the same model lands within about 0.6 of a percentage point of 90 percent, about 95 percent of the time.&lt;/p&gt;

&lt;p&gt;Same model, same skill, wildly different certainty. Whether a headline number deserves your trust depends on a calculation most people never see.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making the Hard Parts Visible
&lt;/h2&gt;

&lt;p&gt;After each week, I do something extra. I write a detailed solutions PDF, and I build a Manim animation that shows the idea moving, not just written down. After Weeks 1 and 2, I shared both with my students and posted them on the section leaders' forum so that every section leader could use them too.&lt;/p&gt;

&lt;p&gt;The reaction was the best surprise of the whole experience. Prof. Chris Piech replied to my post, calling a Manim video for Week 2 a real gift to students and to every section leader in the course, and a fellow section leader added kind words as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonxlthpupfm495bbonxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonxlthpupfm495bbonxu.png" alt="Prof. Chris Piech's reply to my Manim animation for Week 2 of Probability for AI" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A formula on a slide asks you to trust it. An animation lets you watch the reason. When a binomial distribution widens and narrows as you change the number of trials, it stops being a symbol and becomes something you have seen. That has been true in my own classroom as well, and it is why I animate everything I can.&lt;/p&gt;

&lt;p&gt;If you want to explore the material yourself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Detailed PDFs for Week 1 and Week 2:&lt;/strong&gt; &lt;a href="https://drive.google.com/drive/folders/1iwzGMDo9XQ4w8h1BXhQzgaGV9Zx0O4pO?usp=sharing" rel="noopener noreferrer"&gt;open the folder&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The animation playlist:&lt;/strong&gt; &lt;a href="https://www.youtube.com/playlist?list=PLUR1g6hiXfoQ" rel="noopener noreferrer"&gt;Stanford Probability for AI on YouTube&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I Am Taking Away
&lt;/h2&gt;

&lt;p&gt;Teaching this course has changed how I read AI headlines. When I see that a model is "accurate," I ask how many examples it was tested on. When a system is described as "confident," I ask whether that confidence is calibrated. When someone says an AI "knows" something, I remember that it placed a bet.&lt;/p&gt;

&lt;p&gt;That habit of asking is worth more than any single formula, and you do not need to be a mathematician to build it. You need a good teacher, a few well chosen examples, and the patience to look at an idea until it moves. If you want to see where this course lives, it is at &lt;a href="https://pai.stanford.edu" rel="noopener noreferrer"&gt;pai.stanford.edu&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;About the author&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm Sohaib Hasan. I have 9+ years of teaching experience in advanced mathematics and statistics, and I turn the ideas I teach into Manim animations, the kind that Prof. Chris Piech and fellow section leaders of Stanford's Probability for AI have appreciated.&lt;/p&gt;

&lt;p&gt;I share these animations on my YouTube channel, &lt;a href="https://www.youtube.com/@PlotLabAlgorithms" rel="noopener noreferrer"&gt;PlotLab Algorithms&lt;/a&gt;, where I teach data science, machine learning, cryptography, math, DSA and statistics visually, in the style made popular by 3Blue1Brown. Shorter clips live on &lt;a href="https://web.facebook.com/plotlab1/reels/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; (80K+ followers) and &lt;a href="https://www.instagram.com/plotlab01/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; (15K+ followers).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want an animation like this for your own work?&lt;/strong&gt; If you have a project, a research article, a thesis defense, a YouTube video, or any idea that is hard to explain with slides alone, I can turn it into a clear, professional animation. Reach out through my &lt;a href="https://sohaib-hasan.github.io/work-with-me.html" rel="noopener noreferrer"&gt;Work With Me&lt;/a&gt; page and tell me what you are working on. If you would rather learn to build animations yourself, start with my &lt;a href="https://plotlab1.gumroad.com/l/manim_guide_handbook" rel="noopener noreferrer"&gt;Manim CE Beginner's Handbook&lt;/a&gt;. And I'd like to hear what you think of this post, drop a comment.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>mathematics</category>
    </item>
    <item>
      <title>The One Idea Quietly Running Every Prediction App on Your Phone</title>
      <dc:creator>Sohaib Hassan</dc:creator>
      <pubDate>Thu, 22 Oct 2026 06:27:12 +0000</pubDate>
      <link>https://dev.to/sohaibhasan/the-one-idea-quietly-running-every-prediction-app-on-your-phone-38jc</link>
      <guid>https://dev.to/sohaibhasan/the-one-idea-quietly-running-every-prediction-app-on-your-phone-38jc</guid>
      <description>&lt;p&gt;Open your phone and look at three numbers. A weather app saying tomorrow will be 34 degrees. A property site showing what a house in your area is roughly worth. A ride app quoting your fare before the driver has even arrived.&lt;/p&gt;

&lt;p&gt;Every number like that comes from a model that learned from past data. Real products use far more sophisticated models than what I am about to show you. But the simplest, oldest member of that family is called linear regression, and almost everything fancier is built on the same core move. Understand that move once, in plain words, and you will start noticing it behind every prediction you see.&lt;/p&gt;

&lt;p&gt;I teach undergraduate mathematics, and I wrote this the way I would explain it to a friend who has never opened a statistics book. If you already write code, stay for the last third, there is a short Python section for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  You Already Do This, You Just Never Named It
&lt;/h2&gt;

&lt;p&gt;Think about the last time you sold an old phone on OLX or eBay. You did not open a calculator. You looked at what three or four similar phones sold for, same model, similar condition, and landed on a number somewhere in between. You did the same thing if you ever guessed what a plot of land was worth from the sales next door, or guessed how a student would do in a final exam after seeing the first two tests.&lt;/p&gt;

&lt;p&gt;Each time, your brain did one specific thing. It looked at a handful of known examples, noticed the pattern connecting them, and stretched that pattern forward to guess something it had never seen. Draw a line through what you know, then use it to predict what you do not. That is linear regression. You already had the instinct. A computer simply does it with numbers instead of a gut feeling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where This Family of Ideas Shows Up
&lt;/h2&gt;

&lt;p&gt;Once you know what to look for, it appears anywhere someone needs to predict a number from past data.&lt;/p&gt;

&lt;p&gt;A property site can estimate a home's price by learning how size, location and age related to price in thousands of past sales. A retailer can plan stock for Eid or Black Friday by learning how sales behaved in the weeks before it in past years. A bank scoring a loan applicant uses a close cousin of the same idea, usually logistic regression, which predicts a probability instead of a number. In my own classroom, I notice how revision hours relate to test scores, and I use that pattern to tell a new student roughly what to expect.&lt;/p&gt;

&lt;p&gt;The real systems behind big apps combine many more inputs and use more elaborate models than a single straight line. That is exactly the point: a straight line is the simplest version, and the elaborate versions are built on the same foundation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a Gut Feeling Needed Math
&lt;/h2&gt;

&lt;p&gt;If people have guessed this way for centuries, why did it become a formal piece of mathematics?&lt;/p&gt;

&lt;p&gt;Because instinct breaks when the problem gets big or the stakes get real. Ask ten people to price a plot from the same five examples and you will get ten different answers, because everyone draws the pattern a little differently in their head. That is fine for a phone resale. It is not fine when a system makes a million decisions a day.&lt;/p&gt;

&lt;p&gt;Math replaces "roughly in between" with one exact rule for finding the single best line through any data: the line that keeps the total mistake, across every example, as small as it can be. The method behind it, least squares, was first published by Legendre in 1805. It does not change with who runs it, does not get tired, and does not care whether there are five data points or five million. That is the real power math adds. Not a smarter guess, but a guess that can be trusted, repeated, and scaled.&lt;/p&gt;

&lt;h2&gt;
  
  
  For Developers: The Whole Thing in Five Lines
&lt;/h2&gt;

&lt;p&gt;Here is a tiny version with four students: hours studied against marks scored.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;polyfit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;   &lt;span class="c1"&gt;# 0.8 0.5
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;        &lt;span class="c1"&gt;# 4.5, the predicted marks for 5 hours
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The best line is &lt;code&gt;marks = 0.8 * hours + 0.5&lt;/code&gt;. Every extra hour of study is associated with 0.8 extra marks in this toy data, and a student who studied 5 hours is predicted to score 4.5. Those two numbers, the slope and the intercept, are the entire trained model.&lt;/p&gt;

&lt;p&gt;Two things are worth knowing as a developer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;There are two ways to find those numbers.&lt;/strong&gt; For a straight line there is a closed-form answer, which is what &lt;code&gt;polyfit&lt;/code&gt; uses. You can also start with a random line and nudge it downhill on the error, step by step, which is gradient descent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;That second way is how neural networks learn.&lt;/strong&gt; A single neuron with no activation function, trained to minimize squared error, is exactly this model. Stack many of them with nonlinear bends in between and you get the networks behind modern AI. The training loop looks conceptually the same: measure the error, nudge the parameters so the error shrinks, repeat.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So when people say linear regression is the grandparent of machine learning, it is not just a nice phrase. It is the smallest working example of how learning from data actually works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to See the Math by Hand?
&lt;/h2&gt;

&lt;p&gt;Most readers do not need to see a formula to use what they just learned. But if you are a student, or you simply want to watch the best line get calculated step by step with real numbers, I built a complete animated walkthrough using the same four point example:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/MQzgPcSX0Wc" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;It covers why the mistakes are measured the way they are, what the error looks like when you plot it, and how the two numbers above, 0.8 and 0.5, are worked out from scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Next Time You See a Prediction
&lt;/h2&gt;

&lt;p&gt;When an app gives you a price, a fare or an estimate before you have told it much, you now know the shape of what is behind it: look at what happened before, find the pattern, and stretch it forward. The models get bigger and the code gets cleverer, but that core idea has barely changed in over two hundred years.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;About the author&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm Sohaib Hasan. I have 9+ years of teaching experience in advanced mathematics and statistics, and I'm currently a section leader for Stanford's Probability for AI course, selected out of 2,700 participants from 70 countries to teach students from around the world. After each class, I explain the same ideas again through &lt;a href="https://www.youtube.com/playlist?list=PLUR1g6hiXfoQ" rel="noopener noreferrer"&gt;Manim animations&lt;/a&gt;, and I'm glad that Stanford professors and fellow section leaders have appreciated them.&lt;/p&gt;

&lt;p&gt;On my YouTube channel, &lt;a href="https://www.youtube.com/@PlotLabAlgorithms" rel="noopener noreferrer"&gt;PlotLab Algorithms&lt;/a&gt;, I teach data science, machine learning, cryptography, math, DSA, and statistics visually, in the style made popular by 3Blue1Brown. Shorter clips live on &lt;a href="https://web.facebook.com/plotlab1/reels/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; (80K+ followers) and &lt;a href="https://www.instagram.com/plotlab01/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; (15K+ followers).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want an animation like this for your own work?&lt;/strong&gt; If you have a project, a research article, a thesis defense, a YouTube video, or any idea that is hard to explain with slides alone, I can turn it into a clear, professional animation. Reach out through my &lt;a href="https://sohaib-hasan.github.io/work-with-me.html" rel="noopener noreferrer"&gt;Work With Me&lt;/a&gt; page and tell me what you are working on. If you would rather learn to build animations yourself, start with my &lt;a href="https://plotlab1.gumroad.com/l/manim_guide_handbook" rel="noopener noreferrer"&gt;Manim CE Beginner's Handbook&lt;/a&gt;. And I'd like to hear what you think of this post, drop a comment.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I Got 40,000 Facebook Followers in Just Two Months</title>
      <dc:creator>Sohaib Hassan</dc:creator>
      <pubDate>Wed, 02 Sep 2026 07:01:08 +0000</pubDate>
      <link>https://dev.to/sohaibhasan/how-i-got-40000-facebook-followers-in-just-two-months-160a</link>
      <guid>https://dev.to/sohaibhasan/how-i-got-40000-facebook-followers-in-just-two-months-160a</guid>
      <description>&lt;p&gt;Two months ago, my Facebook page had a small, quiet following. Today, more than 40,000 people follow it. I did not expect this to happen so fast, and I do not believe there is a secret trick behind it. But I do understand why it happened, and I want to explain it honestly, because the reason is actually more useful than a trick would be.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Actually Post
&lt;/h2&gt;

&lt;p&gt;My page is called PlotLab. I use it to turn mathematics into animation, using a Python library called &lt;a href="https://www.manim.community/" rel="noopener noreferrer"&gt;Manim&lt;/a&gt;, the same one that powers the diagrams in my other posts here. A definition that feels dry on a whiteboard becomes something a student can actually watch happen. A limit is not just a symbol anymore. You see a point moving closer and closer, step by step, until the idea makes sense on its own.&lt;/p&gt;

&lt;p&gt;This is not a new idea. Channels like 3Blue1Brown made this style popular for a general audience. What I do is narrower and, I think, more practical: I build these animations for the exact topics that undergraduate and school-level students struggle with the most, the ones I see them struggle with in my own classroom, every single semester.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fge6hx5953auxzgem09qt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fge6hx5953auxzgem09qt.png" alt=" " width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why It Actually Worked
&lt;/h2&gt;

&lt;p&gt;Here is the part I think matters most. I do not build an animation and then hope it is useful. I teach first, in a real classroom, with real students in front of me. When I notice the same confusion coming up again and again, on the same topic, I build the animation for that exact topic. Only after that does it go on Facebook or Instagram.&lt;/p&gt;

&lt;p&gt;So the content was never designed for social media first. It was designed for my own students first, and social media is simply where it happens to travel well too. I believe this order matters. It means every animation already solved a real confusion for a real student before a single stranger on the internet ever saw it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What People Actually Tell Me
&lt;/h2&gt;

&lt;p&gt;The most encouraging part of the last two months has not been the follower count. It has been the messages. Almost every day, someone writes to me in the comments or in my inbox to say that a concept they had struggled with for a long time finally made sense after watching one of these animations. Some are students preparing for exams. Some are people revisiting mathematics years after leaving school, just out of curiosity. The message is almost always some version of the same thing: this is the first time this idea actually made sense.&lt;/p&gt;

&lt;p&gt;That kind of feedback is why I keep making these, far more than the follower count itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn195ov6dgymwey9usncx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn195ov6dgymwey9usncx.png" alt=" " width="339" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to Find These Animations
&lt;/h2&gt;

&lt;p&gt;The main page is on &lt;a href="https://web.facebook.com/plotlab1/reels/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;, where the 40,000+ follower community lives. The same animations are also on &lt;a href="https://www.instagram.com/plotlab01/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;, which has grown to 15,000+ followers of its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Things I Built Because of This
&lt;/h2&gt;

&lt;p&gt;Once people started asking for more than just short videos, I built two things to answer that.&lt;/p&gt;

&lt;p&gt;The first is for people who want to learn to build animations like these themselves. I wrote everything I know about getting started with Manim into a single guide, from installing it correctly to the mistakes that waste the most time when you're new to it. It's called the &lt;a href="https://plotlab1.gumroad.com/l/manim_guide_handbook" rel="noopener noreferrer"&gt;Manim CE Beginner's Handbook&lt;/a&gt;, and it's written the same way I'd explain it to a student sitting next to me, not the way the official documentation explains it.&lt;/p&gt;

&lt;p&gt;The second is for students specifically preparing for IGCSE, O-Level, and GCSE exams. I built a complete set of notes covering the full syllabus, where every topic that's genuinely hard to picture from text alone is paired with a scannable code linking straight to the matching Manim animation. Alongside the theory, each topic includes worked examples, exam tips, the mistakes students make most often, and practice problems with a formula sheet for quick revision before an exam. You can find the full set on &lt;a href="https://plotlab1.gumroad.com" rel="noopener noreferrer"&gt;my Gumroad page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxcrs97yalb8xvuczpnbj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxcrs97yalb8xvuczpnbj.png" alt=" " width="789" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Result I Did Not Expect
&lt;/h2&gt;

&lt;p&gt;The most useful outcome of the last two months was not on Facebook at all. Researchers preparing for conference presentations started reaching out, asking if I could build an animation to explain a concept from their own research, the kind of concept that is genuinely hard to present clearly in a short talk using only slides and text. I said yes, and it turned into something I now offer properly: custom Manim-built explainers for research talks, thesis defenses, conference presentations, or coursework, built in the same style as PlotLab, with a fast turnaround.&lt;/p&gt;

&lt;p&gt;If that sounds like something you need, whether it's a concept from your own research, a topic for your students, or anything else where an idea needs to be seen and not just read, you can see how this works and reach out on my &lt;a href="https://sohaib-hasan.github.io/work-with-me.html" rel="noopener noreferrer"&gt;Work With Me&lt;/a&gt; page.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Take From This
&lt;/h2&gt;

&lt;p&gt;I did not grow this page by studying growth tactics. I grew it by solving a real problem for real students first, and only sharing the result afterward. If there is a lesson in that for anyone building an audience around their own work, I think it's this one: build for the person in front of you first. The audience online tends to follow, not the other way around.&lt;/p&gt;




&lt;p&gt;I lead the Mathematics Department at my college, and PlotLab is where I turn what I teach into animation. If you'd like to see more of the work, follow along on &lt;a href="https://web.facebook.com/plotlab1/reels/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; (40,000+ followers) or &lt;a href="https://www.instagram.com/plotlab01/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; (15,000+ followers). If you're a researcher, teacher, or student who needs something explained visually, reach out through my &lt;a href="https://sohaib-hasan.github.io/work-with-me.html" rel="noopener noreferrer"&gt;Work With Me&lt;/a&gt; page. I'd like to hear from you, drop a comment.&lt;/p&gt;

</description>
      <category>python</category>
      <category>education</category>
      <category>career</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I Built My Students an AI Assistant That's Not Allowed to Make Things Up</title>
      <dc:creator>Sohaib Hassan</dc:creator>
      <pubDate>Wed, 19 Aug 2026 18:40:41 +0000</pubDate>
      <link>https://dev.to/sohaibhasan/i-built-my-students-an-ai-assistant-thats-not-allowed-to-make-things-up-3eb5</link>
      <guid>https://dev.to/sohaibhasan/i-built-my-students-an-ai-assistant-thats-not-allowed-to-make-things-up-3eb5</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;How I built Classroom AI System, a free, RAG-grounded teaching assistant that only answers from my own course notes, plus the teacher dashboard it feeds, on a budget of exactly $0.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ask a generic AI chatbot a question about your course, and it will answer confidently, using its own notation, its own conventions, and occasionally its own facts. It doesn't know that you define a term slightly differently than the textbook does, or that a particular proof technique hasn't been covered yet, or that the "obvious" shortcut it just suggested isn't one your students are allowed to use on the exam. It will still answer. That's the problem.&lt;/p&gt;

&lt;p&gt;I teach undergraduate mathematics, and every semester the same pattern repeats: a handful of students ask sharp, specific questions in office hours, while dozens more ask ChatGPT the same questions late at night, when I'm not there to catch the moment an AI politely gets something wrong. So I built something that only answers from my own course notes, refuses to guess when it doesn't know, and, as a side effect, shows me exactly where an entire class is actually getting stuck. It's called &lt;strong&gt;Classroom AI System&lt;/strong&gt;, and the code is public: &lt;a href="https://github.com/Sohaib-Hasan/classroom_ai_system" rel="noopener noreferrer"&gt;github.com/Sohaib-Hasan/classroom_ai_system&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Grounded, Not Generic
&lt;/h2&gt;

&lt;p&gt;The technical name for what makes this different is retrieval-augmented generation, RAG for short. Instead of asking a language model to answer from everything it was trained on, the system first retrieves the exact passage from my own LaTeX course notes most relevant to a student's question, then instructs the model to answer strictly from that passage and nothing else. Right now the knowledge base covers Calculus, Discrete Mathematics, and Number Theory, chunked chapter by chapter from the same notes I hand out in class.&lt;/p&gt;

&lt;p&gt;The system is two separate apps sharing one brain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;student assistant&lt;/strong&gt;, PIN-gated, where students type a question and get an answer grounded in the actual notes.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;teacher dashboard&lt;/strong&gt;, password-gated, where I see what's being asked across the whole class: which topics come up again and again, which questions the cache is already handling, and where the same confusion is repeating across different students.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How a Question Actually Gets Answered
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffuw0vprh446hfas2pg3x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffuw0vprh446hfas2pg3x.png" alt=" " width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Getting from ".tex notes" to "trustworthy answer" happens in two stages. The first, indexing, happens once, offline, whenever my notes change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 chunk_notes.py      &lt;span class="c"&gt;# .tex notes  -&amp;gt;  raw chunks (one per definition/example/theorem/proof)&lt;/span&gt;
python3 clean_chunks.py     &lt;span class="c"&gt;# strips decorative LaTeX, keeps the real math&lt;/span&gt;
python3 embed_chunks.py     &lt;span class="c"&gt;# embeds every cleaned chunk into knowledge_base.json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second stage happens live, every time a student asks something: the question gets embedded and compared against the knowledge base by cosine similarity, the closest matching chunks get pulled out, and only those chunks, together with the question, get sent to Gemini for an answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Step That Almost Broke Everything
&lt;/h2&gt;

&lt;p&gt;The middle step, &lt;code&gt;clean_chunks.py&lt;/code&gt;, sounds like the least interesting part of the pipeline. It's the one that mattered most.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chunk_notes.py&lt;/code&gt; extracts each definition, example, or theorem box straight out of the raw &lt;code&gt;.tex&lt;/code&gt; source, decorative markup and all: color commands, tables, diagram code, spacing macros. That raw text becomes part of the prompt the model sees for every question. Skip the cleaning step, and the model will occasionally echo a fragment of that raw markup straight back to a student, so instead of a clean explanation they see broken LaTeX code on their screen. &lt;code&gt;clean_chunks.py&lt;/code&gt; strips all of that decoration out while leaving the real &lt;code&gt;$...$&lt;/code&gt; math completely untouched, so the model only ever sees the content, never the formatting noise around it. It's a small, unglamorous script, and the whole system's credibility depends on it running before every embedding pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making It Work on a Budget of Exactly $0
&lt;/h2&gt;

&lt;p&gt;This runs entirely on Gemini's free tier, which means every question costs quota, and quota is the actual scaling limit. A few decisions keep that from becoming a wall:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-key rotation.&lt;/strong&gt; Gemini's rate limits apply per Google Cloud project, not per key, so keys from separate accounts draw from independent quota pools. The system supports up to three keys and falls through to the next one only if a call fails, invisibly to the student asking the question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching.&lt;/strong&gt; A SQLite-backed cache means a rephrased version of a question someone already asked skips the generation call entirely, which matters a lot in a class where dozens of students hit the same handful of confusing topics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local embeddings.&lt;/strong&gt; Every question needs an embedding call, even on a cache hit, which makes it the single biggest quota consumer in the whole system. Swapping the embedding provider to a free local model removes that cost entirely, at the price of having to rebuild the knowledge base once, since Gemini and local embeddings aren't compatible with each other.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A per-session rate limit.&lt;/strong&gt; Eight questions per rolling 60 seconds per browser session, mostly as a safety net against an accidental double-submit rather than a real constraint on normal use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Two Apps, One Shared Brain
&lt;/h2&gt;

&lt;p&gt;The student assistant and the teacher dashboard are deployed as two separate Streamlit Cloud apps, on two different URLs, each running in its own isolated container. That last part turned into the trickiest infrastructure problem in the whole project: a local SQLite file that one container writes to simply doesn't exist for the other one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fekensw40l9nukgj4wgle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fekensw40l9nukgj4wgle.png" alt=" " width="800" height="551"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix is &lt;a href="https://turso.tech" rel="noopener noreferrer"&gt;Turso&lt;/a&gt;, a free, hosted, SQLite-compatible database that both apps point to instead of their own local files. Two details in that setup cost real debugging time and are worth writing down: the connection string has to use &lt;code&gt;https://&lt;/code&gt;, not &lt;code&gt;libsql://&lt;/code&gt;, because the WebSocket handshake &lt;code&gt;libsql://&lt;/code&gt; relies on can fail inside Streamlit Cloud's sandboxed environment, and the secret key has to be named exactly &lt;code&gt;TURSO_AUTH_TOKEN&lt;/code&gt;. Get either of those wrong and there's no crash, no error message, just a dashboard that stays quietly empty with nothing to explain why.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the Teacher Actually Sees
&lt;/h2&gt;

&lt;p&gt;This is the part that matters most to me as a teacher, and it's the part a generic AI chatbot can never give you. Office hours show me the questions the handful of students who show up are willing to ask out loud. The dashboard shows me every question the whole class actually had: which topic keeps coming back, which confusion is repeating across students who've never spoken to each other, what the cache is already absorbing versus what's genuinely new. It's the difference between a handful of anecdotes and an actual signal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built to Not Break Quietly
&lt;/h2&gt;

&lt;p&gt;The business logic lives in &lt;code&gt;core.py&lt;/code&gt;, which deliberately has no dependency on Streamlit at all, so it can be tested completely independently of the app itself. Right now it's backed by 91 automated tests, and every one of them exists because a specific bug was found and fixed, not because of abstract coverage targets. One example I'm particularly fond of: the system's &lt;code&gt;verify_computation()&lt;/code&gt; check samples the negative, positive, &lt;em&gt;and&lt;/em&gt; near-zero domains of a function, not just the positive ones, specifically because a positive-only check would miss domain-sensitive errors like treating &lt;code&gt;sqrt(x**2)&lt;/code&gt; as equal to &lt;code&gt;x&lt;/code&gt;, which only holds when &lt;code&gt;x&lt;/code&gt; is non-negative. That's the kind of bug that looks fine in a quick demo and quietly produces wrong math for a student six weeks later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where It's Still Rough
&lt;/h2&gt;

&lt;p&gt;A few honest limitations, because a system that grades student proofs owes its builder the same standard: nested LaTeX boxes of the same type (a definition box inside another definition box) aren't parsed cleanly yet, though a safety check flags this loudly the moment it happens rather than letting it reach a student silently. The automated cleaning handles the large majority of decorative LaTeX but not all of it: roughly 3% of chunks, mostly color commands sitting inside real math, still need a manual look. And there's an optional third-party fallback provider for when every Gemini key is exhausted that I've built but haven't yet stress-tested in production, so for now it's a safety net I wouldn't lean on.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;The next thing I'm building on top of this is a guided answering mode: instead of jumping straight to a full solution, the system will offer a hint first, then a guiding question, and only give the complete answer if the student actually wants it. The goal was never to hand out finished proofs faster. It's to get a student unstuck without doing their thinking for them.&lt;/p&gt;

&lt;p&gt;That's really the whole premise behind this project, and behind the broader direction I want to take my teaching: AI that's useful specifically because it's constrained, not despite it.&lt;/p&gt;




&lt;p&gt;I lead the Mathematics Department at my college and build tools like this one alongside my Manim animation work as PlotLab. If you teach and are curious whether something like this could work for your own courses, or if you'd like help building it, reach out. I write more like this at &lt;a href="https://sohaib-hasan.github.io" rel="noopener noreferrer"&gt;sohaib-hasan.github.io&lt;/a&gt;, and if you want to see the kind of animated explanations I build separately from this project, they're on &lt;a href="https://web.facebook.com/plotlab1/reels/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; (35K+ followers) and &lt;a href="https://www.instagram.com/plotlab01/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; (15K+ followers). I'd like to hear what you think, drop a comment.`&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>education</category>
      <category>opensource</category>
    </item>
    <item>
      <title>AI Just Posted a Perfect Score at the Real Math Olympiad. I Spent Months Building One of These Systems. Here's What It Actually Takes</title>
      <dc:creator>Sohaib Hassan</dc:creator>
      <pubDate>Sat, 08 Aug 2026 08:55:32 +0000</pubDate>
      <link>https://dev.to/sohaibhasan/ai-just-posted-a-perfect-score-at-the-real-math-olympiad-i-spent-months-building-one-of-these-25c1</link>
      <guid>https://dev.to/sohaibhasan/ai-just-posted-a-perfect-score-at-the-real-math-olympiad-i-spent-months-building-one-of-these-25c1</guid>
      <description>&lt;p&gt;In July 2026, in Shanghai, something happened that mathematicians had been debating for two years: AI systems from Huawei and Xiaohongshu were each reported to have solved all six problems of the International Mathematical Olympiad, a perfect 42 out of 42. Several other labs reported matching results on their own. It followed a 2025 breakthrough where Google DeepMind's Gemini Deep Think, officially graded by IMO coordinators, and an OpenAI experimental model both reached the gold-medal threshold of 35/42.&lt;/p&gt;

&lt;p&gt;Headlines called it AI "beating" the world's best teenage mathematicians. I want to tell you what's actually behind a headline like that, not as a journalist, but as someone who spent the past several months building a much smaller, much less glamorous version of exactly this kind of system.&lt;/p&gt;

&lt;p&gt;My teammate Samuel Koh and I entered AIMO3, the third AI Mathematical Olympiad Progress Prize, hosted on Kaggle. We scored 42 out of 50, placing 495th out of 4,138 teams, the top 12% globally. Here's the honest, unglamorous story of how we got there, what we tried that failed, and what the finished system actually looks like under the hood.&lt;/p&gt;

&lt;h2&gt;
  
  
  What AIMO Actually Is (And Why It's Not the IMO)
&lt;/h2&gt;

&lt;p&gt;First, an important distinction, because the acronyms get confusing fast: AIMO is not the IMO.&lt;/p&gt;

&lt;p&gt;The AI Mathematical Olympiad is a $10 million prize fund, created in 2023, that exists specifically to close the gap between what the closed, proprietary models at OpenAI and Google can do and what the open community can build. Its grand prize, $5 million, goes to the first team that publicly shares a model capable of gold-medal-equivalent performance at the actual IMO. Along the way, Kaggle hosts periodic "Progress Prize" competitions to measure how far the open field has come.&lt;/p&gt;

&lt;p&gt;AIMO1 was won by Project Numina in 2024. AIMO2 was won by NVIDIA's team, NemoSkills, who solved 34 of 50 problems. AIMO3, the one we entered, raised the difficulty again: 110 entirely original problems, ranging from national-olympiad level up to full IMO standard, spanning algebra, combinatorics, geometry, and number theory. "Entirely original" matters enormously here: it means no amount of memorization from training data helps you. Every problem has to be reasoned through, not recalled.&lt;/p&gt;

&lt;p&gt;Competitors were also given access to H100 GPUs, roughly double the compute of AIMO2, which meant we could run larger open-weight models than previous years: models like GPT-OSS-120B and Qwen3-Next became viable for the first time.&lt;/p&gt;

&lt;p&gt;So when you read that an AI "scored a perfect IMO," understand what's actually being claimed. In 2026, most of those results, including the ones from Huawei and Xiaohongshu, were the companies' own self-reported submissions, run after the human competition window closed, evaluated against the same problems and time limit but not scored live by IMO coordinators. Only a small number of 2025 and 2026 results have been independently, officially graded. That's not a reason to dismiss the progress. It's real, and it's fast. But it's worth knowing the difference between "officially certified" and "self-administered" when you see the next big claim.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Rules That Shaped Every Decision We Made
&lt;/h2&gt;

&lt;p&gt;Before I describe what we built, you need to understand the two constraints that made this hard, because they killed almost every "obvious" idea we had.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule one: five hours of GPU compute, total, per problem set.&lt;/strong&gt; Not per problem. Per set. That immediately rules out anything computationally greedy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule two: binary scoring, no partial credit.&lt;/strong&gt; A problem is either fully correct or fully wrong. This sounds simple, but it has a brutal implication: a system that produces a plausible, confident-sounding, but wrong answer is worse than a "generic" wrong answer, because it's confidently wrong. Under this rule, knowing when your system is unsure is almost as valuable as getting the right answer.&lt;/p&gt;

&lt;p&gt;I handled the mathematical side: interpreting problems, checking whether a given line of reasoning was actually valid, and sourcing harder test cases beyond the standard dataset to stress-test our system. Samuel handled the engineering: building and running the inference pipeline under that fixed compute budget. Neither role alone was enough. The problems weren't purely mathematical, and they weren't purely a systems problem either.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four Ideas We Killed Before Writing a Line of the Final System
&lt;/h2&gt;

&lt;p&gt;Here's what we considered and rejected, and why each one matters as a lesson, not just a footnote:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supervised fine-tuning.&lt;/strong&gt; The obvious first instinct. Rejected immediately: it needs massive GPU clusters and months of runway, not a fixed five-hour, competition-scale budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fully agentic search&lt;/strong&gt;, a system that breaks a problem into steps, calls tools, verifies intermediate results, and loops back on itself. Conceptually, this is the closest thing to how a human mathematician actually thinks. We rejected it anyway, because Kaggle's environment has no outbound internet access, and an open-ended agentic loop risked silently burning our entire compute budget before ever producing a final answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monte Carlo Tree Search.&lt;/strong&gt; Not used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long, verbose chain-of-thought prompting.&lt;/strong&gt; We tested it. Concise prompting consistently outperformed it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pattern across all four rejections is the same one that ended up defining our whole approach: under a fixed, non-negotiable compute budget, a simpler system you can actually trust beats a theoretically more powerful one you can't fully control.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Architecture: A Parallel Self-Consistency Pipeline
&lt;/h2&gt;

&lt;p&gt;What we actually built and submitted, we called a &lt;strong&gt;Parallel Self-Consistency Pipeline&lt;/strong&gt;. Here's how a single problem moves through it, end to end:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faxfy29tmu8cyv8byzsb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faxfy29tmu8cyv8byzsb1.png" alt=" " width="800" height="876"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The problem&lt;/strong&gt; is written in LaTeX and gets converted into a structured prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The base model&lt;/strong&gt;, GPT-OSS-120B (OpenAI's open-weight mixture-of-experts model, around 120 billion total parameters but only about 5 billion active per token, which is exactly why it fits on a single H100 despite its size), generates a reasoning attempt at temperature 0.8.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Parallel Sampler&lt;/strong&gt; does this eight times, independently, all at once. This is the "self-consistency" idea, and it's built on a real insight from a 2022 paper by Wang et al.: a single reasoning chain can silently go wrong at any step with no way to catch it, but across eight independent attempts, correct reasoning tends to converge on the same answer while failure modes tend to scatter in different directions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool-Integrated Reasoning.&lt;/strong&gt; Each of those eight attempts is paired with a live Python interpreter. The moment a reasoning chain hits a calculation it can't reliably do purely in text, it hands that calculation off to Python instead of guessing, a small design choice that removes an entire category of careless arithmetic errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Entropy-Weighted Aggregator.&lt;/strong&gt; This is the part I'm proudest of. Instead of a simple majority vote across the eight candidate answers, each one is scored by:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;score&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;H&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;8.0&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;⋅&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Here, &lt;em&gt;H&lt;/em&gt; is the mean generation entropy of that attempt (how "confident" the model was, token by token, while producing it) and &lt;em&gt;V&lt;/em&gt; is a verifier score. Because the formula uses 1/H, a low-entropy, confident attempt scores higher than a scattered, uncertain one, even if it wasn't the majority answer. There's also an early-stopping rule: if any single answer already has four or more votes, the aggregator stops and submits it immediately, saving compute for the next problem instead of waiting out the clock.&lt;/p&gt;

&lt;p&gt;I actually animated this entire pipeline in Manim: every arrow, every fan-out, every step of the aggregation, so you can watch it play out visually instead of just reading a static diagram:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/qOPH9anSiw4" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  From 8/50 to 42/50: What the Climb Actually Looked Like
&lt;/h2&gt;

&lt;p&gt;Our first working version of this pipeline scored 8 out of 50. The final version scored 42. That climb didn't come from one clever trick. It came from three unglamorous things, repeated over and over: systematically diagnosing bugs in the pipeline itself, upgrading the base model as better open-weight options became available, and steadily refining the few-shot prompts feeding into step one.&lt;/p&gt;

&lt;p&gt;There's one more data point that told us we were on the right track, and it came after the competition closed. The eventual first-place team's public writeup also centered on GPT-OSS-120B, and their approach was also built around entropy-weighted self-consistency, refined further with things like adaptive runtime scheduling, but directionally the same idea we'd arrived at independently. When a team with more resources converges on the same core mechanism you did, without either of you seeing the other's work, that's a stronger signal than any single benchmark score.&lt;/p&gt;

&lt;h2&gt;
  
  
  The One Lesson I'd Give Anyone Building AI Under Real Constraints
&lt;/h2&gt;

&lt;p&gt;Every rejected idea (fine-tuning, agentic search, tree search, verbose prompting) failed for a version of the same reason: it added complexity we couldn't fully control inside a budget we couldn't negotiate. The thing that actually worked was the opposite: precision and reliability over architectural cleverness.&lt;/p&gt;

&lt;p&gt;That's not a lesson specific to Kaggle competitions. It's true anywhere you're building an AI system against a real constraint: a latency budget, a cost ceiling, a compliance requirement. The fanciest architecture on paper is worth nothing if you can't trust what it does when the clock is running.&lt;/p&gt;

&lt;p&gt;As for the "AI beat the Olympiad" headlines, they're not wrong, exactly. The field genuinely moved from silver-medal level in 2024, to officially certified gold in 2025, to multiple perfect-score claims in 2026, in about two years. I watched a smaller version of that same curve happen inside my own project, going from 8/50 to 42/50 in a few months of iteration. The trend is real. Just read the fine print on "official" versus "self-reported" before you decide how impressed to be by any single claim.&lt;/p&gt;




&lt;p&gt;I've taught undergraduate mathematics for 9+ years, and I build Manim-animated math content as PlotLab. If you want to learn the exact animation workflow shown in the diagram above, from your first &lt;code&gt;Scene&lt;/code&gt; to a full multi-step pipeline animation, I wrote a complete, copy-paste-ready guide: &lt;a href="https://plotlab1.gumroad.com/l/manim_guide_handbook" rel="noopener noreferrer"&gt;Manim CE Beginner's Handbook&lt;/a&gt;. If you'd rather have someone build it for you, for an undergraduate or graduate thesis defense, a research paper, or any project where the math needs actually to look as good as it sounds, I take on that work directly; you can see the quality for yourself on &lt;a href="https://web.facebook.com/plotlab1/reels/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; (35K+ followers) and &lt;a href="https://www.instagram.com/plotlab01/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; (15K+ followers), and reach out if you'd like to work together. I write more essays like this one on mathematics, AI reasoning, Manim Animations, and teaching at &lt;a href="https://sohaib-hasan.github.io" rel="noopener noreferrer"&gt;sohaib-hasan.github.io&lt;/a&gt;. I'd genuinely like to hear what you think of the pipeline above; drop a comment.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>mathematics</category>
      <category>kaggle</category>
    </item>
    <item>
      <title>I Spent 5 Years Making Math Animations in Python. Here's Everything I Wish I Knew on Day One.</title>
      <dc:creator>Sohaib Hassan</dc:creator>
      <pubDate>Wed, 29 Apr 2026 12:04:54 +0000</pubDate>
      <link>https://dev.to/sohaibhasan/i-spent-5-years-making-math-animations-in-python-heres-everything-i-wish-i-knew-on-day-one-5054</link>
      <guid>https://dev.to/sohaibhasan/i-spent-5-years-making-math-animations-in-python-heres-everything-i-wish-i-knew-on-day-one-5054</guid>
      <description>&lt;h2&gt;
  
  
  A complete, honest guide to building 3Blue1Brown-style math animations with Manim CE — from zero setup to your first polished scene. No fluff, just what actually works.
&lt;/h2&gt;

&lt;p&gt;The first time I tried to make a math animation, I spent four hours staring at an error message I didn't understand.&lt;/p&gt;

&lt;p&gt;No one warned me about LaTeX dependencies. No one explained the difference between &lt;code&gt;Text&lt;/code&gt; and &lt;code&gt;MathTex&lt;/code&gt;. No one told me why my equation was rendering in the wrong position — or why my animation was playing twice — or why the camera was cutting off half my scene.&lt;/p&gt;

&lt;p&gt;I figured it out eventually. But it took months, not days.&lt;/p&gt;

&lt;p&gt;If you're reading this, you probably want to create math animations. Maybe you've watched 3Blue1Brown explain calculus and thought &lt;em&gt;"I want to make something like that."&lt;/em&gt; Maybe you teach mathematics and you're tired of static diagrams that put students to sleep. Maybe you're just curious whether Python can actually produce beautiful, publication-quality math visuals.&lt;/p&gt;

&lt;p&gt;It can. And it's more accessible than you think.&lt;/p&gt;

&lt;p&gt;But only if someone shows you where to actually start.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Manim — And Why Does It Matter?
&lt;/h2&gt;

&lt;p&gt;Manim is an open-source Python library built specifically for mathematical animations. Every equation you render is typeset through LaTeX. Every shape, every graph, every transformation is mathematically precise — not visually approximate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is what separates Manim from every other animation tool.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you draw a circle in Manim, it's a &lt;em&gt;perfect&lt;/em&gt; circle — defined mathematically, rendered with zero distortion. When you write a quadratic formula, it looks exactly like a published research paper. When you animate a transformation, every frame is calculated programmatically.&lt;/p&gt;

&lt;p&gt;This is why educators, researchers, and content creators around the world have adopted it. Not because it's easy — but because nothing else produces results like this.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Mistake Everyone Makes on Day One
&lt;/h2&gt;

&lt;p&gt;Most beginners open Manim, look at the documentation, and immediately feel overwhelmed.&lt;/p&gt;

&lt;p&gt;The documentation is comprehensive — but it's not written for beginners. It assumes you already know what you're looking for. If you don't, you'll spend hours reading without actually building anything.&lt;/p&gt;

&lt;p&gt;Here's the truth: &lt;strong&gt;you learn Manim by writing scenes, not by reading documentation.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every concept clicks the moment you run working code and see it render. Not before.&lt;/p&gt;

&lt;p&gt;This is why the &lt;em&gt;copy-paste-first&lt;/em&gt; approach works so much better than theory-first learning.&lt;/p&gt;




&lt;h2&gt;
  
  
  What You Actually Need to Get Started
&lt;/h2&gt;

&lt;p&gt;Before writing your first scene, you need four things — and three of them are completely free.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Python 3.9 or later&lt;/strong&gt;&lt;br&gt;
If you already have Python installed, you're halfway there. If not, the official Python website has a one-click installer for every OS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Manim CE v0.20.1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;&lt;span class="nv"&gt;manim&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;0.20.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. A LaTeX Distribution&lt;/strong&gt; ← &lt;em&gt;This is where most beginners get stuck&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Manim uses LaTeX to render equations. You need either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MiKTeX&lt;/strong&gt; (Windows)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TeX Live&lt;/strong&gt; (Mac/Linux)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both are free. Both take about 15 minutes to set up. &lt;strong&gt;Do not skip this step&lt;/strong&gt; — skipping it is why 80% of "Manim doesn't work" posts exist on forums.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. VS Code&lt;/strong&gt;&lt;br&gt;
Any text editor works, but VS Code gives you syntax highlighting, terminal integration, and extensions that make Manim development significantly smoother.&lt;/p&gt;

&lt;p&gt;That's the entire setup. No subscriptions. No expensive software. No complicated configuration beyond these four things.&lt;/p&gt;


&lt;h2&gt;
  
  
  Your First Scene — What It Looks Like
&lt;/h2&gt;

&lt;p&gt;Here is the simplest possible Manim scene. Copy this exactly, save it as &lt;code&gt;first_scene.py&lt;/code&gt;, and run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;manim&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HelloManim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Scene&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;equation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MathTex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;equation&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Render it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;manim &lt;span class="nt"&gt;-pql&lt;/span&gt; first_scene.py HelloManim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In under ten seconds, you'll have a video of the quadratic formula writing itself onto the screen — typeset perfectly, animated smoothly.&lt;/p&gt;

&lt;p&gt;That's Manim. That's what three lines of actual code produce.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Always use &lt;code&gt;-pql&lt;/code&gt; (low quality) while developing.&lt;/strong&gt; High-quality renders take minutes. Save &lt;code&gt;-pqh&lt;/code&gt; for your final output only.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Five Concepts That Unlock Everything
&lt;/h2&gt;

&lt;p&gt;After years of building animations, I can tell you that 90% of what you'll ever need in Manim comes down to five core concepts.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;MathTex&lt;/code&gt; and &lt;code&gt;Text&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;MathTex&lt;/code&gt; renders LaTeX equations. &lt;code&gt;Text&lt;/code&gt; renders plain words. Knowing when to use which — and how to color individual parts of an equation — is the foundation of every math explainer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Correct — renders LaTeX
&lt;/span&gt;&lt;span class="n"&gt;equation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MathTex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;E = mc^2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Wrong for equations — won't render LaTeX
&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;E = mc^2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Shapes and Geometry
&lt;/h3&gt;

&lt;p&gt;Circles, squares, triangles, lines, arcs — all mathematically defined, all fully customizable. Once you understand how positioning works in Manim, placing objects exactly where you want them takes seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;circle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;BLUE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;side_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;GREEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;square&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next_to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;RIGHT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;buff&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Animations and Transforms
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Write&lt;/code&gt;, &lt;code&gt;Create&lt;/code&gt;, &lt;code&gt;FadeIn&lt;/code&gt;, &lt;code&gt;Transform&lt;/code&gt;, &lt;code&gt;ReplacementTransform&lt;/code&gt; — these are the &lt;em&gt;verbs&lt;/em&gt; of Manim. Each one does something specific, and choosing the right one makes the difference between an animation that feels natural and one that feels jarring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;equation&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;           &lt;span class="c1"&gt;# draws stroke by stroke
&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;FadeIn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;            &lt;span class="c1"&gt;# fades in from transparent
&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;square&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# morphs one shape into another
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. &lt;code&gt;NumberPlane&lt;/code&gt; and Graphs
&lt;/h3&gt;

&lt;p&gt;Plotting functions in Manim is remarkably clean. Define your axes, pass a lambda function, and Manim draws it — with full control over color, range, and style.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;axes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Axes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;y_range&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;graph&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;axes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axes&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nc"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Updaters and &lt;code&gt;ValueTracker&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This is where Manim becomes truly powerful. Updaters let objects respond dynamically to changing values — this is how you create animations where a tangent line moves along a curve, or a point traces a parametric path in real time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tracker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ValueTracker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;dot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;always_redraw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Dot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;c2p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_value&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;RED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;run_time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Common Mistakes That Cost Beginners Hours
&lt;/h2&gt;

&lt;p&gt;I made every single one of these. You don't have to.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mistake&lt;/th&gt;
&lt;th&gt;What to do instead&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rendering high quality every time&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;-pql&lt;/code&gt; while building. Switch to &lt;code&gt;-pqh&lt;/code&gt; only for the final render.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Not using &lt;code&gt;VGroup&lt;/code&gt; for positioning&lt;/td&gt;
&lt;td&gt;Group related objects with &lt;code&gt;VGroup&lt;/code&gt; — positioning a group is infinitely cleaner than positioning each object individually.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hardcoding coordinates&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;.next_to()&lt;/code&gt;, &lt;code&gt;.shift()&lt;/code&gt;, &lt;code&gt;.move_to()&lt;/code&gt;. Your layout will survive any change you make.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Using &lt;code&gt;Text&lt;/code&gt; for equations&lt;/td&gt;
&lt;td&gt;If your equation looks wrong — jagged, unstyled, broken — you're almost certainly using &lt;code&gt;Text&lt;/code&gt; when you should be using &lt;code&gt;MathTex&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One long &lt;code&gt;construct()&lt;/code&gt; method&lt;/td&gt;
&lt;td&gt;Break your scene into helper methods. A readable scene is a maintainable scene — especially when you return to it three weeks later.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  A Complete Working Example — From Zero to Polished
&lt;/h2&gt;

&lt;p&gt;Here's a scene that combines everything above. Copy it, run it, and modify it as your own starting template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;manim&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;QuadraticExplainer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Scene&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Title
&lt;/span&gt;        &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Solving a Quadratic Equation&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UP&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

        &lt;span class="c1"&gt;# Standard form
&lt;/span&gt;        &lt;span class="n"&gt;standard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MathTex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ax^2 + bx + c = 0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;standard&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Transform to quadratic formula
&lt;/span&gt;        &lt;span class="n"&gt;formula&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MathTex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;font_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ReplacementTransform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;standard&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;formula&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Highlight the discriminant
&lt;/span&gt;        &lt;span class="n"&gt;formula&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;set_color&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;discriminant_label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;discriminant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;YELLOW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;discriminant_label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next_to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formula&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DOWN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;discriminant_label&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;manim &lt;span class="nt"&gt;-pql&lt;/span&gt; scene.py QuadraticExplainer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Where to Go From Here
&lt;/h2&gt;

&lt;p&gt;Manim has a learning curve — but it's not as steep as it looks from the outside. The moment your first animation renders, something shifts. You stop seeing it as code and start seeing it as a creative tool.&lt;/p&gt;

&lt;p&gt;The path forward is simple: &lt;strong&gt;build scenes.&lt;/strong&gt; Start with something small — an equation, a shape, a simple transform. Then add complexity one layer at a time.&lt;/p&gt;

&lt;p&gt;I spent years on this path. I documented everything — every mistake, every shortcut, every pattern I kept returning to — into a structured beginner handbook:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://plotlab1.gumroad.com/l/manim_guide_handbook" rel="noopener noreferrer"&gt;📘 Manim CE v0.20.1 Beginner Handbook&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ten complete chapters. Copy-paste-ready code for every concept above. Common mistakes are prefixed before you hit them. 60 pages.&lt;/p&gt;

&lt;p&gt;If you want to see what Manim looks like in practice before committing to anything, the animations are here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://instagram.com/plotlab01" rel="noopener noreferrer"&gt;📱 @plotlab01 on Instagram&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Start building. The best math animation you'll ever make is the next one.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;About the author:&lt;/strong&gt; Sohaib Hasan is a Mathematics Lecturer with 9 years of experience and 1,500+ students taught. He creates 3Blue1Brown-style math animations using Python and Manim, and shares them at &lt;a href="https://instagram.com/plotlab01" rel="noopener noreferrer"&gt;@plotlab01&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>mathematics</category>
    </item>
  </channel>
</rss>
