summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArchit Sangal2020-06-20 18:56:19 +0530
committerArchit Sangal2020-06-20 18:56:19 +0530
commit450b3d9b496aa7386d8cf52ed683f77cfe9abeb3 (patch)
treebe5d44a665f368a978bd6dd81e06292f5561861f
parent86d4b8658d61c2823187b1353bb06c0daebec7ae (diff)
downloadFSF-mathematics-python-code-archive-450b3d9b496aa7386d8cf52ed683f77cfe9abeb3.tar.gz
FSF-mathematics-python-code-archive-450b3d9b496aa7386d8cf52ed683f77cfe9abeb3.tar.bz2
FSF-mathematics-python-code-archive-450b3d9b496aa7386d8cf52ed683f77cfe9abeb3.zip
Review
-rwxr-xr-xFSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py85
-rw-r--r--FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py174
-rwxr-xr-xFSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py77
3 files changed, 336 insertions, 0 deletions
diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py
new file mode 100755
index 0000000..814fa57
--- /dev/null
+++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py
@@ -0,0 +1,85 @@
+from manimlib.imports import *
+
+class Projections(GraphScene):
+ CONFIG = {
+ "x_min": -6,
+ "x_max": 6,
+ "y_min": -4,
+ "y_max": 4,
+ "graph_origin" : ORIGIN ,
+ }
+ def construct(self):
+
+ self.setup_axes(animate=True)
+
+ XTD = self.x_axis_width/(self.x_max-self.x_min)
+ YTD = self.y_axis_height/(self.y_max-self.y_min)
+
+ arrow_a = Arrow(start = ORIGIN, end = 4*XTD*RIGHT)
+ arrow_a.scale(1.2)
+ arrow_a.set_color(DARK_BLUE)
+ arrow_b = Arrow(start = ORIGIN, end = 2*YTD*UP+2*XTD*RIGHT)
+ arrow_b.scale(1.3)
+ arrow_b.set_color(DARK_BLUE)
+ self.play(ShowCreation(arrow_a), ShowCreation(arrow_b))
+
+ text = TextMobject(r"Let there be 2 vectors $a$ and $b$")
+ text.set_color(DARK_BLUE)
+ text.scale(0.75)
+ text.move_to(2*YTD*DOWN+4*XTD*LEFT)
+ text_a = TextMobject("a")
+ text_a.move_to(0.4*YTD*DOWN+3*XTD*RIGHT)
+ text_a.set_color(DARK_BLUE)
+ text_b = TextMobject("b")
+ text_b.move_to(1.5*YTD*UP+RIGHT*XTD)
+ text_b.set_color(DARK_BLUE)
+
+ self.play(Write(text),Write(text_a), Write(text_b))
+ self.wait()
+
+ arrow_b_copy = Arrow(start = ORIGIN, end = 2*YTD*UP+2*XTD*RIGHT)
+ arrow_b_copy.scale(1.25)
+
+ arrow_p = Arrow(start = ORIGIN, end = 2*XTD*RIGHT)
+ arrow_p.scale(1.5)
+ arrow_p.set_color(GOLD_E)
+
+ text_p = TextMobject("p")
+ text_p.move_to(0.25*DOWN+RIGHT)
+ text_p.set_color(GOLD_E)
+
+ self.play(FadeOut(text), Transform(arrow_b_copy,arrow_p), FadeOut(text_a), FadeOut(text_b))
+ text = TextMobject(r"$p$ is the projection of $b$ on $a$")
+ text.set_color(GOLD_E)
+ text.move_to(2*DOWN+3*LEFT)
+ text.scale(0.8)
+ self.play(Write(text),Write(text_p))
+ self.wait()
+
+ self.play(FadeIn(text_a), FadeIn(text_b))
+
+ arrow_o = Arrow(start = 2*XTD*RIGHT, end = 2*YTD*UP+2*XTD*RIGHT)
+ arrow_o.scale(1.5)
+ arrow_o.set_color(GREEN_E)
+
+ text_o = TextMobject("b-p")
+ text_o.move_to(UP*YTD+2.7*XTD*RIGHT)
+ text_o.set_color(GREEN_E)
+
+ self.play(ShowCreation(arrow_o))
+ self.play(FadeOut(text),Write(text_o))
+
+ text = TextMobject(r"Observe, ($b-p$) is orthogonal to $a$")
+ text.set_color(GREEN_E)
+ text.move_to(2*DOWN+4*LEFT)
+ text.scale(0.8)
+ self.play(Write(text))
+ self.wait(2)
+
+ self.play(FadeOut(self.axes), FadeOut(arrow_a), FadeOut(arrow_b), FadeOut(arrow_b_copy), FadeOut(arrow_o), FadeOut(text_a), FadeOut(text_b), FadeOut(text_o), FadeOut(text_p), FadeOut(text))
+
+ text = TextMobject(r"Therefore, unit vectors of $b-p$ and $a$ are orthonormal to each other")
+ text.scale(0.75)
+ self.play(Write(text))
+ self.wait(2)
+ self.play(FadeOut(text)) \ No newline at end of file
diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py
new file mode 100644
index 0000000..640b8be
--- /dev/null
+++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py
@@ -0,0 +1,174 @@
+from manimlib.imports import *
+
+from manimlib.imports import *
+
+class Orthogonal(ThreeDScene):
+ def construct(self):
+
+ text = TextMobject(r"These are two Orthogonal Basis $\alpha_{1}$ and $\alpha_{2}$")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*(DOWN+RIGHT))
+ self.play(Write(text))
+
+ axes = ThreeDAxes()
+ self.play(ShowCreation(axes))
+ self.move_camera(phi=60*DEGREES,theta=45*DEGREES,run_time=3)
+ self.begin_ambient_camera_rotation(rate=0.3)
+
+ line1 = Line(start = ORIGIN,end = 1*RIGHT)
+ line1.set_color(DARK_BLUE)
+ tip1 = Polygon(RIGHT,0.8*RIGHT-0.2*DOWN,0.8*RIGHT-0.2*UP)
+ tip1.set_opacity(1)
+ tip1.set_fill(DARK_BLUE)
+ tip1.set_color(DARK_BLUE)
+
+ arrow2 = Line(start = ORIGIN,end = 1*UP)
+ arrow2.set_color(DARK_BLUE)
+ tip2 = Polygon(UP,0.8*UP-0.2*RIGHT,0.8*UP-0.2*LEFT)
+ tip2.set_opacity(1)
+ tip2.set_fill(DARK_BLUE)
+ tip2.set_color(DARK_BLUE)
+ arrow2.set_color(DARK_BLUE)
+
+ self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2))
+ self.wait()
+
+ a_line = Line(start = ORIGIN,end = 2*UP+2*RIGHT+[0,0,2])
+ a_line.set_color(GOLD_E)
+ a_tip = Polygon(2*UP+2*RIGHT+[0,0,2],2*UP+1.6*RIGHT+[0,0,1.8],1.6*UP+2*RIGHT+[0,0,1.8])
+ a_tip.set_opacity(1)
+ a_tip.set_fill(GOLD_E)
+ a_tip.set_color(GOLD_E)
+
+ a_line_c1 = Line(start = ORIGIN,end = 2*UP+2*RIGHT+[0,0,2])
+ a_line_c1.set_color(GOLD_E)
+ a_tip_c1 = Polygon(2*UP+2*RIGHT+[0,0,2],2*UP+1.6*RIGHT+[0,0,1.8],1.6*UP+2*RIGHT+[0,0,1.8])
+ a_tip_c1.set_opacity(1)
+ a_tip_c1.set_fill(GOLD_E)
+ a_tip_c1.set_color(GOLD_E)
+
+ self.play(FadeOut(text), ShowCreation(a_line), ShowCreation(a_tip), ShowCreation(a_line_c1), ShowCreation(a_tip_c1))
+
+ text = TextMobject(r"There is a vector $\beta_3$")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*(DOWN+RIGHT))
+ self.play(Write(text))
+ self.wait()
+ self.play(FadeOut(text))
+
+ p_line1 = Line(start = ORIGIN,end = 2*RIGHT)
+ p_line1.set_color(GOLD_E)
+ p_tip1 = Polygon(RIGHT,0.8*RIGHT+0.2*DOWN,0.8*RIGHT+0.2*UP)
+ p_tip1.move_to(2*RIGHT)
+ p_tip1.set_opacity(1)
+ p_tip1.set_fill(GOLD_E)
+ p_tip1.set_color(GOLD_E)
+
+ self.play(Transform(a_line_c1,p_line1),Transform(a_tip_c1,p_tip1))
+
+ text = TextMobject(r"Take projection of $\beta_3$ on $\alpha_1$")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*(DOWN+RIGHT))
+ self.play(Write(text))
+ self.wait()
+ self.play(FadeOut(text))
+
+ o_line1 = Line(start = 2*RIGHT,end = 2*UP+2*RIGHT+[0,0,2])
+ o_line1.set_color(GREEN_E)
+ o_tip1 = Polygon(2*UP+2*RIGHT+[0,0,2],1.8*UP+2*RIGHT+[0,0,1.8]+0.2*RIGHT,1.8*UP+2*RIGHT+[0,0,1.8]-0.2*RIGHT)
+ o_tip1.set_opacity(1)
+ o_tip1.set_fill(GREEN_E)
+ o_tip1.set_color(GREEN_E)
+
+ a_line1 = Line(start = ORIGIN,end = 2*UP+[0,0,2])
+ a_line1.set_color(GREEN_E)
+ a_tip1 = Polygon(2*UP+[0,0,2],1.8*UP+[0,0,1.8]+0.2*RIGHT,1.8*UP+[0,0,1.8]-0.2*RIGHT)
+ a_tip1.set_opacity(1)
+ a_tip1.set_fill(GREEN_E)
+ a_tip1.set_color(GREEN_E)
+
+ a_line1_c1 = Line(start = ORIGIN,end = 2*UP+[0,0,2])
+ a_line1_c1.set_color(GREEN_E)
+ a_tip1_c1 = Polygon(2*UP+[0,0,2],1.8*UP+[0,0,1.8]+0.2*RIGHT,1.8*UP+[0,0,1.8]-0.2*RIGHT)
+ a_tip1_c1.set_opacity(1)
+ a_tip1_c1.set_fill(GREEN_E)
+ a_tip1_c1.set_color(GREEN_E)
+
+ text = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$)")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*(DOWN+RIGHT))
+ self.play(Write(text))
+ self.play(ShowCreation(o_line1), ShowCreation(o_tip1))
+ self.wait(2)
+ self.play(FadeOut(a_line_c1), FadeOut(a_tip_c1),
+ FadeOut(a_line), FadeOut(a_tip),
+ Transform(o_line1,a_line1), Transform(o_tip1,a_tip1))
+
+ self.wait()
+ self.play(FadeOut(text))
+
+ p_arrow2 = Line(start = ORIGIN,end = 2*UP)
+ p_arrow2.set_color(GOLD_E)
+ p_tip2 = Polygon(2*UP,1.8*UP+0.2*RIGHT,1.8*UP+0.2*LEFT)
+ p_tip2.set_opacity(1)
+ p_tip2.set_fill(GOLD_E)
+ p_tip2.set_color(GOLD_E)
+ p_arrow2.set_color(GOLD_E)
+
+ last_a = Line(start = 2*UP,end = [0,2,2])
+ last_a.set_color(GOLD_E)
+ last_a_tip = Polygon([0,0,2],[0,0,1.8]+0.2*RIGHT,[0,0,1.8]+0.2*LEFT)
+ last_a_tip.move_to([0,2,2])
+ last_a_tip.set_opacity(1)
+ last_a_tip.set_fill(GOLD_E)
+ last_a_tip.set_color(GOLD_E)
+
+ self.wait()
+ text = TextMobject(r"Take projection on $\alpha_2$")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*(DOWN+RIGHT))
+ self.play(Write(text))
+ self.play(Transform(a_line1_c1,p_arrow2),Transform(a_tip1_c1,p_tip2))
+ self.wait()
+ self.play(FadeOut(text))
+
+ text = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$ + projection of $\beta_3$ on $\alpha_2$)")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*DOWN+2*RIGHT)
+ self.play(Write(text))
+ self.play(ShowCreation(o_line1), ShowCreation(o_tip1))
+ self.wait(2)
+ self.play(ShowCreation(last_a_tip), ShowCreation(last_a))
+ self.wait()
+ self.play(FadeOut(text))
+
+ larrow3 = Line(start = ORIGIN,end = [0,0,2])
+ larrow3.set_color(GOLD_E)
+ ltip3 = Polygon([0,0,2],[0,0,1.8]+0.2*RIGHT,[0,0,1.8]+0.2*LEFT)
+ ltip3.set_opacity(1)
+ ltip3.set_fill(GOLD_E)
+ ltip3.set_color(GOLD_E)
+ self.wait()
+ self.play(FadeOut(o_line1), FadeOut(o_tip1), FadeOut(a_line1_c1), FadeOut(a_tip1_c1), Transform(last_a,larrow3), Transform(last_a_tip,ltip3))
+
+ text = TextMobject(r"Normalisation of the orthogonal vector")
+ text.scale(0.75)
+ self.add_fixed_in_frame_mobjects(text)
+ text.move_to(3*DOWN+2*RIGHT)
+ self.play(Write(text))
+
+ arrow3 = Line(start = ORIGIN,end = [0,0,1])
+ arrow3.set_color(DARK_BLUE)
+ tip3 = Polygon([0,0,1],[0,0,0.8]-0.2*RIGHT,[0,0,0.8]-0.2*LEFT)
+ tip3.set_opacity(1)
+ tip3.set_fill(DARK_BLUE)
+ tip3.set_color(DARK_BLUE)
+ self.play(Transform(last_a,arrow3), Transform(last_a_tip,tip3))
+
+ self.wait(3) \ No newline at end of file
diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py
new file mode 100755
index 0000000..95d1021
--- /dev/null
+++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py
@@ -0,0 +1,77 @@
+from manimlib.imports import *
+
+class Axb(Scene):
+
+ def construct(self):
+
+ text0 = TextMobject("Linear System Of Equations")
+ text1 = TextMobject(r"$x_{1}+x_{2}+x_{3} =b_{1}$")
+ text2 = TextMobject(r"$x_{1}+2x_{2}+x_{3} =b_{2}$")
+ text3 = TextMobject(r"$x_{1}+x_{2}+3x_{3} =b_{3}$")
+ text0.move_to(UP*2+LEFT*2)
+ text0.set_color(DARK_BLUE)
+ text1.move_to(UP)
+ text2.move_to(ORIGIN)
+ text3.move_to(DOWN)
+
+ text0.scale(0.75)
+ text1.scale(0.75)
+ text2.scale(0.75)
+ text3.scale(0.75)
+ self.play(Write(text0))
+ self.play(Write(text1))
+ self.play(Write(text2))
+ self.play(Write(text3))
+ self.play(ApplyMethod(text0.move_to,3*UP+LEFT*2), ApplyMethod(text1.move_to,2.5*UP), ApplyMethod(text2.move_to,2*UP), ApplyMethod(text3.move_to,1.5*UP))
+
+ A = TextMobject(r"$\left( \begin{array}{c c c} 1 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 3 \end{array}\right) \left[ \begin{array} {c} x_{1} \\ x_{2} \\ x_{3} \end{array}\right] =$", r"$\left[ \begin{array}{c} x_{1}+x_{2}+x_{3} \\ x_{1}+2x_{2}+x_{3} \\ x_{1}+x_{2}+3x_{3} \end{array}\right]$")
+ A.scale(0.75)
+ self.play(FadeIn(A))
+
+ textA = TextMobject("A")
+ textx = TextMobject("x")
+ textb = TextMobject("Ax")
+
+ textA.move_to(DOWN+3*LEFT)
+ textx.move_to(1.1*DOWN+0.5*LEFT)
+ textb.move_to(DOWN-2*LEFT)
+
+ self.play(Write(textA), Write(textx), Write(textb))
+
+ circle1 = Circle(radius = 0.24)
+ circle2 = Circle(radius = 0.24)
+ square = Square(side_length = 0.6)
+
+ circle1.move_to(UP*0.5+LEFT*3.05)
+ circle2.move_to(UP*0.4+LEFT*0.5)
+ square.move_to(UP*0.4+RIGHT*1.3)
+
+ self.play(FadeIn(circle1), FadeIn(circle2),FadeIn(square))
+
+ self.play(ApplyMethod(circle1.move_to,UP*0.5+LEFT*2.45), ApplyMethod(circle2.move_to,LEFT*0.5), ApplyMethod(square.move_to,UP*0.4+RIGHT*2.2))
+ self.play(ApplyMethod(circle1.move_to,UP*0.5+LEFT*1.85), ApplyMethod(circle2.move_to,DOWN*0.5+LEFT*0.5), ApplyMethod(square.move_to,UP*0.4+RIGHT*3.1))
+
+ self.play(ApplyMethod(circle1.move_to,LEFT*3.05), ApplyMethod(circle2.move_to,UP*0.4+LEFT*0.5), ApplyMethod(square.move_to,RIGHT*1.3))
+ self.play(ApplyMethod(circle1.move_to,LEFT*2.45), ApplyMethod(circle2.move_to,LEFT*0.5), ApplyMethod(square.move_to,RIGHT*2.2))
+ self.play(ApplyMethod(circle1.move_to,LEFT*1.85), ApplyMethod(circle2.move_to,DOWN*0.5+LEFT*0.5), ApplyMethod(square.move_to,RIGHT*3.1))
+
+ self.play(ApplyMethod(circle1.move_to,0.4*DOWN+LEFT*3.05), ApplyMethod(circle2.move_to,UP*0.4+LEFT*0.5), ApplyMethod(square.move_to,0.4*DOWN+RIGHT*1.3))
+ self.play(ApplyMethod(circle1.move_to,0.4*DOWN+LEFT*2.45), ApplyMethod(circle2.move_to,LEFT*0.5), ApplyMethod(square.move_to,0.4*DOWN+RIGHT*2.2))
+ self.play(ApplyMethod(circle1.move_to,0.4*DOWN+LEFT*1.85), ApplyMethod(circle2.move_to,DOWN*0.5+LEFT*0.5), ApplyMethod(square.move_to,0.4*DOWN+RIGHT*3.1))
+
+ self.play(FadeOut(circle1), FadeOut(circle2), FadeOut(square))
+ self.play(FadeOut(A[0]), ApplyMethod(A[1].move_to,2*LEFT),ApplyMethod(textb.move_to,DOWN+1.7*LEFT), FadeOut(textx), FadeOut(textA))
+ b = TextMobject(r"$=\left[ \begin{array}{c} b_{1} \\ b_{2} \\ b_{3} \end{array}\right]$")
+ b.move_to(RIGHT)
+ textB = TextMobject("b")
+ textB.move_to(1.2*DOWN+1.1*RIGHT)
+ self.play(FadeIn(b),FadeIn(textB))
+
+ self.wait()
+
+ self.play(FadeOut(text0), FadeOut(text1), FadeOut(text2), FadeOut(text3))
+
+ axb = TextMobject("Ax = b")
+ self.play(FadeIn(axb), FadeOut(textb), FadeOut(textB), FadeOut(b), FadeOut(A[1]))
+
+ self.wait() \ No newline at end of file