Skip to main content
Logo image

Chapter 8 Manim

This chapter is co-authored by Tien Chih .

Section 8.1 What Is Manim?

Manim stands for “Math Animation”. The Community Manim Python package is a publically maintained, open-source commmunity version of a custom Python package initially created by Grant Sanderson, more commonly known as 3Blue1Brown.
Manim provides tools that can bring mathematical ideas and concepts to life that static words and explanations may not capture. As an example, the TBIL.org
 3 
tbil.org
Calculus I video series at this YouTube playlist
 4 
www.youtube.com/playlist?list=PLwXCBkIf7xBODPeQxULagMeWSK4YtLYog
was animated entirely by Tien Chih using Manim.

Section 8.2 Creating a Manim Codespace

A turn-key repository for creating a Codespace (Section 4.1) for Manim is available at StevenClontz/manim-workshop
 1 
github.com/StevenClontz/manim-workshop
. Follow the instructions there to obtain an interface for authoring Manim content using just your web browser (Chrome/Edge/Firefox recommended).

Section 8.3 Hello World!

Let’s run our very first Manim animation.

Activity 8.3.1.

Open main.py and look for the line class HelloWorld(Scene):.
(a)
Open a Terminal and execute the command manim render -ql main.py HelloWorld. (See the README file for other options to render Manim scenes.)
(b)
Open the file media/videos/main/480p15/HelloWorld.mp4 to view your newly rendered video.
(c)
See if you can add these lines to the code so the video ends by saying “My name is YOUR NAME HERE”.
  • name = MathTex(r"\text{My name is YOUR NAME HERE.}")
  • self.play(Transform(hello, name))
Don’t forget to re-run manim render -ql main.py HelloWorld to update your rendered video.
(d)
See if you can make the circle GREEN instead of PINK.

Section 8.4 More Animations

Activity 8.4.1.

Open main.py and look for the line class TanLine(Scene):.
Review the comments and the code within this block. This particular scene TanLine creates a curve, displays the algebraic work needed to find a tangent line, and then displays said tangent line.
(a)
Run manim render -ql main.py TanLine to produce a video file at media/videos/main/480p15/TanLine.mp4.
(b)
Edit the code to find and display the line tangent to the curve when \(x=2\text{.}\)
(c)
Change the window so that \(x\) ranges from \(0\) to \(10\text{.}\)
(d)
Choose a function \(f\) and \(x\) value of your choice, and edit the code to find and display the line tangent to \(y=f(x)\) at your chosen \(x\) value.

Remark 8.4.1.

The web-based Desmos
 1 
www.desmos.com/
tool can be very helpful in determining appropriate window sizes and scaling.

Activity 8.4.2.

Open main.py and look for the line class SinChange(Scene):.
This particular block of code plots a transformed sine function of the form \(y=a\sin(bx)+c\text{.}\) Where initially \(a=1, b=1, c=0\text{.}\) We then adjust the values for \(a, b\) and \(c\) over time.
(a)
Run the code to produce a video file.
(b)
Edit the array a=[1,2, 2, 2, -1/3], and the rhs entries to adjust the vertical stretch.
(c)
Edit the array b=[1,1, 1/2,1/2,-2], and the rhs entries to adjust the horizontal stretch.
(d)
Edit the array c=[0,0, 0, -3, 2], and the rhs entries to adjust the vertical shift.

Activity 8.4.3.

Open main.py and look for the lines class FindProduct(Scene):, class FindQuotient(Scene):, and class FindPower(Scene):.
The scene FindProduct displays a product rule computation, FindQuotient displays a quotient rule computation, and FindPower displays a faux-quotient rule computation using powers.
(a)
Run the function FindProduct to produce a video file.
(b)
Pick your favorite product of functions and edit the code to produce the appropriate derivation.
(c)
Copy and paste the FindProduct function and rename it FindChain.
(d)
Edit this new command to display an animation for your favorite chain rule derivation.

Activity 8.4.4.

Open main.py and look for the line class Riemann(Scene):.
This code displays a Riemann sum for a funcion, and displays the ongoing sum for \(R_n\text{.}\)
(a)
Run the code to see the output.
(b)
Change the function to a function of your choice. You may need to resize the window. Recall the identitites
\begin{equation*} \sum_{i=1}^n i = \frac{n(n+1)}{2}, \sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6}, \sum_{i=1}^n i^3 = \left( \frac{n(n+1)}{2}\right)^2. \end{equation*}

Section 8.5 Additional Resources:

Here are a list of helpful links regarding Manim authoring: