Created
August 28, 2021 18:29
-
-
Save maxdrohde/3f181508d6800732d4a948a1f55a4d78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using manim community edition | |
from manim import * | |
config.frame_width = 22 | |
text1 = MathTex(r"\begin{bmatrix} 3 & 9 & 5 \\ 9 & 4 & 2 \\ 7 & 3 & 6 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \\ 3 & 6 & 9 & 8 \\ 2 & 7 & 1 & 4 \end{bmatrix}") | |
text2 = MathTex(r"\begin{bmatrix} 3 & 9 & 5 \\ 9 & 4 & 2 \\ 7 & 3 & 6 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \\ 3 & 6 & 9 & 8 \\ 2 & 7 & 1 & 4 \end{bmatrix}", r"&=", r"\begin{bmatrix} 3 \\ 9 \\ 7 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \end{bmatrix} + \begin{bmatrix} 9 \\ 4 \\ 3 \end{bmatrix} \begin{bmatrix} 3 & 6 & 9 & 8 \end{bmatrix} + \begin{bmatrix} 5 \\ 2 \\ 6 \end{bmatrix} \begin{bmatrix} 2 & 7 & 1 & 4 \end{bmatrix} \\") | |
text3 = MathTex(r"\begin{bmatrix} 3 & 9 & 5 \\ 9 & 4 & 2 \\ 7 & 3 & 6 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \\ 3 & 6 & 9 & 8 \\ 2 & 7 & 1 & 4 \end{bmatrix}", r"&=", r"\begin{bmatrix} 15 & 21 & 6 & 12 \\ 45 & 63 & 18 & 36 \\ 35 & 49 & 14 & 28 \end{bmatrix} + \begin{bmatrix} 27 & 54 & 81 & 72 \\ 12 & 24 & 36 & 32 \\ 9 & 18 & 27 & 24 \end{bmatrix} + \begin{bmatrix} 10 & 35 & 5 & 20 \\ 4 & 14 & 2 & 8 \\ 12 & 42 & 6 & 24 \end{bmatrix}") | |
text4 = MathTex(r"\begin{bmatrix} 3 & 9 & 5 \\ 9 & 4 & 2 \\ 7 & 3 & 6 \end{bmatrix} \begin{bmatrix} 5 & 7 & 2 & 4 \\ 3 & 6 & 9 & 8 \\ 2 & 7 & 1 & 4 \end{bmatrix}", r"&=", r"\begin{bmatrix} 52 & 110 & 92 & 104 \\ 61 & 101 & 56 & 76 \\ 56 & 109 & 47 & 76 \end{bmatrix}") | |
tt1 = Tex("(Columns of A) times (Rows of B)").shift(UP).shift(UP) | |
tt2 = Tex("Compute the outer products").shift(UP).shift(UP) | |
tt3 = Tex("Sum the outer products").shift(UP).shift(UP) | |
class Multiply(Scene): | |
def construct(self): | |
self.play(Write(text1)) | |
self.wait(0.5) | |
self.play(Write(tt1)) | |
self.play(ReplacementTransform(text1, text2)) | |
self.wait(1.0) | |
self.play(ReplacementTransform(tt1, tt2)) | |
self.wait(0.5) | |
self.play(ReplacementTransform(text2, text3)) | |
self.wait(1.0) | |
self.play(ReplacementTransform(tt2, tt3)) | |
self.play(ReplacementTransform(text3, text4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment