Diagram Formulas

Inside our geometry diagram maker

Diagram Formulas

How AI can help make accurate math diagrams

The short version

We don't ask the AI to draw directly. We ask it to write instructions to build the shape. A math engine follows the instructions, works out the points, and checks them before rendering the final diagram.

1.The problem: almost correct is not correct

Geometry runs on diagrams. Textbooks, worksheets, and practice apps are full of them. Students need many examples before the idea settles in.

Good diagrams take time. Someone has to place the points, draw the lines, and check the angles. That slow, exact work is one reason good practice material is hard to make in bulk.

AI looks like an easy answer. Ask for "a right triangle with a circle through all three corners" and you get something close. But look again. One side is bent. The right angle is off. The circle is slightly oval.

Almost correct is fine for an illustration. In geometry, this can teach the wrong idea. A student practicing on a "right angle" that is not 90° has been handed a false diagram.

That is the failure mode we want to avoid:

Try it №1

Spot the mistakes

Use the two buttons to switch between a guessed diagram and a built one.
A B C M this is 84°, not 90° M is not the middle the circle misses C

The guessed picture has the right parts, but the geometry is wrong. People catch some mistakes by eye. A useful system needs checks a computer can run every time.

2.Our fix: ask for the construction formula, not the final picture

Think of giving a friend directions to your house. You would not paint the whole trip. You would give steps: turn left at the bakery, take the second right, look for the gray door.

Steps are easier to check than a picture. If the steps are exact, anyone can follow them and get the same result.

That is the idea behind a construction formula. The AI does not place pixels or guess coordinates. It writes a plan that can be drawn out with a figurative compass and ruler: Make a triangle with a square corner at B. Find M, the exact middle of side AC. Draw a circle around M through A.

A math engine follows the formula one step at a time. Watch it below:

Try it №2

Play the formula

The AI wrote the steps on the left. Press the play button to watch the math follow them, one step at a time.

Written by the AI

{ "op": "triangle", "corners": ["A","B","C"],  "right_angle_at": "B" }{ "op": "midpoint", "name": "M", "of": ["A","C"] }{ "op": "circle", "center": "M", "through": "A" }checks:  distance(M,A) = distance(M,B) = distance(M,C)  angle(A,B,C) = 90°

Built by the math engine

step 0 of 4

The circle touches all three corners, and that is not luck. Thales' theorem says it must, for a right triangle, when M is the middle of the longest side. The formula makes it exact. The checks confirm it.

It works because the job is split three ways:

The AI plans

It writes what to build, not the final coordinates.

The math builds

It follows the steps and works out every point.

The red pen checks

It measures the promises in the formula. If a check fails, the diagram stays hidden.

The AI brings the plan. The math brings the precision. Each does what it is good at.

3.Every picture is graded first

A geometry diagram is a bundle of promises. M is the middle. The corner is 90°. The circle touches all three corners.

A computer can measure those promises.

Before a diagram appears, the system takes those measurements. We call this step what a teacher would: the red pen. If a check fails, the AI gets notes back and writes a new formula. It gets three tries. If the math still fails, no diagram is shown.

Move M and watch the checks:

Try it №3

Be the checker

Drag the red point M along the slanted side. Keyboard users can tab to it and use the arrow keys.
A B C M
AM = 5.0 · MC = 5.0 (M is the middle) circle through A also touches B and C

4.The whole assembly line

One request passes through five stations. A failed check sends the formula back, like a draft with comments. Tap a station to see what happens there:

↺ if a check fails, the work goes back to station 2 with notes

A peek under the hood for curious readers: the real files behind Try it №2

Step 1 · The ask. Plain words go in:

Draw triangle ABC with a right angle at B. M is the midpoint
of AC. Draw the circle centered at M through A.

Step 2 · The formula becomes data a computer can read. Every step gets a type, and every promise gets listed. This is the AI's whole job. Note that it never says where M is, only what M means.

{"id":"B", "kind":"point_fixed", "x":0, "y":0}
{"id":"A", "kind":"point_fixed", "x":0, "y":3}
{"id":"C", "kind":"point_fixed", "x":4, "y":0}
{"id":"T", "kind":"triangle", "a":"A", "b":"B", "c":"C"}
{"id":"M", "kind":"point_midpoint", "p":"A", "q":"C"}
{"id":"k", "kind":"circle_center_point", "center":"M", "through":"A"}
{"id":"MA", "kind":"segment", "a":"M", "b":"A"}
{"id":"MB", "kind":"segment", "a":"M", "b":"B"}
{"id":"MC", "kind":"segment", "a":"M", "b":"C"}

checks:
{"kind":"right_angle", "angle":{"a":"A", "o":"B", "b":"C"}}
{"kind":"equal_length", "segs":["MA","MB","MC"]}

Step 3 · The math engine works out the exact points. We use SymPy, a free math library. Look at the numbers. M lands at (2, 3/2) and the radius is exactly 5/2. These are fractions, not rounded guesses. Harder builds use high-precision decimals instead, and those get checked too. Nothing is eyeballed.

A = Point2D(0, 3)    B = Point2D(0, 0)    C = Point2D(4, 0)
M = Point2D(2, 3/2)               # the midpoint, computed
k = Circle(Point2D(2, 3/2), 5/2)  # radius = |MA|, exact

Step 4 · The red pen runs. Every promise becomes a test:

✓ right_angle   angle A-B-C measures 90°
✓ equal_length  |MA| = |MB| = |MC| = 5/2

Each test must pass within a tight margin. Any failure rejects the picture and sends notes back to the AI. After three failed tries, the system gives up rather than show a bad diagram.

Step 5 · Only now is anything drawn. The checked points go to TikZ, a drawing language, which draws the final image. The drawing layer never invents a point. It only uses the ones that passed.

\tkzDefPoint(0,3){A}   \tkzDefPoint(0,0){B}
\tkzDefPoint(4,0){C}   \tkzDefPoint(2,1.5){M}
\tkzDrawPolygon(A,B,C)
\tkzDrawCircle(M,A)

5.Why it matters

0

diagrams are shown without passing every check. "Looks fine" is not enough.

3

tries before the system gives up rather than show a bad diagram.

801

problems in GeoGenBench, our public benchmark of AI-drawn geometry.

Teachers can trust the diagrams because each comes with a receipt: the promises it made and the measurements that show it kept them. No one has to rely on eyesight alone.

Practice material comes faster. A checked diagram that once took minutes of expert time now takes seconds. That makes fresh examples cheap.

Anyone can keep score. Our public benchmark, GeoGenBench, has 801 diagram problems: 600 built from templates and 201 written from a K-12 curriculum. A machine can check every one, so researchers can measure how well an AI draws instead of eyeballing it.

The lesson is simple:

The AI writes the formula. A rendering engine builds it, checks it, and only then draws the diagram. That is what makes it reliable.