Inspiration
We both take Calc II, and our friends get stuck a course earlier, in precalculus. Office hours exist, but at midnight before a quiz we want to know right now whether our steps are right.
AI chatbots are tedious for this: photograph the page, write a prompt, re-prompt. Then they dump the whole solution when we only wanted to know where we went wrong. And they aren't reliable. When we gave Gemini a handwritten solution to
$$\int \sin^3 x \, dx$$
it got the final answer right but blamed a term that was actually correct. Our real mistake was somewhere else. If we had trusted it, we would have "fixed" the right part.
We wanted a tool that checks our own work, points at the first wrong line, proves when the answer is wrong, and only helps as much as we ask, so we improve instead of copying answers.
What it does
- Write your solution by hand, one step per line, on a ruled canvas in any browser. It works with a stylus on an Android tablet, and palm and finger touches are ignored, so you can rest your hand while writing.
- Enter the question your way: type it, write it, or snap a photo of your textbook.
- Three courses: Precalculus, Calculus I and Calculus II.
- Pick how much help you want before checking:
| Level | Name | What you get |
|---|---|---|
| 1 | Walkthrough | Which line is wrong, why, and how to fix it |
| 2 | Pinpoint | Which line is wrong and why; you fix it |
| 3 | Nudge | One guiding question, no verdict |
| 4 | Check | Only correct or incorrect |
| 5 | Exam | Nothing until you submit; then a full review, and the problem locks |
- Press Check. MathWise reads each handwritten line, shows you what it read, and highlights the first wrong line on your handwriting. Lines that correctly follow from an earlier mistake are not flagged, the way an exam grader gives "error carried forward" credit.
- Math checks the AI. SymPy, a computer algebra system, checks your final answer with math, not AI: it differentiates your antiderivative, integrates numerically, takes two-sided limits, or substitutes your solutions back in. When the answer is wrong, it shows a concrete counterexample.
- Stuck? Ask for a hint. Each hint steps down one level, without spoiling more than you asked for.
- Still stuck at Walkthrough? You can reveal a full worked solution, also checked by SymPy, after a confirmation.
- Reread the right section. Each mistake links to the matching section of a free OpenStax textbook.
- No sign-up. History keeps your checked problems in your browser only. A "Try a sample" button shows how it works without a stylus.
How we built it
- Frontend: React, TypeScript, Vite and Tailwind. The canvas uses Pointer Events: it accepts the pen (and a mouse on laptops), ignores touch for palm rejection, and uses coalesced events and pressure for smooth ink. Math is rendered with KaTeX.
- Backend: Python and FastAPI, deployed on Modal as one HTTPS web app serving both the API and the frontend. The Gemini key is a Modal secret.
- Gemini API, in separate calls:
- Transcription: each row is cropped into its own image. The prompt tells Gemini to transcribe exactly what is written and never fix mistakes, because vision models tend to silently correct student errors, which hides the very mistake we need to find.
- Checking: Gemini analyzes the steps once and returns structured JSON: verdict, first wrong line, mistake type, explanation, fix, a guiding question, and the problem and final answer translated into SymPy syntax.
- SymPy final-answer check: because the SymPy text comes from the AI, it only accepts whitelisted math names, rejects huge numbers like 9^9^9 that could freeze the server, and stops after 12 seconds.
- Help levels are plain code, not AI: the server stores the one analysis and only sends the fields your level allows. That keeps the five levels consistent, and hints don't need another AI call.
- Reliability: if a Gemini model is overloaded or too slow, the backend falls back to another Gemini model. Repeat checks of the same work are cached, so they return instantly with the same answer.
- 106 unit tests cover the levels, hints, transcription, fallbacks, the cache and the SymPy check, with Gemini mocked.
- Domain: mathwise.ink. .ink, because you write your work in ink.
Challenges we ran into
- Gemini overload during the event. We got 503 "high demand" and 429 rate-limit errors, and one check took over 3 minutes because the SDK quietly retried 5 times. We turned off the SDK's retries, added a time limit per model, and fall back through several Gemini models. A slow check now finishes in seconds.
- Every live call failed at first with a 400 error: our Pydantic schemas added
additionalPropertiesto the schema Gemini receives, and Gemini rejects it. Our tests mocked Gemini, so only a real call found it. - Transcription took 41 seconds for six lines. Lowering the model's thinking level made it about 4 seconds, with identical output.
- AI finds the wrong line only part of the time. Research benchmarks like ProcessBench show that even strong models often miss the first wrong step, and a small model blamed the wrong line in our own test. That's why we added SymPy: it can't find the wrong line, but when the final answer is wrong, it proves it.
- Letting AI write code-like math safely. SymPy's parser runs Python, so we check every expression against a whitelist first, and block numbers big enough to freeze the server.
- Strokes that cross the ruled lines, like an integral sign or a fraction, can land in the wrong row.
- Promised cloud credits didn't work, so we built on the Gemini free tier, then moved to a small paid key for the final app.
Accomplishments that we're proud of
- On our handwritten sin³x test, MathWise read the lines exactly as written, mistake included, and blamed the correct line, the one the plain Gemini app got wrong. Then SymPy proved the final answer wrong with a counterexample.
- Real palm rejection in a plain web page on an Android tablet, without a native app.
- Five help levels that stay consistent, because one analysis is filtered instead of asking the AI five different ways.
- A live HTTPS deployment that survives model overload, at our first hackathon.
What we learned
- Mocked tests aren't enough with an AI API: the first real call found a bug every test missed.
- Reading handwriting and judging math are separate problems. Splitting them made each one easier to check and to fix.
- AI is good at explaining and bad at being sure. Anything that must be right (which fields a level shows, fallbacks, the final-answer check) should be ordinary code or real math.
- How to deploy on Modal, use Gemini structured output, and work with Pointer Events and stylus pressure.
What's next for MathWise
- Check every line with math, not just the final answer: show a counterexample for the blamed line itself ("at x = 1, line 3 and line 4 disagree").
- Circle the exact wrong term in red pen, not just the whole line.
- Calculus III. We haven't taken it yet, so we can't verify its problems ourselves.
- An "incomplete but on track" result, so a stuck student can get a nudge on half a solution.
- Accounts, only with a proper privacy setup: history across devices, and an instructor link that sets a maximum help level for an assignment.
Built With
- built-with-(14-tags)-python
- fastapi
- gemini-api
- google-genai
- html5
- katex
- modal
- pointer-events
- pydantic
- pytest
- react
- tailwindcss
- typescript
- vite