Solving a linear equation

Make the board of a maths lesson: 2x + 3 = 11 is solved in four moves, and each move is a transformation. The 3 that crosses the equals sign is gold, so the eye follows it. You write five formulas, place their clips, relate them in pairs and export the scene.

What you will make

Sixteen seconds of algebra. The first formula writes itself in. Each formula stays long enough to read, and then turns into the next: the 3 crosses the equals sign and the plus becomes a minus, 11 − 3 collapses into 8, the 2 drops under the 8, and the fraction becomes 4.

Along the way you meet the moves that every animation of this kind repeats:

It takes about half an hour. It is the work of Your first animation, five times over, so do that one first if you have not.

Before you start

Open the editor with an empty project (File ▸ New). Name it: click Untitled in the menu bar, type Solving a linear equation and press Enter. The scene of the export will take that name.

Then tick two preferences in the Edit menu: Always add intro (Write) (1) and Always add outro (FadeOut) (2). From then on every new clip starts with a Write and ends with a FadeOut, so you do not have to give them one by one.

The Edit menu with Always add intro (Write) and Always add outro (FadeOut) both ticked.
The two preferences, ticked: Always add intro (Write) (1) and Always add outro (FadeOut) (2).

These are the five formulas. Each has a name, which becomes a Python variable in the export: a name takes letters, digits and underscores, and does not start with a digit.

NameLaTeXWhat happens to it
equation2x + 3 = 11The equation to solve.
subtract2x = 11 - 3The 3 crosses the equals sign, and the plus becomes a minus.
simplify2x = 811 − 3 is 8.
dividex = \frac{8}{2}Both sides are divided by 2: the 2 drops under the 8.
answerx = 48 over 2 is 4.

If you want to skip a part, this project holds the work of the first four steps: the formulas, the colours and the clips, with nothing related yet. Open it with File ▸ Open…: press Other file… in the dialog and pick the downloaded file (Projects and files explains the dialog). Then go on from step 5.

Step by step

1. Write the five formulas

For each formula in the table:

When the five are written, the Creator lists them. Its list scrolls; this picture was taken in a taller window to show them all.

The Creator with five formulas listed: equation, subtract, simplify, divide and answer, each with its rendering.
The five formulas in the Creator.

2. Colour the glyphs that travel

The 3 changes sides in the first move, and the 2 changes place in the third. Colour them, and the eye can follow them. The glyph view of the formula editor does it.

The formula editor of equation in its glyph view: the 3 of 2x + 3 = 11 outlined and drawn in gold, and the row of swatches with the gold one chosen.
The glyph picked (1) and the swatch chosen (2).

Colour three more glyphs the same way. A glyph colour belongs to the formula, so every clip of the formula shows it.

FormulaGlyphColour
equationthe 3gold
subtractthe 3, the last glyphgold
simplifythe 2, the first glyphblue
dividethe 2, under the barblue

Colouring glyphs and objects has the other ways to colour: the hex field, colours in order, and copying a sequence of colours.

3. Put the clips on the timeline

Drag each card from the Creator onto a track. Alternate the two tracks, and start each clip three seconds after the one before. The timeline snaps clips to its ticks, half a second apart, so a drop near a time lands on it.

FormulaTrackDrop it at
equationTrack 20 s
subtractTrack 13 s
simplifyTrack 26 s
divideTrack 19 s
answerTrack 212 s

The timeline is wider than its panel. Press the key that shows the whole timeline, in its toolbar, to see every clip. Each clip starts with a Write and ends with a FadeOut, from the two preferences you ticked.

4. Give each formula time

Every clip is three seconds long, so clips that start three seconds apart only touch, and a relation needs them to overlap. Lengthen each clip by one second: select it, open the Timing tab of the Animations panel, type the new End (1) and press Enter. Or drag the right edge of the clip.

FormulaEnd
equation4
subtract7
simplify10
divide13
answer16
The Timing tab of the Animations panel for the clip of subtract: its start, its end, and the Intro and Outro animations.
The Start and End of a clip (1), and the Animation of its intro (2).

Each clip now overlaps the next by a second, and a formula stays on screen, still, for two seconds between its arrival and its departure. Last, let the answer stay: select the clip of answer, scroll the panel down to its Outro section, and choose None (disappear) as the Animation.

The whole timeline: five clips alternating between Track 2 and Track 1, each overlapping the next by one second, each with a Write intro and a FadeOut outro, the last without an outro.
The five clips. Click the picture to see it larger.

5. Relate the formulas

Relate each formula to the next: four relations. For each pair of neighbours, do what you did in your first animation. Hold Shift, click the port of the first clip, click the second clip, press Suggest links by label and Accept all, and press Save relation. The first pair needs nothing else.

equation to subtract. The glyphs that are the same symbol are linked: 2, x, =, 3 and the two 1s. The + has no partner and leaves, and the − arrives.

The relation editor for equation to subtract: six glyph pairs drawn as numbered lines, and the list of pairs.
The first relation: what the editor says (1), the pairs (2) and Save relation (3).

subtract to simplify. Suggesting links by label links the 2, the x and the =. The right side is left: nothing in 11 − 3 is the same symbol as 8. Link it by hand. Click the first 1 of the top formula, Shift-click the second 1, the − and the 3, then click the 8 of the bottom one. The four glyphs are one pair. In the list of pairs, set the style of that pair to Fade transform, so that they fade into the 8. Press Save relation.

The drawing of the relation editor for subtract to simplify: the four glyphs 1, 1, minus and 3 of 2x = 11 − 3 selected, and the 8 of 2x = 8 below, which a click makes the target.
Four glyphs picked (1): the first with a click, the others with Shift. A click on the 8 (2) makes the pair.

simplify to divide. By label again: the 2 goes under the 8, and the x, the = and the 8 go to their places. The fraction bar has no partner, so it arrives with the intro of divide.

divide to answer. The x and the = are linked by label. Link the fraction by hand: click the 8, Shift-click the 2 and the bar, then click the 4, and set the style of the pair to Fade transform. Press Save relation.

The relation editor for divide to answer: x and equals linked one to one, and the 8, the 2 and the fraction bar linked together to the 4 with the Fade transform style.
The last relation: the pair of three glyphs and one (1), and Save relation (2).

6. Play it

Move the playhead to the start with Home and press Space. The first formula writes itself in; each next formula takes shape as the glyphs of the one before travel into it, and the glyphs with no partner are written in. If a move is too quick, select its relation by clicking its band on the timeline and make its Duration longer in the Animations panel; the clips must then overlap by that much (Transforming one formula into another says how the window works).

7. Export it

Choose Export ▸ Python — ManimCE…. The scene is named after your project: SolvingALinearEquation. Press Download SolvingALinearEquation.py. The dialog is the one of your first animation, and Exporting explains its options.

Run it from the folder of the file, with the command at the top of the file:

manim -r 1920,1080 --fps 60 SolvingALinearEquation.py SolvingALinearEquation

That renders at 1920×1080 and 60 frames a second. For a quick look, run manim -ql -p SolvingALinearEquation.py SolvingALinearEquation instead: -ql renders at 854×480 and 15 frames a second, and -p plays the video when it is done. Leave out -r and --fps, which would override -ql.

The result

This is what ManimCE renders from the exported scene with -ql, the quick low-quality render (854×480 at 15 frames a second):

And this is the Python the editor exports, for both libraries. It is plain Manim: one MathTex per formula, then a self.play(…) per step of the timeline.

Open the project in the editor, change it, and export again:

Try changing it