summaryrefslogtreecommitdiff
path: root/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py
blob: 70547cb05cb384728edb5038f4fa942cac68a260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
from manimlib.imports import *

class Column_Space(Scene):
    def construct(self):

        A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c} 1 & 2 \\ 3 & 4 \end{array} \right)$")
        A.move_to(2*UP)
        A[1].set_color(color = DARK_BLUE)
        A.scale(0.75)

        self.play(Write(A),run_time = 1)

        CS_A = TextMobject(r"Column Space of $A = x_{1}$",r"$\left( \begin{array}{c} 1 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 4\end{array} \right)$")
        CS_A.move_to(1.5*LEFT+1*DOWN)
        CS_A[1].set_color(color = DARK_BLUE)
        CS_A[3].set_color(color = DARK_BLUE)
        CS_A.scale(0.75)

        self.play(Write(CS_A),run_time = 2)

        arrow1 = Arrow(start = 1.25*UP,end = (0.25*DOWN+1.75*LEFT+0.25*DOWN+1.2*RIGHT)/2)
        arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = (0.25*DOWN+2.9*RIGHT+0.25*DOWN)/2)

        arrow1.scale(1.5)
        arrow3.scale(1.5)

        Defn = TextMobject("Linear Combination of Columns of Matrix")
        Defn.move_to(3*DOWN)

        self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow3),run_time = 1)
        self.wait(1)

class solution(LinearTransformationScene):
    def construct(self):

        self.setup()
        self.wait()
        
        o = TextMobject(r"Consider the vector space $R^2$")
        o.move_to(2*DOWN)
        o.scale(0.75)
        o.add_background_rectangle()
        self.play(Write(o))
        self.wait()
        self.play(FadeOut(o))

        A = TextMobject(r"Let $A$ be ",r"$\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$",r". $A$ denotes the matrix the of this linear transformation.")
        A.move_to(2*DOWN)
        A.scale(0.75)
        A.add_background_rectangle()
        self.play(Write(A))
        matrix = [[1,-1],[1,-1]]
        self.apply_matrix(matrix)
        self.wait()
        self.play(FadeOut(A))

        o = TextMobject(r"This is the transformed vector space")
        o.move_to(2*DOWN)
        o.scale(0.75)
        o.add_background_rectangle()
        self.play(Write(o))
        self.wait()
        self.play(FadeOut(o))

        texti = TextMobject(r"$\left[\begin{array}{c}1\\1\end{array}\right]$")
        textj = TextMobject(r"$\left[\begin{array}{c}-1\\-1\end{array}\right]$")
        texti.set_color(GREEN)
        textj.set_color(RED)
        texti.scale(0.7)
        textj.scale(0.7)
        texti.move_to(1.35*RIGHT+0.5*UP)
        textj.move_to(-(1.5*RIGHT+0.5*UP))

        text1 = TextMobject("[")
        text2 = TextMobject(r"$\begin{array}{c} 1 \\ 1 \end{array}$")
        text3 = TextMobject(r"$\begin{array}{c} -1 \\ -1 \end{array}$")
        text4 = TextMobject("]")

        text2.set_color(GREEN)
        text3.set_color(RED)

        text1.scale(2)
        text4.scale(2)
        text2.scale(0.7)
        text3.scale(0.7)

        text1.move_to(2.5*UP+6*LEFT)
        text2.move_to(2.5*UP+5.75*LEFT)
        text3.move_to(2.5*UP+5.25*LEFT)
        text4.move_to(2.5*UP+5*LEFT)

        self.play(Write(texti), Write(textj))
        self.wait()
        self.play(FadeIn(text1), Transform(texti,text2), Transform(textj,text3), FadeIn(text4))
        self.wait()

        o = TextMobject(r"Now, you can observe the Image of Linear Transformation")
        o1 = TextMobject(r"and Column Space(i.e. span of columns of matrix $A$) are same")
        o.move_to(2.5*DOWN)
        o1.move_to(3*DOWN)
        o.scale(0.75)
        o1.scale(0.75)
        o.add_background_rectangle()
        o1.add_background_rectangle()
        self.play(Write(o))
        self.play(Write(o1))
        self.wait()
        self.play(FadeOut(o),FadeOut(o1))

class solution2nd(LinearTransformationScene):
    def construct(self):

        self.setup()
        self.wait()
        
        arrow1 = Arrow(start = ORIGIN,end = 2*DOWN+RIGHT)
        arrow2 = Arrow(start = ORIGIN,end = UP+LEFT)
        arrow3 = Arrow(start = ORIGIN,end = 3*UP+4*RIGHT)
        arrow1.set_color(YELLOW)
        arrow2.set_color(ORANGE)
        arrow3.set_color(PURPLE)
        arrow1.scale(1.3)
        arrow2.scale(1.5)
        arrow3.scale(1.1)

        self.play(ShowCreation(arrow1), ShowCreation(arrow2), ShowCreation(arrow3))

        self.add_transformable_mobject(arrow1)
        self.add_transformable_mobject(arrow2)
        self.add_transformable_mobject(arrow3)
        o = TextMobject(r"Consider any vector in the original vector space $R^2$")
        o.move_to(2.5*DOWN)
        o.scale(0.75)
        o.add_background_rectangle()
        self.play(Write(o))
        self.wait()
        self.play(FadeOut(o))

        A = TextMobject(r"Let the matrix the of this linear transformation be $A$ =",r"$\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$",r" again.")
        A.move_to(2*DOWN)
        A.scale(0.75)
        A.add_background_rectangle()
        self.play(Write(A))
        matrix = [[1,-1],[1,-1]]
        self.apply_matrix(matrix)
        self.wait()
        self.play(FadeOut(A))

        o = TextMobject(r"This is the transformed vector space")
        o.move_to(2*DOWN)
        o.scale(0.75)
        o.add_background_rectangle()
        self.play(Write(o))
        self.wait()
        self.play(FadeOut(o))

        o = TextMobject(r"Each and every vector of original vector space $R^2$ will transform")
        o1 = TextMobject(r"to this new vector space which is spanned by $\mathbf{CS}(A)$")
        o.move_to(2.5*DOWN)
        o1.move_to(3*DOWN)
        o.scale(0.75)
        o1.scale(0.75)
        o.add_background_rectangle()
        o1.add_background_rectangle()
        self.play(Write(o))
        self.play(Write(o1))
        self.wait()
        self.play(FadeOut(o))
        self.play(FadeOut(o1))