{"slug": "how-to-learn-maths-and-cs-with-ai-without-fooling-yourself", "title": "How to learn maths and CS with AI without fooling yourself", "summary": "A developer and teacher argues that using AI to learn hard maths and computer science works best when a textbook or lecture notes provide the structure and the model is confined to narrower roles: generating ungraded exercises, locating the first mistake in a written attempt, and supplying worked numeric examples. The approach pairs AI assistance with independent verification, such as comparing a solution against a brute-force reference on random inputs—a test that caught a common Kadane's algorithm variant returning 0 for an all-negative array—or checking formulas at small values of n.", "body_md": "If you're using AI to learn a hard maths or CS topic, I'd stop asking it for tutorials. A generated tutorial reads smoothly and you come away feeling you've understood it, but you haven't done anything yet, and doing it is the part that makes it stick.\n\nWhat has worked better for me and for the people I teach is keeping a proper textbook or set of lecture notes as the spine. Somebody who knows the subject has already decided the order things come in and which examples matter. The AI then gets two narrower jobs.\n\nOnce you've read a section, ask for five exercises on it that go from routine to hard, without the answers, and do them on paper. Then paste your attempt and ask where the first mistake is. Don't ask it to grade the whole thing, because it'll tend to tell you a mostly-right answer is fine.\n\nAlso, if an explanation it gives you feels more complicated than the topic, ask for one worked example with real numbers before any general statement. That is usually the bit that's missing.\n\nFor computer science this part is fairly easy, because you can write the slowest version you're sure is correct next to your own solution and compare the two on lots of small random inputs. You can see it on the maximum subarray problem (Kadane's algorithm next to a common wrong version of it, with a brute force over every subarray as the referee):\n\n``` python\nimport random\n\ndef kadane(a):\n    best = cur = a[0]\n    for x in a[1:]:\n        cur = max(x, cur + x)\n        best = max(best, cur)\n    return best\n\ndef kadane_wrong(a):          # starts from 0, a version you'll see often\n    best = cur = 0\n    for x in a:\n        cur = max(0, cur + x)\n        best = max(best, cur)\n    return best\n\ndef brute(a):\n    return max(sum(a[i:j]) for i in range(len(a)) for j in range(i + 1, len(a) + 1))\n\nfor f in (kadane, kadane_wrong):\n    random.seed(1)\n    for _ in range(1000):\n        a = [random.randint(-5, 5) for _ in range(random.randint(1, 6))]\n        if f(a) != brute(a):\n            print(f.__name__, \"fails on\", a, f(a), brute(a))\n            break\n    else:\n        print(f.__name__, \"passes 1000 tests\")\n```\n\nRunning it prints:\n\n```\nkadane passes 1000 tests\nkadane_wrong fails on [-5, -5, -5] 0 -5\n```\n\nThe wrong version returns 0 for a list where every number is negative, because it lets the empty subarray count (and that has a sum of 0). I think you and the AI could both read straight past that in the code, whereas the random test finds it almost immediately and even hands you a three-element input that shows the bug.\n\nFor maths the equivalent is plugging small numbers in, so if you've derived a formula you'd try it at n = 1, 2 and 3 and compare it with a direct count. Suppose you've worked out that the number of pairs you can choose from n people is 2n(n+1) . At n = 2 that gives 3, although two people obviously make only one pair. The right formula is (2n)=2n(n−1) , which gives 0, 1, 3, 6 for n = 1 to 4. A check like this usually takes about a minute, and in my experience it catches the AI's mistakes just as often as your own.\n\nIn practice I'd read a section of the book and do the AI's exercises on paper, then ask it where your first mistake is and test anything that can be run or counted. It's probably slower than reading generated notes, although by the end of each week you'll find you can actually do the problems yourself.\n\nIf you're studying computer science, the coding practice at [https://academicquant.co.uk/coding?utm_source=devto&utm_medium=post&utm_campaign=devto-ai-learn-maths-cs](https://academicquant.co.uk/coding?utm_source=devto&utm_medium=post&utm_campaign=devto-ai-learn-maths-cs) works on the same principle (every problem has tests whose answers come from an independent brute-force version, in six languages), so you can check your own solution yourself without having to take anyone's word for it.", "url": "https://wpnews.pro/news/how-to-learn-maths-and-cs-with-ai-without-fooling-yourself", "canonical_source": "https://dev.to/academicquant/how-to-learn-maths-and-cs-with-ai-without-fooling-yourself-32ic", "published_at": "2026-11-21 09:06:03+00:00", "updated_at": "2026-11-21 09:12:01.510934+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-tools"], "entities": [], "also_reported_by": [], "takeaway": "Verify AI-assisted derivations with an independent referee—a brute-force implementation on random small inputs or a formula checked at n=1,2,3—since a common Kadane's variant that starts from 0 fails on [-5,-5,-5], returning 0 instead of -5.", "recommendation": {"advice": "When learning or checking algorithms with AI, write a brute-force reference and compare outputs on many small random inputs; this caught a Kadane variant failing on all-negative arrays.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/how-to-learn-maths-and-cs-with-ai-without-fooling-yourself", "markdown": "https://wpnews.pro/news/how-to-learn-maths-and-cs-with-ai-without-fooling-yourself.md", "text": "https://wpnews.pro/news/how-to-learn-maths-and-cs-with-ai-without-fooling-yourself.txt", "jsonld": "https://wpnews.pro/news/how-to-learn-maths-and-cs-with-ai-without-fooling-yourself.jsonld"}}