From 450b3d9b496aa7386d8cf52ed683f77cfe9abeb3 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sat, 20 Jun 2020 18:56:19 +0530 Subject: Review --- .../file1_projections.py | 85 ++++++++++ .../file2_orthonormal.py | 174 +++++++++++++++++++++ .../The-Four-Fundamental-Subspaces/Axb.py | 77 +++++++++ 3 files changed, 336 insertions(+) create mode 100755 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py create mode 100755 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py (limited to 'FSF-2020/linear-algebra/linear-transformations') 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 -- cgit From df07222008133f28cdaf27d614a07a9c1ee4bec1 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Thu, 2 Jul 2020 13:54:11 +0530 Subject: file1_of orthonormal bases updated --- .../Orthonormal Basis/file1_orthogonal.py | 26 +++++--- .../The-Four-Fundamental-Subspaces/solution.py | 75 ++++++++++++++++++++++ 2 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py index b400f93..a5d96f5 100755 --- a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py @@ -4,31 +4,37 @@ class Orthogonal(ThreeDScene): def construct(self): axes = ThreeDAxes() self.play(ShowCreation(axes)) - self.move_camera(phi=30*DEGREES,theta=-45*DEGREES,run_time=3) - line1 = Line(start = ORIGIN,end = -3*LEFT) + self.move_camera(phi=60*DEGREES,theta=45*DEGREES,run_time=3) + + text = TextMobject(r"$\hat{i}$",r"$\hat{j}$",r"$\hat{k}$") + text[0].move_to(0.7*DOWN+0.8*LEFT) + text[1].move_to(0.75*DOWN+0.7*RIGHT) + text[2].move_to(0.75*UP+0.4*RIGHT) + self.add_fixed_in_frame_mobjects(text) + self.play(Write(text)) + + line1 = Line(start = ORIGIN,end = RIGHT) line1.set_color(DARK_BLUE) - tip1 = Polygon(-LEFT,-0.8*LEFT-0.2*DOWN,-0.8*LEFT-0.2*UP) - tip1.move_to(-3*LEFT) + tip1 = Polygon(-0.95*LEFT,-0.8*LEFT-0.1*DOWN,-0.8*LEFT-0.1*UP) tip1.set_opacity(1) tip1.set_fill(DARK_BLUE) tip1.set_color(DARK_BLUE) - arrow2 = Line(start = ORIGIN,end = -3*UP) + arrow2 = Line(start = ORIGIN,end = UP) arrow2.set_color(DARK_BLUE) - tip2 = Polygon(DOWN,0.8*DOWN-0.2*RIGHT,0.8*DOWN-0.2*LEFT) - tip2.move_to(3*DOWN) + tip2 = Polygon(0.95*UP,0.8*UP-0.1*RIGHT,0.8*UP-0.1*LEFT) tip2.set_opacity(1) tip2.set_fill(DARK_BLUE) tip2.set_color(DARK_BLUE) arrow2.set_color(DARK_BLUE) - arrow3 = Line(start = ORIGIN,end = [0,0,3]) + arrow3 = Line(start = ORIGIN,end = [0,0,1]) arrow3.set_color(DARK_BLUE) - tip3 = Polygon([0,0,3],[0,0,2.8]-0.2*RIGHT,[0,0,2.8]-0.2*LEFT) + tip3 = Polygon([0,0,0.95],[0,0,0.8]-0.1*RIGHT,[0,0,0.8]-0.1*LEFT) tip3.set_opacity(1) tip3.set_fill(DARK_BLUE) tip3.set_color(DARK_BLUE) self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), ShowCreation(arrow3), ShowCreation(tip3)) - self.wait() \ No newline at end of file + self.wait() diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py new file mode 100644 index 0000000..fb31881 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py @@ -0,0 +1,75 @@ +from manimlib.imports import * +class solution(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original $2D$ vector space(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + A = TextMobject("Let $A$ denote the matrix the of this linear transformation.") + A.move_to(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 i.e. a line ($1D$)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + arrow2 = Arrow(start = ORIGIN, end = 2*DOWN+2*LEFT) + arrow2.set_color(DARK_BLUE) + arrow2.scale(1.2) + self.play(ShowCreation(arrow2)) + self.wait() + + o1 = TextMobject("If the vector lies in the transformed vector space") + o2 = TextMobject("(the line) then the solution exist") + o1.move_to(2*DOWN+2*RIGHT) + o2.move_to(2.5*DOWN+2*RIGHT) + o1.scale(0.75) + o2.scale(0.75) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + self.play(FadeOut(o1), FadeOut(o2)) + + self.play(FadeOut(arrow2)) + + arrow1 = Arrow(start = ORIGIN, end = 2*UP+RIGHT) + arrow1.set_color(DARK_BLUE) + arrow1.scale(1.3) + self.play(ShowCreation(arrow1)) + self.wait() + + o1 = TextMobject("If the vector does lies in the transformed") + o2 = TextMobject("vector space then the does not solution exist") + o1.move_to(2*DOWN+2*RIGHT) + o2.move_to(2.5*DOWN+2*RIGHT) + o1.scale(0.75) + o2.scale(0.75) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + self.play(FadeOut(o1), FadeOut(o2)) + + self.play(FadeOut(arrow1)) + \ No newline at end of file -- cgit From d3e8ac1760878ee50eb37d16c5a8a9a5e847639e Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sat, 4 Jul 2020 16:32:29 +0530 Subject: new repo due to large gif --- .../Orthonormal Basis/file2_OrthonormalBasis.py | 82 ---------- .../file2_sum_of_projections_part1.py | 133 ++++++++++++++++ .../file3_sum_of_projections_part2.py | 173 +++++++++++++++++++++ 3 files changed, 306 insertions(+), 82 deletions(-) delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py create mode 100755 FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_sum_of_projections_part1.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file3_sum_of_projections_part2.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py deleted file mode 100644 index 0a28f22..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py +++ /dev/null @@ -1,82 +0,0 @@ -from manimlib.imports import * -class OrthonormalBasis(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) - - arrow1 = Arrow(start = ORIGIN,end = 0.707*YTD*UP+0.707*XTD*RIGHT) - arrow1.scale(2.25) - arrow1.set_color(DARK_BLUE) - - arrow2 = Arrow(start = ORIGIN,end = 0.707*YTD*UP+0.707*XTD*LEFT) - arrow2.scale(2.25) - arrow2.set_color(DARK_BLUE) - - square = Polygon(UP*0.4*YTD,0.2*(YTD*UP+XTD*RIGHT),ORIGIN,0.2*(YTD*UP+XTD*LEFT)) - square.set_color(DARK_BLUE) - self.play(ShowCreation(arrow2), ShowCreation(arrow1), ShowCreation(square)) - - ortho = TextMobject("Orthonormal Vectors") - ortho.scale(0.75) - ortho.move_to(DOWN+3*RIGHT) - self.play(Write(ortho)) - self.wait() - self.play(FadeOut(ortho)) - - arrow3 = Arrow(start = ORIGIN,end = YTD*3*UP+XTD*LEFT) - arrow3.scale(1.25) - arrow3.set_color(GOLD_E) - self.play(ShowCreation(arrow3)) - - arrow4 = Arrow(start = ORIGIN,end = YTD*UP+XTD*RIGHT) - arrow4.scale(1.8) - arrow4.set_color(GOLD_A) - - arrow5 = Arrow(start = ORIGIN,end = 2*YTD*UP-2*XTD*RIGHT) - arrow5.scale(1.3) - arrow5.set_color(GOLD_A) - - self.play(ShowCreation(arrow5), ShowCreation(arrow4)) - - self.wait() - - self.play(FadeOut(arrow1), FadeOut(arrow2), FadeOut(square)) - - self.wait() - - text1 = TextMobject(r"$ v_1$") - text1.move_to(UP+2*RIGHT) - text1.scale(0.75) - text2 = TextMobject(r"$ v_2$") - text2.move_to(UP+3*LEFT) - text2.scale(0.75) - - text3 = TextMobject("v") - text3.move_to(YTD*3.5*UP+XTD*1.5*LEFT) - - self.play(Write(text1), Write(text2), Write(text3)) - self.wait() - - line1 = DashedLine(start = YTD*UP+XTD*RIGHT, end = YTD*3*UP+XTD*1*LEFT) - line2 = DashedLine(start = YTD*2*UP+XTD*2*LEFT, end = YTD*3*UP+XTD*1*LEFT) - self.play(ShowCreation(line1),ShowCreation(line2)) - - self.wait() - - text = TextMobject(r"$v$ is the sum of projections","on the orthonormal vectors") - text[0].move_to(DOWN+3.2*RIGHT) - text[1].move_to(1.5*DOWN+3.2*RIGHT) - self.play(Write(text)) - self.wait(2) - self.play(FadeOut(arrow3), FadeOut(arrow4), FadeOut(arrow5), FadeOut(text1), FadeOut(text2), FadeOut(text3), FadeOut(self.axes), FadeOut(line1), FadeOut(line2)) - self.play(FadeOut(text)) diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_sum_of_projections_part1.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_sum_of_projections_part1.py new file mode 100755 index 0000000..81a0888 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_sum_of_projections_part1.py @@ -0,0 +1,133 @@ +from manimlib.imports import * +class LinearTrans(LinearTransformationScene): + CONFIG = { + "show_basis_vectors": True, + "basis_vector_stroke_width": 1, + "leave_ghost_vectors": False, + "show_coordinates": True, + } + + def construct(self): + + self.setup() + + matrix = [[0.6,-0.8],[0.8,0.6]] + self.apply_matrix(matrix) + + self.wait(2) + orthonormal = TextMobject(r"These are 2 orthonormal vectors($v_1$ and $v_2$)") + orthonormal.scale(0.7) + orthonormal.move_to(DOWN+LEFT*3.5) + orthonormal.add_background_rectangle() + v1 = TextMobject(r"$v_1$") + v1.scale(0.75) + v1.set_color(X_COLOR) + v1.move_to(0.75*UP+RIGHT) + v1.add_background_rectangle() + v2 = TextMobject(r"$v_2$") + v2.scale(0.75) + v2.set_color(Y_COLOR) + v2.move_to(0.75*UP+LEFT*1.25) + v2.add_background_rectangle() + self.play(Write(orthonormal)) + self.play(Write(v1),Write(v2)) + self.wait() + self.play(FadeOut(orthonormal), FadeOut(v1), FadeOut(v2)) + + arrow = Arrow(start = ORIGIN,end = 3*RIGHT+UP) + arrow.scale(1.2) + arrow.set_color(BLUE) + arrow.apply_matrix(matrix) + text3 = TextMobject("v") + text3.move_to(3.2*UP+1.2*RIGHT) + text3.add_background_rectangle() + self.play(ShowCreation(arrow),Write(text3)) + self.wait() + v_cor = TextMobject("(1,3)") + v_cor.move_to(3.2*UP+1.3*RIGHT) + v_cor.set_color(BLUE) + v_cor.scale(0.75) + v_cor.add_background_rectangle() + self.play(Transform(text3,v_cor)) + + line1 = DashedLine(start = 1*UP+3*RIGHT, end = 3*RIGHT) + line2 = DashedLine(start = 1*UP+3*RIGHT, end = UP) + line1.apply_matrix(matrix) + line2.apply_matrix(matrix) + self.play(ShowCreation(line1),ShowCreation(line2),run_time = 2) + + v1 = Arrow(start = ORIGIN,end = 3*RIGHT+UP) + v1.scale(1.2) + v1.set_color(BLUE) + v1.apply_matrix(matrix) + arrow1 = Arrow(start = ORIGIN,end = 3*RIGHT) + arrow1.scale(1.2) + arrow1.set_color("#6B8E23") + arrow1.apply_matrix(matrix) + self.play(Transform(v1,arrow1)) + v1_cor = TextMobject(r"$ v_1$") + v1_cor.move_to(2.5*UP+3*RIGHT) + v1_cor.scale(0.75) + v1_cor.add_background_rectangle() + self.play(Write(v1_cor)) + self.wait(0.5) + text1 = TextMobject(r"(1.8,2.4)") + text1.move_to(2.1*UP+2.5*RIGHT) + text1.scale(0.75) + text1.set_color("#6B8E23") + text1.add_background_rectangle() + self.play(Transform(v1_cor,text1)) + + v2 = Arrow(start = ORIGIN,end = 3*RIGHT+UP) + v2.scale(1.2) + v2.set_color("#8b0000") + v2.apply_matrix(matrix) + arrow2 = Arrow(start = ORIGIN,end = UP) + arrow2.scale(2.1) + arrow2.set_color("#8b0000") + arrow2.apply_matrix(matrix) + self.wait(0.5) + self.play(Transform(v2,arrow2)) + self.wait(0.5) + v2_cor = TextMobject(r"$ v_2$") + v2_cor.move_to(0.75*UP+2.5*LEFT) + v2_cor.scale(0.75) + v2_cor.add_background_rectangle() + self.play(Write(v2_cor)) + self.wait(0.5) + text2 = TextMobject(r"(-0.8,0.6)") + text2.move_to(0.75*UP+1.75*LEFT) + text2.scale(0.75) + text2.set_color("#8b0000") + text2.add_background_rectangle() + self.play(Transform(v2_cor,text2)) + + self.wait() + + self.play(ApplyMethod(v2.move_to,1.4*RIGHT+2.7*UP),FadeOut(v1_cor),FadeOut(v2_cor),FadeOut(v_cor)) + + self.wait() + + ending = TextMobject(r"$v = v_1 + v_2$") + ending.scale(0.7) + ending.move_to(DOWN) + ending.add_background_rectangle() + self.play(Write(ending)) + self.wait() + self.play(FadeOut(ending)) + + ending = TextMobject(r"$\left[ \begin{array} {c} 1\\ 3 \end{array}\right] = \left[ \begin{array} {c}1.8 \\ 2.4 \end{array}\right] + \left[ \begin{array} {c} -0.8\\ 0.6 \end{array}\right]$") + ending.scale(0.7) + ending.move_to(DOWN) + ending.add_background_rectangle() + self.play(Write(ending)) + self.wait() + self.play(FadeOut(ending)) + + ending = TextMobject(r"$v$ is the sum of projections on the orthonormal vectors") + ending.scale(0.7) + ending.move_to(DOWN) + ending.add_background_rectangle() + self.play(Write(ending)) + self.wait() + self.play(FadeOut(ending)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file3_sum_of_projections_part2.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file3_sum_of_projections_part2.py new file mode 100644 index 0000000..9d25192 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file3_sum_of_projections_part2.py @@ -0,0 +1,173 @@ +from manimlib.imports import * +class ThreeDExplanation(ThreeDScene): + + def construct(self): + + text = TextMobject("Let us consider the example discussed above again. These are the things we know:-") + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*UP) + self.play(Write(text)) + self.wait(2) + basis = TextMobject(r"Set of Orthonormal Basis - $\left(\begin{array}{c}\frac{1}{\sqrt{2}}\\\frac{1}{\sqrt{2}}\\0\end{array}\right),\left(\begin{array}{c}\frac{-1}{\sqrt{2}}\\\frac{1}{\sqrt{2}}\\0\end{array}\right),\left(\begin{array}{c}0\\0\\1\end{array}\right)$") + basis.scale(0.75) + basis.move_to(UP*1.5) + self.play(Write(basis)) + v = TextMobject(r"$v_1$",r"$v_2$",r"$v_3$") + v[0].move_to(UP*0.5+RIGHT*0.75) + v[1].move_to(UP*0.5+RIGHT*2.5) + v[2].move_to(UP*0.5+RIGHT*4) + eq = TextMobject(r"$v = \left(\begin{array}{c}3\\4\\5\end{array}\right)$") + eq1 = TextMobject(r"$ = \frac{3}{\sqrt{2}} + \frac{4}{\sqrt{2}} + 0 = \frac{7}{\sqrt{2}}$") + eq2 = TextMobject(r"$ = \frac{-3}{\sqrt{2}} + \frac{4}{\sqrt{2}} + 0 =\frac{1}{\sqrt{2}}$") + eq3 = TextMobject(r"$ =  0 + 0 + 5 =5$") + eq.move_to(4*LEFT+DOWN) + eq1.move_to(0.5*DOWN+2*RIGHT) + eq2.move_to(1.5*DOWN+2*RIGHT) + eq3.move_to(2.5*DOWN+2*RIGHT) + self.play(Write(v)) + self.play(Write(eq)) + self.play(Write(eq1)) + self.play(Write(eq2)) + self.play(Write(eq3)) + self.wait() + self.play(FadeOut(text), FadeOut(basis), FadeOut(eq), FadeOut(v), FadeOut(eq1), FadeOut(eq2), FadeOut(eq3)) + self.wait() + + text = TextMobject("These are the 3 mutually orthonormal basis of the set(", r"$v_1$, ", r"$v_2$, ", r"$v_3$",")") + text[1].set_color(DARK_BLUE) + text[2].set_color(RED) + text[3].set_color(YELLOW) + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN) + self.play(Write(text)) + self.wait() + + axes = ThreeDAxes(x_min = -9,x_max=9,y_min=-9,y_max=9,z_min=-9,z_max=9) + self.play(ShowCreation(axes)) + self.move_camera(distance = 100, phi=30*DEGREES,theta=45*DEGREES,run_time=3) + self.begin_ambient_camera_rotation(rate=0.3) + + dashedline1 = DashedLine(start = -12*(UP+RIGHT), end = 12*(UP+RIGHT)) + dashedline2 = DashedLine(start = -12*(UP+LEFT), end = 12*(UP+LEFT)) + dashedline3 = DashedLine(start = 4*UP+3*RIGHT+[0,0,5], end = 3.5*UP+3.5*RIGHT) + dashedline4 = DashedLine(start = 4*UP+3*RIGHT+[0,0,5], end = 0.5*UP+0.5*LEFT) + dashedline5 = DashedLine(start = 4*UP+3*RIGHT+[0,0,5], end = [0,0,5]) + + self.play(ShowCreation(dashedline1), ShowCreation(dashedline2)) + + line1 = Line(start = ORIGIN,end = 0.707*RIGHT + 0.707*UP) + line1.set_color(DARK_BLUE) + tip1 = Polygon(0.707*RIGHT + 0.707*UP, 0.707*RIGHT + 0.607*UP, 0.607*RIGHT + 0.707*UP) + tip1.set_opacity(1) + tip1.set_fill(DARK_BLUE) + tip1.set_color(DARK_BLUE) + self.play(ShowCreation(line1), ShowCreation(tip1)) + + line2 = Line(start = ORIGIN,end = 0.707*LEFT + 0.707*UP) + line2.set_color(RED) + tip2 = Polygon(0.707*LEFT + 0.707*UP, 0.707*LEFT + 0.607*UP, 0.607*LEFT + 0.707*UP) + tip2.set_opacity(1) + tip2.set_fill(RED) + tip2.set_color(RED) + + self.play(ShowCreation(line2), ShowCreation(tip2)) + + line3 = Line(start = ORIGIN,end = [0,0,1]) + line3.set_color(YELLOW) + 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(YELLOW) + tip3.set_color(YELLOW) + self.play(ShowCreation(line3), ShowCreation(tip3)) + self.wait() + + self.play(FadeOut(text)) + + text = TextMobject("Take the projection of ", r"$v$", " on the mutually orthonormal vectors") + text[1].set_color(GOLD_E) + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN) + self.play(Write(text)) + self.wait(2) + + a_line = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + a_line.set_color(GOLD_E) + a_tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + a_tip.set_opacity(1) + a_tip.set_fill(GOLD_E) + a_tip.set_color(GOLD_E) + + self.play(ShowCreation(a_line), ShowCreation(a_tip)) + self.wait(9) + self.play(ShowCreation(dashedline3),ShowCreation(dashedline4),ShowCreation(dashedline5)) + self.wait(6) + + pv1 = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + pv1.set_color(GOLD_E) + pv1tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + pv1tip.set_opacity(1) + pv1tip.set_fill(GOLD_E) + pv1tip.set_color(GOLD_E) + + v1_p = Line(start = ORIGIN,end = 3.5*RIGHT + 3.5*UP) + v1_p.set_color(BLUE_E) + v1_p_tip = Polygon(3.5*RIGHT + 3.5*UP, 3.5*RIGHT + 3.4*UP, 3.4*RIGHT + 3.5*UP) + v1_p_tip.set_opacity(1) + v1_p_tip.set_fill(BLUE_E) + v1_p_tip.set_color(BLUE_E) + + pv2 = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + pv2.set_color(GOLD_E) + pv2tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + pv2tip.set_opacity(1) + pv2tip.set_fill(GOLD_E) + pv2tip.set_color(GOLD_E) + + v2_p = Line(start = ORIGIN,end = 0.5*LEFT + 0.5*UP) + v2_p.set_color(RED_E) + v2_p_tip = Polygon(0.5*LEFT + 0.5*UP, 0.5*LEFT + 0.4*UP, 0.4*LEFT + 0.5*UP) + v2_p_tip.set_opacity(1) + v2_p_tip.set_fill(RED_E) + v2_p_tip.set_color(RED_E) + + pv3 = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + pv3.set_color(GOLD_E) + pv3tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + pv3tip.set_opacity(1) + pv3tip.set_fill(GOLD_E) + pv3tip.set_color(GOLD_E) + + v3_p = Line(start = ORIGIN,end = [0,0,5]) + v3_p.set_color(YELLOW_E) + v3_p_tip = Polygon([0,0,5],[0,0,4.8]+0.2*RIGHT,[0,0,4.8]+0.2*LEFT) + v3_p_tip.set_opacity(1) + v3_p_tip.set_fill(YELLOW_E) + v3_p_tip.set_color(YELLOW_E) + + self.stop_ambient_camera_rotation() + self.play(Transform(pv1,v1_p), Transform(pv1tip,v1_p_tip), Transform(pv2,v2_p), Transform(pv2tip,v2_p_tip), Transform(pv3,v3_p), Transform(pv3tip,v3_p_tip)) + self.play(FadeOut(dashedline1), + FadeOut(dashedline2), + FadeOut(dashedline3), + FadeOut(dashedline4), + FadeOut(dashedline5), + FadeOut(line1), + FadeOut(tip1), + FadeOut(line2), + FadeOut(tip2), + FadeOut(line3), + FadeOut(tip3), + FadeOut(text)) + + text = TextMobject(r"$v$ is the sum of projections on the orthonormal vectors") + text.set_color(GOLD_E) + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN) + self.play(Write(text), ApplyMethod(pv2.move_to,(3.5*RIGHT + 3.5*UP+3*RIGHT+4*UP)/2), ApplyMethod(pv2tip.move_to,(3.1*RIGHT + 3.9*UP))) + self.play(ApplyMethod(pv3.move_to,3*RIGHT + 4*UP + [0,0,2.5]), ApplyMethod(pv3tip.move_to,(3*RIGHT + 4*UP + [0,0,4.8]))) + + self.wait(3) \ No newline at end of file -- cgit From ba43051d6bac9074939a10e44e99935cad80d7c3 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sun, 5 Jul 2020 11:07:04 +0530 Subject: Animation In Linear Transformation --- .../file_before_matrix.py | 191 +++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py new file mode 100644 index 0000000..85a2983 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py @@ -0,0 +1,191 @@ +from manimlib.imports import * + +class linear(GraphScene): + + CONFIG = { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN+RIGHT, + "x_labeled_nums": list(range(-5, 6)), + "y_labeled_nums": list(range(-5, 6)), + "x_axis_width": 7, + "y_axis_height": 7, + } + + def construct(self): + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate = True) + heading = TextMobject(r"$T(x,y) = T(x+2y,x-y)$") + heading.move_to(UP*3+LEFT*4) + self.play(Write(heading)) + self.wait() + + before = TextMobject("Before Linear Transformation") + before.set_color(DARK_BLUE) + before.move_to(3*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(self.graph_origin+1*XTD*RIGHT+1*YTD*UP) + dot2 = Dot().shift(self.graph_origin+2*XTD*RIGHT+1*YTD*UP) + dot1.set_color(DARK_BLUE) + dot2.set_color(DARK_BLUE) + p1 = TextMobject(r"$P_1$") + p1.set_color(DARK_BLUE) + p1.move_to(self.graph_origin+1*XTD*RIGHT+2*YTD*UP) + p2 = TextMobject(r"$P_2$") + p2.set_color(DARK_BLUE) + p2.move_to(self.graph_origin+2*XTD*RIGHT+2*YTD*UP) + + after = TextMobject("After applying Linear Transformation") + after.set_color(RED) + after.move_to(3*UP+4.5*RIGHT) + after.scale(0.75) + dot3 = Dot().shift(self.graph_origin+3*XTD*RIGHT+0*YTD*UP) + dot4 = Dot().shift(self.graph_origin+4*XTD*RIGHT+1*YTD*UP) + dot3.set_color(RED) + dot4.set_color(RED) + p3 = TextMobject(r"$P_3$") + p3.set_color(RED) + p3.move_to(self.graph_origin+3*XTD*RIGHT-1.1*YTD*UP) + p4 = TextMobject(r"$P_4$") + p4.set_color(RED) + p4.move_to(self.graph_origin+4*XTD*RIGHT+2*YTD*UP) + + tp1 = TextMobject(r"$T(P_1) = P_3$") + tp1.set_color(RED) + tp1.move_to(DOWN+4*LEFT) + tp2 = TextMobject(r"$T(P_2) = P_4$") + tp2.set_color(RED) + tp2.move_to(2*DOWN+4*LEFT) + + self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) + self.wait(3) + self.play(Transform(before,after), Transform(dot1,dot3), Transform(dot2,dot4), Transform(p2,p4), Transform(p1,p3), Write(tp1), Write(tp2)) + self.wait(3) + + +class withgrid(LinearTransformationScene): + def construct(self): + + heading = TextMobject(r"$T(x,y) = (x+2y,x-y)$") + heading.move_to(UP*2.5+LEFT*4) + self.play(Write(heading)) + self.wait() + + before = TextMobject("Before Linear Transformation") + before.set_color(DARK_BLUE) + before.move_to(3.5*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(1*RIGHT+1*UP) + dot2 = Dot().shift(2*RIGHT+1*UP) + dot1.set_color(DARK_BLUE) + dot2.set_color(DARK_BLUE) + + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) + dot2_c = Dot(radius = 0.05).shift(2*RIGHT+1*UP) + dot1_c.set_color(RED) + dot2_c.set_color(RED) + self.add_transformable_mobject(dot1_c) + self.add_transformable_mobject(dot2_c) + + p1 = TextMobject(r"$P_1$") + p1.set_color(DARK_BLUE) + p1.move_to(1*RIGHT+1.5*UP) + p2 = TextMobject(r"$P_2$") + p2.set_color(DARK_BLUE) + p2.move_to(2*RIGHT+1.5*UP) + + after = TextMobject("After applying Linear Transformation") + after.set_color(RED) + after.move_to(3.5*UP+3.5*RIGHT) + after.scale(0.75) + dot3 = Dot().shift(3*RIGHT+0*UP) + dot4 = Dot().shift(4*RIGHT+1*UP) + dot3.set_color(RED) + dot4.set_color(RED) + p3 = TextMobject(r"$P_3$") + p3.set_color(RED) + p3.move_to(3*RIGHT-0.6*UP) + p4 = TextMobject(r"$P_4$") + p4.set_color(RED) + p4.move_to(4*RIGHT+1.5*UP) + + self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) + self.wait(3) + matrix = [[1,2],[1,-1]] + self.apply_matrix(matrix) + self.play(Transform(before,after), Transform(p2,p4), Transform(p1,p3)) + self.play(Transform(before,after)) + self.wait(3) + + ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+2y \\ x-y\end{array}\right]$") + ending.move_to(UP*2+LEFT*4) + self.play(Transform(heading,ending)) + self.wait() + +from manimlib.imports import * +class ThreeDExplanation(ThreeDScene): + + def construct(self): + + text = TextMobject(r"$T(x,y) = (x+y,x-y,x+2y)$") + text.scale(0.75) + text.move_to(UP*2.5+LEFT*4) + self.add_fixed_in_frame_mobjects(text) + self.play(Write(text)) + self.wait() + + before = TextMobject("Before Linear Transformation") + self.add_fixed_in_frame_mobjects(before) + before.set_color(GREEN_E) + before.move_to(3.5*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(1*RIGHT+1*UP) + dot2 = Dot().shift(2*RIGHT+1*UP) + dot3 = Dot().shift(1*RIGHT+1*UP) + dot1.set_color(GREEN_E) + dot2.set_color(GREEN_E) + dot3.set_color(GREEN_E) + self.play(ShowCreation(before)) + + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) + dot2_c = Dot(radius = 0.05).shift(0*RIGHT+2*UP) + dot3_c = Dot(radius = 0.05).shift(1*RIGHT-1*UP) + dot1_c.set_color(RED) + dot2_c.set_color(RED) + dot3_c.set_color(RED) + + axes = ThreeDAxes(x_min = -7,x_max=7,y_min=-4,y_max=4,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + self.move_camera(distance = 100, phi=30*DEGREES,theta=45*DEGREES,run_time=3) + + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(1) + self.stop_ambient_camera_rotation() + + plane = NumberPlane() + self.play(ShowCreation(dot1),ShowCreation(dot3),ShowCreation(dot2),ShowCreation(plane)) + + self.play(FadeOut(before)) + after = TextMobject("After applying Linear Transformation") + self.add_fixed_in_frame_mobjects(after) + after.set_color(RED) + after.move_to(3.5*UP+3.5*RIGHT) + after.scale(0.75) + + matrix = [[1,1],[1,-1],[2,1]] + self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(dot3),ApplyMethod(plane.apply_matrix,matrix),ApplyMethod(dot1_c.apply_matrix,matrix),ApplyMethod(dot3_c.apply_matrix,matrix),ApplyMethod(dot2_c.apply_matrix,matrix)) + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(3) + self.stop_ambient_camera_rotation() + + ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+y \\ x-y \\ x+2y \end{array}\right]$") + ending.scale(0.75) + ending.move_to(-UP*2+LEFT*4) + self.play(Transform(text,ending)) + self.add_fixed_in_frame_mobjects(ending) + self.wait(9) -- cgit From ad41877105cce82da726387083f4c63deb4f4f7c Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sun, 5 Jul 2020 11:54:11 +0530 Subject: video 1 of GSOP --- .../file_introduction.py | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py new file mode 100644 index 0000000..ccd23c9 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py @@ -0,0 +1,33 @@ +from manimlib.imports import * + +class Orthonormal(Scene): + def construct(self): + Centre = DOWN + arrow_1 = Arrow(start = Centre+ORIGIN,end = Centre+1.414*(UP+RIGHT)) + arrow_2 = Arrow(start = Centre+ORIGIN,end = Centre+2*UP) + arrow_1.scale(1.35) + arrow_2.scale(1.35) + text = TextMobject("This is a set of linearly independent vectors") + text.scale(0.75) + text.move_to(3*UP+3*LEFT) + text.set_color(PURPLE_E) + arrow_1.set_color(PURPLE_E) + arrow_2.set_color(PURPLE_E) + self.play(Write(text)) + self.play(ShowCreation(arrow_1), ShowCreation(arrow_2)) + self.wait(2) + text1 = TextMobject("After we apply Gram-Schmidt Orthogonalization Process to set of linearly independent vectors") + text1.scale(0.6) + text1.move_to(3*UP+2*LEFT) + text1.set_color(GREEN) + arrow_a = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+RIGHT)) + arrow_a.set_color(GREEN) + arrow_a.scale(2) + self.play(Transform(text,text1)) + self.wait(2) + self.play(Transform(arrow_1,arrow_a)) + arrow_b = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+LEFT)) + arrow_b.set_color(GREEN) + arrow_b.scale(2) + self.play(Transform(arrow_2,arrow_b)) + self.wait(2) \ No newline at end of file -- cgit From 747f68c91279c9915382f0013ddc80fa67bd6d09 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sun, 5 Jul 2020 12:53:03 +0530 Subject: Video 2 on projections added --- .../file1_projections.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'FSF-2020/linear-algebra/linear-transformations') 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 index 814fa57..dd4b8d4 100755 --- 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 @@ -23,10 +23,10 @@ class Projections(GraphScene): 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 = TextMobject(r"Consider 2 linearly independent vectors $a$ and $b$") text.set_color(DARK_BLUE) - text.scale(0.75) - text.move_to(2*YTD*DOWN+4*XTD*LEFT) + text.scale(0.6) + text.move_to(3*YTD*UP+5*XTD*LEFT) text_a = TextMobject("a") text_a.move_to(0.4*YTD*DOWN+3*XTD*RIGHT) text_a.set_color(DARK_BLUE) @@ -51,7 +51,7 @@ class Projections(GraphScene): 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.move_to(3*UP+4*LEFT) text.scale(0.8) self.play(Write(text),Write(text_p)) self.wait() @@ -76,10 +76,4 @@ class Projections(GraphScene): 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 + 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)) \ No newline at end of file -- cgit From 1697d2286a00b1bfdac00320a60c968ac5a45eaf Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sun, 5 Jul 2020 18:19:17 +0530 Subject: Video 3: For Algo of GSOP added --- .../file2_orthonormal.py | 207 ++++++++++++++++++--- 1 file changed, 183 insertions(+), 24 deletions(-) (limited to 'FSF-2020/linear-algebra/linear-transformations') 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 index 640b8be..af51fc6 100644 --- 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 @@ -1,18 +1,153 @@ from manimlib.imports import * -from manimlib.imports import * - -class Orthogonal(ThreeDScene): +class Algo(ThreeDScene): def construct(self): - text = TextMobject(r"These are two Orthogonal Basis $\alpha_{1}$ and $\alpha_{2}$") + axes = ThreeDAxes(x_min = -5,x_max=5,y_min=-3,y_max=3,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + + text = TextMobject(r"This is the vector $\beta_1(=\left[\begin{array}{c} 4\\0\\0 \end{array}\right])$") + text.set_color(GREEN) + text.scale(0.6) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + arrow_a = Arrow(start = ORIGIN, end = 4*RIGHT) + arrow_a.set_color(GREEN) + arrow_a.scale(1.15) + self.play(ShowCreation(arrow_a)) + + text_a = TextMobject(r"$\beta_1$") + text_a.move_to(0.4*DOWN+3*RIGHT) + text_a.set_color(GREEN) + text_a.scale(0.75) + self.play(Write(text_a)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"Normalize $\beta_1$ to get $\alpha_1$") + text.set_color(DARK_BLUE) text.scale(0.75) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + alpha_1 = Arrow(start = ORIGIN,end = RIGHT) + alpha_1.scale(1.9) + alpha_1.set_color(DARK_BLUE) + text_alpha_1 = TextMobject(r"$\alpha_1$") + text_alpha_1.move_to(0.4*DOWN+RIGHT) + text_alpha_1.set_color(DARK_BLUE) + text_alpha_1.scale(0.75) + self.play(Transform(text_a,text_alpha_1), Transform(arrow_a,alpha_1)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"Consider another vector $\beta_2(=\left[\begin{array}{c} 2\\2\\0 \end{array}\right])$") + text1 = TextMobject(r"which is linearly independent to $\beta_1$") + text.set_color(GREEN) + text1.set_color(GREEN) + text.scale(0.6) + text1.scale(0.6) + text.move_to(3*UP+4*LEFT) + text1.move_to(2*UP+4*LEFT) + self.play(Write(text)) + self.play(Write(text1)) + + arrow_b = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) + arrow_b.scale(1.2) + arrow_b.set_color(GREEN) + text_b = TextMobject(r"$\beta_2$") + text_b.move_to(1.5*UP+RIGHT) + text_b.set_color(GREEN) + text_b.scale(0.75) + + self.play(ShowCreation(arrow_b), Write(text_b)) + self.wait() + + arrow_b_copy = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) + arrow_b_copy.scale(1.2) + + arrow_p = Arrow(start = ORIGIN, end = 2*RIGHT) + arrow_p.scale(1.35) + 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), FadeOut(text1), Transform(arrow_b_copy,arrow_p), FadeOut(text_a), FadeOut(text_b)) + text = TextMobject(r"$p$ is the projection of $\beta_2$ on $\alpha_1$") + text.set_color(GOLD_E) + text.move_to(3*UP+4*LEFT) + text.scale(0.8) + self.play(Write(text),Write(text_p)) + self.wait() + + self.play(FadeIn(text_b)) + + arrow_o = Arrow(start = 2*RIGHT, end = 2*UP+2*RIGHT) + arrow_o.scale(1.35) + arrow_o.set_color(PURPLE_E) + + text_o = TextMobject(r"$\beta_2-p$") + text_o.move_to(UP+2.7*RIGHT) + text_o.scale(0.75) + text_o.set_color(PURPLE_E) + + self.play(ShowCreation(arrow_o)) + self.play(FadeOut(text),Write(text_o)) + + text = TextMobject(r"$\beta_2-p$ is orthogonal to p") + text1 = TextMobject(r"(and hence orthogonal to $\alpha_1$ also)") + text.set_color(PURPLE_E) + text1.set_color(PURPLE_E) + text.scale(0.7) + text1.scale(0.7) + text.move_to(3*UP+4*LEFT) + text1.move_to(2.5*UP+4*LEFT) + self.play(Write(text)) + self.play(Write(text1)) + self.wait(2) + + self.play(FadeOut(text_p), FadeIn(arrow_a), FadeOut(text), FadeOut(text1), FadeOut(arrow_b_copy), FadeOut(arrow_p), FadeOut(text_b), FadeOut(arrow_b)) + self.play(ApplyMethod(arrow_o.move_to,UP), ApplyMethod(text_o.move_to,RIGHT+UP)) + + text = TextMobject(r"Now, Normalize $\beta_2-p$") + text.set_color(DARK_BLUE) + text.scale(0.6) + text.move_to(3*UP+4*LEFT) + self.play(Write(text)) + + alpha_2 = Arrow(start = ORIGIN,end = UP) + alpha_2.scale(1.9) + alpha_2.set_color(DARK_BLUE) + text_alpha_2 = TextMobject(r"$\alpha_2$") + text_alpha_2.move_to(0.4*LEFT+UP) + text_alpha_2.set_color(DARK_BLUE) + text_alpha_2.scale(0.75) + self.play(Transform(text_o,text_alpha_2), Transform(arrow_o,alpha_2), FadeIn(text_a)) + self.wait() + self.play(FadeOut(text),FadeOut(text_a),FadeOut(text_o)) + + self.add(axes) + ############################################################################# + axis = TextMobject(r"$\alpha_1$",r"$\alpha_2$",r"$\alpha_3$",r"$\beta_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$") + axis.scale(0.5) + axis[0].move_to(0.5*RIGHT+[0,0,-0.5]) + axis[1].move_to(0.5*UP+[0,0,-0.5]) + axis[2].move_to(np.array([0,0,0.5])) + axis[3].move_to(np.array([1,1,1.5])) + self.add_fixed_orientation_mobjects(axis[0]) + self.add_fixed_orientation_mobjects(axis[1]) + ############################################################################# + + text = TextMobject(r"These are the same two orthonormal vectors $\alpha_{1}$ and $\alpha_{2}$") + text.scale(0.6) + text.set_color(DARK_BLUE) 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) @@ -31,7 +166,7 @@ class Orthogonal(ThreeDScene): tip2.set_color(DARK_BLUE) arrow2.set_color(DARK_BLUE) - self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2)) + self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), FadeOut(arrow_a), FadeOut(arrow_o)) self.wait() a_line = Line(start = ORIGIN,end = 2*UP+2*RIGHT+[0,0,2]) @@ -50,9 +185,11 @@ class Orthogonal(ThreeDScene): 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) + text = TextMobject(r"Now, we have a vector $\beta_3(=\left[\begin{array}{c} 2\\2\\2 \end{array}\right])$") + text.set_color(GOLD_E) + text.scale(0.7) self.add_fixed_in_frame_mobjects(text) + self.add_fixed_orientation_mobjects(axis[3]) text.move_to(3*(DOWN+RIGHT)) self.play(Write(text)) self.wait() @@ -69,7 +206,8 @@ class Orthogonal(ThreeDScene): 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) + text.scale(0.6) + text.set_color(GOLD_E) self.add_fixed_in_frame_mobjects(text) text.move_to(3*(DOWN+RIGHT)) self.play(Write(text)) @@ -98,14 +236,15 @@ class Orthogonal(ThreeDScene): a_tip1_c1.set_color(GREEN_E) text = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$)") - text.scale(0.75) + text.set_color(GREEN_E) + text.scale(0.6) 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), + FadeOut(a_line), FadeOut(a_tip), FadeOut(axis[3]), Transform(o_line1,a_line1), Transform(o_tip1,a_tip1)) self.wait() @@ -120,16 +259,17 @@ class Orthogonal(ThreeDScene): p_arrow2.set_color(GOLD_E) last_a = Line(start = 2*UP,end = [0,2,2]) - last_a.set_color(GOLD_E) + last_a.set_color(PURPLE_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) + last_a_tip.set_fill(PURPLE_E) + last_a_tip.set_color(PURPLE_E) self.wait() text = TextMobject(r"Take projection on $\alpha_2$") - text.scale(0.75) + text.scale(0.6) + text.set_color(GOLD_E) self.add_fixed_in_frame_mobjects(text) text.move_to(3*(DOWN+RIGHT)) self.play(Write(text)) @@ -138,9 +278,10 @@ class Orthogonal(ThreeDScene): 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) + text.set_color(PURPLE_E) + text.scale(0.6) self.add_fixed_in_frame_mobjects(text) - text.move_to(3*DOWN+2*RIGHT) + text.move_to(3*DOWN+3.5*RIGHT) self.play(Write(text)) self.play(ShowCreation(o_line1), ShowCreation(o_tip1)) self.wait(2) @@ -149,19 +290,26 @@ class Orthogonal(ThreeDScene): self.play(FadeOut(text)) larrow3 = Line(start = ORIGIN,end = [0,0,2]) - larrow3.set_color(GOLD_E) + larrow3.set_color(PURPLE_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) + ltip3.set_fill(PURPLE_E) + ltip3.set_color(PURPLE_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) + text = TextMobject(r"Normalize, the vector") + text1 = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$ + projection of $\beta_3$ on $\alpha_2$") + text.set_color(PURPLE_E) + text1.set_color(PURPLE_E) + text.scale(0.6) + text1.scale(0.6) self.add_fixed_in_frame_mobjects(text) - text.move_to(3*DOWN+2*RIGHT) + self.add_fixed_in_frame_mobjects(text1) + text.move_to(3*DOWN+3*RIGHT) + text1.move_to(3.5*DOWN+3*RIGHT) self.play(Write(text)) + self.play(Write(text1)) arrow3 = Line(start = ORIGIN,end = [0,0,1]) arrow3.set_color(DARK_BLUE) @@ -170,5 +318,16 @@ class Orthogonal(ThreeDScene): tip3.set_fill(DARK_BLUE) tip3.set_color(DARK_BLUE) self.play(Transform(last_a,arrow3), Transform(last_a_tip,tip3)) + self.add_fixed_orientation_mobjects(axis[2]) + + self.wait() + self.play(FadeOut(text),FadeOut(text1)) + + text = TextMobject(r"These are the three orthonormal vectors $\alpha_1, \alpha_2, \alpha_3$") + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.scale(0.6) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) self.wait(3) \ No newline at end of file -- cgit From 7b7ae0deb322b097c5e5940f6b9789a641af205a Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sun, 5 Jul 2020 19:36:24 +0530 Subject: code for last video of GSOP added --- .../file3_Non_Standard_Basis.py | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py new file mode 100644 index 0000000..6410a2c --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py @@ -0,0 +1,51 @@ +from manimlib.imports import * + +class NSB(ThreeDScene): + def construct(self): + + axes = ThreeDAxes(x_min = -4,x_max=4,y_min=-4,y_max=4,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + self.move_camera(phi=60*DEGREES,theta=45*DEGREES,run_time=3) + self.begin_ambient_camera_rotation(rate=0.5) + + matrix = [[0.577,0.577,0.577],[-0.577,0.577,0.577],[0.577,-0.577,0.577]] + + line1 = Line(start = ORIGIN,end = 1*RIGHT) + line1.set_color(DARK_BLUE) + tip1 = Polygon(RIGHT,0.9*RIGHT-0.1*DOWN,0.9*RIGHT-0.1*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.9*UP-0.1*RIGHT,0.9*UP-0.1*LEFT) + tip2.set_opacity(1) + tip2.set_fill(DARK_BLUE) + tip2.set_color(DARK_BLUE) + arrow2.set_color(DARK_BLUE) + + arrow3 = Line(start = ORIGIN,end = [0,0,1]) + arrow3.set_color(DARK_BLUE) + tip3 = Polygon([0,0,1],[0,0,0.9]-0.1*RIGHT,[0,0,0.9]-0.1*LEFT) + tip3.set_opacity(1) + tip3.set_fill(DARK_BLUE) + tip3.set_color(DARK_BLUE) + + line1.apply_matrix(matrix) + tip1.apply_matrix(matrix) + arrow2.apply_matrix(matrix) + tip2.apply_matrix(matrix) + arrow3.apply_matrix(matrix) + tip3.apply_matrix(matrix) + + self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), ShowCreation(arrow3), ShowCreation(tip3)) + + text = TextMobject(r"This is also a set of Orthonormal Vectors") + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.scale(0.6) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) + + self.wait(7) \ No newline at end of file -- cgit From f818aa6face482b21a46b2da9a32b27c212f5d4c Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Sun, 5 Jul 2020 21:21:57 +0530 Subject: modification to an animation --- .../file_before_matrix.py | 85 +++++++++++++++------- 1 file changed, 60 insertions(+), 25 deletions(-) mode change 100644 => 100755 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py old mode 100644 new mode 100755 index 85a2983..e0476a3 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py @@ -1,13 +1,13 @@ from manimlib.imports import * -class linear(GraphScene): +class Linear(GraphScene): CONFIG = { "x_min": -5, "x_max": 5, "y_min": -5, "y_max": 5, - "graph_origin": ORIGIN+RIGHT, + "graph_origin": ORIGIN, "x_labeled_nums": list(range(-5, 6)), "y_labeled_nums": list(range(-5, 6)), "x_axis_width": 7, @@ -22,6 +22,7 @@ class linear(GraphScene): self.setup_axes(animate = True) heading = TextMobject(r"$T(x,y) = T(x+2y,x-y)$") heading.move_to(UP*3+LEFT*4) + heading.scale(0.7) self.play(Write(heading)) self.wait() @@ -34,44 +35,42 @@ class linear(GraphScene): dot1.set_color(DARK_BLUE) dot2.set_color(DARK_BLUE) p1 = TextMobject(r"$P_1$") + p1.scale(0.75) p1.set_color(DARK_BLUE) - p1.move_to(self.graph_origin+1*XTD*RIGHT+2*YTD*UP) + p1.move_to(self.graph_origin+1*XTD*RIGHT+1.5*YTD*UP) p2 = TextMobject(r"$P_2$") p2.set_color(DARK_BLUE) - p2.move_to(self.graph_origin+2*XTD*RIGHT+2*YTD*UP) + p2.scale(0.75) + p2.move_to(self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) after = TextMobject("After applying Linear Transformation") after.set_color(RED) after.move_to(3*UP+4.5*RIGHT) - after.scale(0.75) + after.scale(0.5) dot3 = Dot().shift(self.graph_origin+3*XTD*RIGHT+0*YTD*UP) dot4 = Dot().shift(self.graph_origin+4*XTD*RIGHT+1*YTD*UP) dot3.set_color(RED) dot4.set_color(RED) - p3 = TextMobject(r"$P_3$") + p3 = TextMobject(r"$T(P_1)$") + p3.scale(0.7) p3.set_color(RED) p3.move_to(self.graph_origin+3*XTD*RIGHT-1.1*YTD*UP) - p4 = TextMobject(r"$P_4$") + p4 = TextMobject(r"$T(P_2)$") + p4.scale(0.7) p4.set_color(RED) - p4.move_to(self.graph_origin+4*XTD*RIGHT+2*YTD*UP) - - tp1 = TextMobject(r"$T(P_1) = P_3$") - tp1.set_color(RED) - tp1.move_to(DOWN+4*LEFT) - tp2 = TextMobject(r"$T(P_2) = P_4$") - tp2.set_color(RED) - tp2.move_to(2*DOWN+4*LEFT) + p4.move_to(self.graph_origin+4*XTD*RIGHT+1.5*YTD*UP) self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) self.wait(3) - self.play(Transform(before,after), Transform(dot1,dot3), Transform(dot2,dot4), Transform(p2,p4), Transform(p1,p3), Write(tp1), Write(tp2)) + self.play(Transform(before,after), Transform(dot1,dot3), Transform(dot2,dot4), Transform(p2,p4), Transform(p1,p3)) self.wait(3) class withgrid(LinearTransformationScene): def construct(self): - heading = TextMobject(r"$T(x,y) = (x+2y,x-y)$") + heading = TextMobject(r"Now, Imagine this happening for all the vectors") + heading.scale(0.5) heading.move_to(UP*2.5+LEFT*4) self.play(Write(heading)) self.wait() @@ -93,9 +92,11 @@ class withgrid(LinearTransformationScene): self.add_transformable_mobject(dot2_c) p1 = TextMobject(r"$P_1$") + p1.scale(0.75) p1.set_color(DARK_BLUE) p1.move_to(1*RIGHT+1.5*UP) p2 = TextMobject(r"$P_2$") + p2.scale(0.75) p2.set_color(DARK_BLUE) p2.move_to(2*RIGHT+1.5*UP) @@ -107,10 +108,12 @@ class withgrid(LinearTransformationScene): dot4 = Dot().shift(4*RIGHT+1*UP) dot3.set_color(RED) dot4.set_color(RED) - p3 = TextMobject(r"$P_3$") + p3 = TextMobject(r"$T(P_1)$") + p3.scale(0.75) p3.set_color(RED) p3.move_to(3*RIGHT-0.6*UP) - p4 = TextMobject(r"$P_4$") + p4 = TextMobject(r"$T(P_2)$") + p4.scale(0.75) p4.set_color(RED) p4.move_to(4*RIGHT+1.5*UP) @@ -118,6 +121,7 @@ class withgrid(LinearTransformationScene): self.wait(3) matrix = [[1,2],[1,-1]] self.apply_matrix(matrix) + self.play(FadeOut(dot1),FadeOut(dot2)) self.play(Transform(before,after), Transform(p2,p4), Transform(p1,p3)) self.play(Transform(before,after)) self.wait(3) @@ -141,17 +145,28 @@ class ThreeDExplanation(ThreeDScene): before = TextMobject("Before Linear Transformation") self.add_fixed_in_frame_mobjects(before) - before.set_color(GREEN_E) + before.set_color(YELLOW) before.move_to(3.5*UP+4*RIGHT) before.scale(0.75) + + p1 = TextMobject(r"$P_1$") + p2 = TextMobject(r"$P_2$") + p3 = TextMobject(r"$P_3$") + p1.scale(0.75) + p2.scale(0.75) + p3.scale(0.75) dot1 = Dot().shift(1*RIGHT+1*UP) dot2 = Dot().shift(2*RIGHT+1*UP) - dot3 = Dot().shift(1*RIGHT+1*UP) - dot1.set_color(GREEN_E) - dot2.set_color(GREEN_E) - dot3.set_color(GREEN_E) + dot3 = Dot().shift(1*RIGHT+1*DOWN) + dot1.set_color(YELLOW) + dot2.set_color(YELLOW) + dot3.set_color(YELLOW) self.play(ShowCreation(before)) - + + p1.move_to(1*RIGHT+1*UP+[0,0,0.5]) + p2.move_to(2*RIGHT+1*UP+[0,0,0.5]) + p3.move_to(1*RIGHT-1*UP+[0,0,0.5]) + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) dot2_c = Dot(radius = 0.05).shift(0*RIGHT+2*UP) dot3_c = Dot(radius = 0.05).shift(1*RIGHT-1*UP) @@ -168,6 +183,9 @@ class ThreeDExplanation(ThreeDScene): self.stop_ambient_camera_rotation() plane = NumberPlane() + self.add_fixed_orientation_mobjects(p1) + self.add_fixed_orientation_mobjects(p2) + self.add_fixed_orientation_mobjects(p3) self.play(ShowCreation(dot1),ShowCreation(dot3),ShowCreation(dot2),ShowCreation(plane)) self.play(FadeOut(before)) @@ -177,8 +195,23 @@ class ThreeDExplanation(ThreeDScene): after.move_to(3.5*UP+3.5*RIGHT) after.scale(0.75) + self.play(FadeOut(p1),FadeOut(p2),FadeOut(p3)) matrix = [[1,1],[1,-1],[2,1]] self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(dot3),ApplyMethod(plane.apply_matrix,matrix),ApplyMethod(dot1_c.apply_matrix,matrix),ApplyMethod(dot3_c.apply_matrix,matrix),ApplyMethod(dot2_c.apply_matrix,matrix)) + + p4 = TextMobject(r"$T(P_1)$") + p5 = TextMobject(r"$T(P_2)$") + p6 = TextMobject(r"$T(P_3)$") + p4.scale(0.75) + p5.scale(0.75) + p6.scale(0.75) + p4.move_to(2*RIGHT+0*UP+[0,0,3.5]) + p5.move_to(2*RIGHT-2*UP+[0,0,2.5]) + p6.move_to(0*RIGHT+2*UP+[0,0,1.5]) + self.add_fixed_orientation_mobjects(p5) + self.add_fixed_orientation_mobjects(p4) + self.add_fixed_orientation_mobjects(p6) + self.begin_ambient_camera_rotation(rate=0.3) self.wait(3) self.stop_ambient_camera_rotation() @@ -188,4 +221,6 @@ class ThreeDExplanation(ThreeDScene): ending.move_to(-UP*2+LEFT*4) self.play(Transform(text,ending)) self.add_fixed_in_frame_mobjects(ending) + + self.play(FadeOut(plane)) self.wait(9) -- cgit From 116a7e0bceceeaa961b8586219015d27f6576c1b Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Mon, 6 Jul 2020 04:44:52 +0530 Subject: rectangle to ||alogram --- .../Linear-Transformations-(Linear-Maps)/square.py | 246 +++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py new file mode 100644 index 0000000..e828de4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py @@ -0,0 +1,246 @@ +from manimlib.imports import * + +class Linear(GraphScene): + CONFIG = { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "x_labeled_nums": list(range(-5, 6)), + "y_labeled_nums": list(range(-5, 6)), + "x_axis_width": 7, + "y_axis_height": 7, + } + def construct(self): + + text = TextMobject("T(x,y) = T(x+y,y)") + text.scale(0.75) + text.set_color(PURPLE) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate = True) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3+3*RIGHT) + + a = TextMobject("(1,1)") + b = TextMobject("(3,1)") + c = TextMobject("(3,2)") + d = TextMobject("(1,2)") + a.scale(0.5) + b.scale(0.5) + c.scale(0.5) + d.scale(0.5) + a.move_to(self.graph_origin+0.6*UP+0.6*RIGHT) + b.move_to(self.graph_origin+0.6*UP+3.4*RIGHT) + c.move_to(self.graph_origin+2.4*UP+3.4*RIGHT) + d.move_to(self.graph_origin+2.6*UP+0.6*RIGHT) + + square = Polygon(self.graph_origin+UP+RIGHT,self.graph_origin+UP+3*RIGHT,self.graph_origin+2*UP+3*RIGHT,self.graph_origin+2*UP+RIGHT) + + self.play(Write(text1), Write(a), Write(b), Write(c), Write(d), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1), FadeOut(a), FadeOut(b), FadeOut(c), FadeOut(d), ApplyMethod(square.apply_matrix,[[1,1],[0,1]])) + + a = TextMobject("(2,1)") + b = TextMobject("(4,1)") + c = TextMobject("(3,2)") + d = TextMobject("(5,2)") + a.scale(0.5) + b.scale(0.5) + c.scale(0.5) + d.scale(0.5) + a.move_to(self.graph_origin+0.6*UP+1.6*RIGHT) + b.move_to(self.graph_origin+0.6*UP+4.4*RIGHT) + d.move_to(self.graph_origin+2.4*UP+5.4*RIGHT) + c.move_to(self.graph_origin+2.4*UP+2.6*RIGHT) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3+3*RIGHT) + + self.play(Write(text1), Write(a), Write(b), Write(c), Write(d)) + + self.wait(2) + +class grid(LinearTransformationScene): + def construct(self): + + text = TextMobject("Now, consider all the vectors.") + text.scale(0.75) + text.set_color(PURPLE) + text.move_to(2.5*UP+3*LEFT) + self.play(Write(text)) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) + square.set_color(YELLOW) + + self.play(Write(text1), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1)) + self.add_transformable_mobject(square) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + matrix = [[1,1],[0,1]] + + self.apply_matrix(matrix) + self.play(Write(text1)) + + self.wait() + +class grid2(LinearTransformationScene): + CONFIG = { + "include_background_plane": True, + "include_foreground_plane": False, + "show_coordinates": True, + "show_basis_vectors": True, + "basis_vector_stroke_width": 3, + "i_hat_color": X_COLOR, + "j_hat_color": Y_COLOR, + "leave_ghost_vectors": True, + } + + def construct(self): + + text = TextMobject("Now, let us focus only on the standard basis") + text.scale(0.7) + text.set_color(PURPLE) + text.move_to(2.5*UP+3.5*LEFT) + self.play(Write(text)) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) + square.set_color(YELLOW) + + self.play(Write(text1), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1)) + self.add_transformable_mobject(square) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + matrix = [[1,1],[0,1]] + + self.apply_matrix(matrix) + self.play(Write(text1)) + + self.play(FadeOut(square), FadeOut(text1)) + + cor_x = TextMobject("(1,0)") + cor_y = TextMobject("(1,1)") + cor_x.scale(0.65) + cor_y.scale(0.65) + cor_y.move_to(1.25*RIGHT+1.5*UP) + cor_x.move_to(0.75*RIGHT-0.5*UP) + cor_x.set_color(GREEN) + cor_y.set_color(RED) + + x_cor = TextMobject(r"$\left[\begin{array}{c} 1\\0\end{array}\right]$") + x_cor.set_color(GREEN) + x_cor.scale(0.5) + y_cor = TextMobject(r"$\left[\begin{array}{c} 1\\1\end{array}\right]$") + x_cor.move_to(0.75*RIGHT-0.5*UP) + y_cor.move_to(1.25*RIGHT+1.5*UP) + y_cor.set_color(RED) + y_cor.scale(0.5) + + text1 = TextMobject(r"$T(\left[\begin{array}{c} x\\y \end{array}\right]) = $",r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") + text1.scale(0.7) + text1.set_color(PURPLE) + text1.move_to(1.5*UP+3*LEFT) + + text = TextMobject(r"$T(x,y) = (x+y,y)$") + text.scale(0.6) + text.set_color(PURPLE) + text.move_to(1.5*UP+3*LEFT) + + self.play(FadeIn(text),FadeIn(cor_x), FadeIn(cor_y)) + self.wait() + + self.play(Transform(text,text1), Transform(cor_x,x_cor), Transform(cor_y,y_cor)) + + text3 = TextMobject(r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") + text3.scale(0.7) + text3.set_color(PURPLE) + text3.move_to(1.5*DOWN+5*LEFT) + + equal = TextMobject("=") + equal.move_to(1.5*DOWN+3.5*LEFT) + + text3 = TextMobject("[") + text4 = TextMobject(r"$\begin{array}{c} (1)x\\(0)x \end{array}$") + text5 = TextMobject(r"$\begin{array}{c} + \\ + \end{array}$") + text6 = TextMobject(r"$\begin{array}{c} (1)y\\(1)y \end{array}$") + text7 = TextMobject("]") + text3.scale(2) + text4.scale(0.7) + text5.scale(0.7) + text6.scale(0.7) + text7.scale(2) + text4.set_color(GREEN) + text5.set_color(PURPLE) + text6.set_color(RED) + text3.move_to(1.5*DOWN+3*LEFT) + text4.move_to(1.5*DOWN+2.5*LEFT) + text5.move_to(1.5*DOWN+2*LEFT) + text6.move_to(1.5*DOWN+1.5*LEFT) + text7.move_to(1.5*DOWN+1*LEFT) + + text1[1].scale(1.2) + self.play(FadeOut(text1[0]), ApplyMethod(text1[1].move_to,1.5*DOWN+5*LEFT), FadeIn(text3), FadeIn(equal), FadeIn(text4), FadeIn(text5), FadeIn(text6), FadeIn(text7)) + + self.wait() + self.play(FadeOut(text1[1])) + + self.play(ApplyMethod(text3.move_to,1.5*DOWN+6*LEFT), + ApplyMethod(text4.move_to,1.5*DOWN+5.5*LEFT), + ApplyMethod(text5.move_to,1.5*DOWN+5*LEFT), + ApplyMethod(text6.move_to,1.5*DOWN+4.5*LEFT), + ApplyMethod(text7.move_to,1.5*DOWN+4*LEFT)) + + text10 = TextMobject("[") + text11 = TextMobject(r"$\begin{array}{c} 1\\0 \end{array}$") + text13 = TextMobject(r"$\begin{array}{c} 1\\1 \end{array}$") + text14 = TextMobject("]") + text10.scale(2) + text11.scale(0.7) + text13.scale(0.7) + text14.scale(2) + text11.set_color(GREEN) + text13.set_color(RED) + text10.move_to(1.5*DOWN+3*LEFT) + text11.move_to(1.5*DOWN+2.75*LEFT) + text13.move_to(1.5*DOWN+2.25*LEFT) + text14.move_to(1.5*DOWN+2*LEFT) + + self.play(FadeIn(text10), Transform(x_cor,text11), Transform(y_cor,text13), FadeIn(text14)) + + text15 = TextMobject(r"$\left[\begin{array}{c} x\\y \end{array}\right]$") + text15.scale(0.7) + text15.set_color(PURPLE) + text15.move_to(1.5*DOWN+1.5*LEFT) + + self.play(FadeIn(text15)) + self.play(FadeOut(text3), FadeOut(text4), FadeOut(text5), FadeOut(text7), FadeOut(text6)) + + text1[0].scale(1.2) + self.play(ApplyMethod(text1[0].move_to,1.5*DOWN+4.5*LEFT), FadeOut(equal)) + self.wait(2) \ No newline at end of file -- cgit From 1e4ac7ee9a243d6fe878e2d22c250bc9475b5dad Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Mon, 6 Jul 2020 05:05:28 +0530 Subject: changes implemented --- .../file_before_matrix.py | 70 ++++++++++++---------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py index e0476a3..96e456d 100755 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py @@ -27,37 +27,37 @@ class Linear(GraphScene): self.wait() before = TextMobject("Before Linear Transformation") - before.set_color(DARK_BLUE) + before.set_color(ORANGE) before.move_to(3*UP+4*RIGHT) before.scale(0.75) dot1 = Dot().shift(self.graph_origin+1*XTD*RIGHT+1*YTD*UP) dot2 = Dot().shift(self.graph_origin+2*XTD*RIGHT+1*YTD*UP) - dot1.set_color(DARK_BLUE) - dot2.set_color(DARK_BLUE) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) p1 = TextMobject(r"$P_1$") p1.scale(0.75) - p1.set_color(DARK_BLUE) + p1.set_color(ORANGE) p1.move_to(self.graph_origin+1*XTD*RIGHT+1.5*YTD*UP) p2 = TextMobject(r"$P_2$") - p2.set_color(DARK_BLUE) + p2.set_color(ORANGE) p2.scale(0.75) p2.move_to(self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) after = TextMobject("After applying Linear Transformation") - after.set_color(RED) + after.set_color(YELLOW) after.move_to(3*UP+4.5*RIGHT) after.scale(0.5) dot3 = Dot().shift(self.graph_origin+3*XTD*RIGHT+0*YTD*UP) dot4 = Dot().shift(self.graph_origin+4*XTD*RIGHT+1*YTD*UP) - dot3.set_color(RED) - dot4.set_color(RED) + dot3.set_color(YELLOW) + dot4.set_color(YELLOW) p3 = TextMobject(r"$T(P_1)$") p3.scale(0.7) - p3.set_color(RED) + p3.set_color(YELLOW) p3.move_to(self.graph_origin+3*XTD*RIGHT-1.1*YTD*UP) p4 = TextMobject(r"$T(P_2)$") p4.scale(0.7) - p4.set_color(RED) + p4.set_color(YELLOW) p4.move_to(self.graph_origin+4*XTD*RIGHT+1.5*YTD*UP) self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) @@ -76,52 +76,54 @@ class withgrid(LinearTransformationScene): self.wait() before = TextMobject("Before Linear Transformation") - before.set_color(DARK_BLUE) + before.set_color(ORANGE) before.move_to(3.5*UP+4*RIGHT) before.scale(0.75) dot1 = Dot().shift(1*RIGHT+1*UP) dot2 = Dot().shift(2*RIGHT+1*UP) - dot1.set_color(DARK_BLUE) - dot2.set_color(DARK_BLUE) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) dot2_c = Dot(radius = 0.05).shift(2*RIGHT+1*UP) - dot1_c.set_color(RED) - dot2_c.set_color(RED) + dot1_c.set_color(YELLOW) + dot2_c.set_color(YELLOW) self.add_transformable_mobject(dot1_c) self.add_transformable_mobject(dot2_c) p1 = TextMobject(r"$P_1$") p1.scale(0.75) - p1.set_color(DARK_BLUE) + p1.set_color(ORANGE) p1.move_to(1*RIGHT+1.5*UP) p2 = TextMobject(r"$P_2$") p2.scale(0.75) - p2.set_color(DARK_BLUE) + p2.set_color(ORANGE) p2.move_to(2*RIGHT+1.5*UP) after = TextMobject("After applying Linear Transformation") - after.set_color(RED) + after.set_color(YELLOW) after.move_to(3.5*UP+3.5*RIGHT) after.scale(0.75) dot3 = Dot().shift(3*RIGHT+0*UP) dot4 = Dot().shift(4*RIGHT+1*UP) - dot3.set_color(RED) - dot4.set_color(RED) + dot3.set_color(YELLOW) + dot4.set_color(YELLOW) p3 = TextMobject(r"$T(P_1)$") p3.scale(0.75) - p3.set_color(RED) + p3.set_color(YELLOW) p3.move_to(3*RIGHT-0.6*UP) p4 = TextMobject(r"$T(P_2)$") p4.scale(0.75) - p4.set_color(RED) + p4.set_color(YELLOW) p4.move_to(4*RIGHT+1.5*UP) self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) self.wait(3) matrix = [[1,2],[1,-1]] + dot1.set_color(GREY) + dot2.set_color(GREY) + self.play(FadeIn(dot1),FadeIn(dot2)) self.apply_matrix(matrix) - self.play(FadeOut(dot1),FadeOut(dot2)) self.play(Transform(before,after), Transform(p2,p4), Transform(p1,p3)) self.play(Transform(before,after)) self.wait(3) @@ -145,7 +147,7 @@ class ThreeDExplanation(ThreeDScene): before = TextMobject("Before Linear Transformation") self.add_fixed_in_frame_mobjects(before) - before.set_color(YELLOW) + before.set_color(ORANGE) before.move_to(3.5*UP+4*RIGHT) before.scale(0.75) @@ -158,9 +160,9 @@ class ThreeDExplanation(ThreeDScene): dot1 = Dot().shift(1*RIGHT+1*UP) dot2 = Dot().shift(2*RIGHT+1*UP) dot3 = Dot().shift(1*RIGHT+1*DOWN) - dot1.set_color(YELLOW) - dot2.set_color(YELLOW) - dot3.set_color(YELLOW) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + dot3.set_color(ORANGE) self.play(ShowCreation(before)) p1.move_to(1*RIGHT+1*UP+[0,0,0.5]) @@ -170,9 +172,9 @@ class ThreeDExplanation(ThreeDScene): dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) dot2_c = Dot(radius = 0.05).shift(0*RIGHT+2*UP) dot3_c = Dot(radius = 0.05).shift(1*RIGHT-1*UP) - dot1_c.set_color(RED) - dot2_c.set_color(RED) - dot3_c.set_color(RED) + dot1_c.set_color(YELLOW) + dot2_c.set_color(YELLOW) + dot3_c.set_color(YELLOW) axes = ThreeDAxes(x_min = -7,x_max=7,y_min=-4,y_max=4,z_min=-4,z_max=4) self.play(ShowCreation(axes)) @@ -191,7 +193,7 @@ class ThreeDExplanation(ThreeDScene): self.play(FadeOut(before)) after = TextMobject("After applying Linear Transformation") self.add_fixed_in_frame_mobjects(after) - after.set_color(RED) + after.set_color(YELLOW) after.move_to(3.5*UP+3.5*RIGHT) after.scale(0.75) @@ -223,4 +225,8 @@ class ThreeDExplanation(ThreeDScene): self.add_fixed_in_frame_mobjects(ending) self.play(FadeOut(plane)) - self.wait(9) + self.wait(3) + + self.begin_ambient_camera_rotation(rate=0.5) + self.wait(5) + self.stop_ambient_camera_rotation() -- cgit From 73582bd5f91d845437fb4a88b3a863e940d1de7e Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Mon, 6 Jul 2020 17:06:19 +0530 Subject: animation added in 4FSS --- .../The-Four-Fundamental-Subspaces/CSasImage.py | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py new file mode 100644 index 0000000..fbb3291 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py @@ -0,0 +1,168 @@ +from manimlib.imports import * + +class Column_Space(Scene): + def construct(self): + + A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \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 \\ 1 \\ 2 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 3 \\ 1 \\ 2 \end{array} \right)$",r"$ + x_{3}$",r"$\left( \begin{array}{c} 1 \\ 1 \\ 4 \\ 3 \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[5].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) + arrow2 = Arrow(start = 1.35*UP+0.5*RIGHT,end = 0.25*DOWN+0.5*RIGHT) + arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = 0.25*DOWN+2.9*RIGHT) + + Defn = TextMobject("Linear Combination of Columns of Matrix") + Defn.move_to(3*DOWN) + + self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow2), 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$(= ",r"$\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$",r")denote 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(YELLOW) + arrow3.set_color(YELLOW) + 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"Matrix the of this linear transformation is $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)) \ No newline at end of file -- cgit From a74eaef144ee85b1fd2fa0b39fcebad9fbc44190 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Mon, 6 Jul 2020 17:10:30 +0530 Subject: animation changed in 4FSS --- .../The-Four-Fundamental-Subspaces/null_space.py | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py new file mode 100644 index 0000000..dfc3cb4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py @@ -0,0 +1,91 @@ +from manimlib.imports import * +class null_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original $2D$ vector space(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a particular vector $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + o1 = TextMobject("Notice, entire set of vectors which belong to the vector") + o2 = TextMobject(r"subspace(Linear Span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$) transforms to zero") + o1.move_to(2*DOWN+2.5*RIGHT) + o2.move_to(2.75*DOWN+2.5*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait() + + self.play(FadeOut(o1), FadeOut(o2)) + + o = TextMobject(r"Hence, the vector space formed by linear span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$ is the null space of $A$") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait(2) + self.play(FadeOut(o), FadeOut(arrow), FadeOut(arrow1), FadeOut(arrow2), FadeOut(arrow3), FadeOut(arrow4), FadeOut(arrow5), FadeOut(arrow6), FadeOut(arrow7)) -- cgit From 0d8a9f7ed659c349d92bf3be92edd1eccba5f713 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Tue, 7 Jul 2020 00:38:01 +0530 Subject: Still need to make changes --- .../The-Four-Fundamental-Subspaces/null_space.py | 2 +- .../The-Four-Fundamental-Subspaces/row_space.py | 150 +++++++++++++++++++++ 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py index dfc3cb4..c686710 100644 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py @@ -5,7 +5,7 @@ class null_space(LinearTransformationScene): self.setup() self.wait() - o = TextMobject(r"This is the original $2D$ vector space(before Linear Transformation)") + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") o.move_to(DOWN) o.scale(0.75) o.add_background_rectangle() diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py new file mode 100644 index 0000000..c81d370 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py @@ -0,0 +1,150 @@ +from manimlib.imports import * +class row_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$i.e. the null space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow.set_color(YELLOW) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow1.set_color(YELLOW) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow2.set_color(YELLOW) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow3.set_color(YELLOW) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow4.set_color(YELLOW) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow5.set_color(YELLOW) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow6.set_color(YELLOW) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + arrow7.set_color(YELLOW) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$i.e. the row space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(PURPLE) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(PURPLE) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(PURPLE) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(PURPLE) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(PURPLE) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(PURPLE) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(PURPLE) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(PURPLE) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + self.add_transformable_mobject(rarrow) + self.add_transformable_mobject(rarrow1) + self.add_transformable_mobject(rarrow2) + self.add_transformable_mobject(rarrow3) + self.add_transformable_mobject(rarrow4) + self.add_transformable_mobject(rarrow5) + self.add_transformable_mobject(rarrow6) + self.add_transformable_mobject(rarrow7) + + o1 = TextMobject("Notice, entire set of vectors which belong to the null space of $A$ transforms to zero") + o2 = TextMobject(r"and entire set of vectors which belong to the row space of $A$ transforms to column space of $A$.") + o1.move_to(2.5*DOWN) + o2.move_to(3.5*DOWN) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait(3) + + self.play(FadeOut(o1), FadeOut(o2)) \ No newline at end of file -- cgit From 9c93f9fd57d3d12355e5fb854603e421965a08c1 Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Tue, 7 Jul 2020 18:47:41 +0530 Subject: semi-final 4FSS --- .../The-Four-Fundamental-Subspaces/Axb.py | 77 --------- .../The-Four-Fundamental-Subspaces/CSasImage.py | 168 ------------------- .../file10_NOT_in_lecture_note_Column_Space.py | 30 ++++ .../The-Four-Fundamental-Subspaces/file1_Axb.py | 77 +++++++++ .../file1_Column_Space.gif | Bin 1182328 -> 0 bytes .../file1_Column_Space.py | 30 ---- .../file2_CSasImage.py | 169 +++++++++++++++++++ .../file2_Row_Space.py | 145 ---------------- .../file3_solution.py | 77 +++++++++ .../file4_null_space.py | 91 ++++++++++ .../file5_Row_Space_part_1.py | 68 ++++++++ .../file6_Row_Space_part_2.py | 145 ++++++++++++++++ .../file7_Row_space_Orthogonal_Complements.py | 150 +++++++++++++++++ .../file8_Left_Null_Space.py | 26 +++ .../file9_left_null_space.py | 186 +++++++++++++++++++++ .../The-Four-Fundamental-Subspaces/null_space.py | 91 ---------- .../The-Four-Fundamental-Subspaces/row_space.py | 150 ----------------- .../The-Four-Fundamental-Subspaces/solution.py | 75 --------- 18 files changed, 1019 insertions(+), 736 deletions(-) delete mode 100755 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_NOT_in_lecture_note_Column_Space.py create mode 100755 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Axb.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py create mode 100755 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py (limited to 'FSF-2020/linear-algebra/linear-transformations') 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 deleted file mode 100755 index 95d1021..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/Axb.py +++ /dev/null @@ -1,77 +0,0 @@ -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 diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py deleted file mode 100644 index fbb3291..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/CSasImage.py +++ /dev/null @@ -1,168 +0,0 @@ -from manimlib.imports import * - -class Column_Space(Scene): - def construct(self): - - A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \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 \\ 1 \\ 2 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 3 \\ 1 \\ 2 \end{array} \right)$",r"$ + x_{3}$",r"$\left( \begin{array}{c} 1 \\ 1 \\ 4 \\ 3 \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[5].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) - arrow2 = Arrow(start = 1.35*UP+0.5*RIGHT,end = 0.25*DOWN+0.5*RIGHT) - arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = 0.25*DOWN+2.9*RIGHT) - - Defn = TextMobject("Linear Combination of Columns of Matrix") - Defn.move_to(3*DOWN) - - self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow2), 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$(= ",r"$\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$",r")denote 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(YELLOW) - arrow3.set_color(YELLOW) - 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"Matrix the of this linear transformation is $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)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_NOT_in_lecture_note_Column_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_NOT_in_lecture_note_Column_Space.py new file mode 100644 index 0000000..afe4f9a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_NOT_in_lecture_note_Column_Space.py @@ -0,0 +1,30 @@ +from manimlib.imports import * + +class Column_Space(Scene): + def construct(self): + + A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \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 \\ 1 \\ 2 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 3 \\ 1 \\ 2 \end{array} \right)$",r"$ + x_{3}$",r"$\left( \begin{array}{c} 1 \\ 1 \\ 4 \\ 3 \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[5].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) + arrow2 = Arrow(start = 1.35*UP+0.5*RIGHT,end = 0.25*DOWN+0.5*RIGHT) + arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = 0.25*DOWN+2.9*RIGHT) + + Defn = TextMobject("Linear Combination of Columns of Matrix") + Defn.move_to(3*DOWN) + + self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow2), ShowCreation(arrow3),run_time = 1) + self.wait(1) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Axb.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Axb.py new file mode 100755 index 0000000..95d1021 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_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 diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif deleted file mode 100644 index 7d8d2e1..0000000 Binary files a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif and /dev/null differ diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py deleted file mode 100644 index afe4f9a..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py +++ /dev/null @@ -1,30 +0,0 @@ -from manimlib.imports import * - -class Column_Space(Scene): - def construct(self): - - A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \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 \\ 1 \\ 2 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 3 \\ 1 \\ 2 \end{array} \right)$",r"$ + x_{3}$",r"$\left( \begin{array}{c} 1 \\ 1 \\ 4 \\ 3 \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[5].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) - arrow2 = Arrow(start = 1.35*UP+0.5*RIGHT,end = 0.25*DOWN+0.5*RIGHT) - arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = 0.25*DOWN+2.9*RIGHT) - - Defn = TextMobject("Linear Combination of Columns of Matrix") - Defn.move_to(3*DOWN) - - self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow2), ShowCreation(arrow3),run_time = 1) - self.wait(1) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py new file mode 100644 index 0000000..70547cb --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py @@ -0,0 +1,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)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py deleted file mode 100644 index b16a32a..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py +++ /dev/null @@ -1,145 +0,0 @@ -from manimlib.imports import * - -class Row_Space(Scene): - def construct(self): - - Heading = TextMobject("Row Space") - defn1 = TextMobject("Definition 1: Row Space of a matrix is the linear combination of the rows of that matrix.") - defn2 = TextMobject("Definition 2: It is a vector space generated by a linear combination of the columns of $A^{T}$.") - equivalent = TextMobject(r"Definition 1 $\equiv$ Definition 2") - - Heading.move_to(2*UP) - Heading.set_color(color = DARK_BLUE) - - defn1.move_to(UP) - defn1.scale(0.75) - - defn2.scale(0.75) - - equivalent.move_to(DOWN) - - self.play(Write(Heading)) - self.play(Write(defn1)) - self.play(Write(defn2)) - self.play(Write(equivalent)) - - self.wait(2) - self.play(FadeOut(Heading),FadeOut(defn1),FadeOut(defn2),ApplyMethod(equivalent.move_to,2*UP)) - - how = TextMobject("Let us see, How?") - how.move_to(UP) - self.play(Write(how)) - self.play(FadeOut(equivalent),FadeOut(how)) - - A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \end{array} \right)$") - A.move_to(2*UP+3*LEFT) - A[1].set_color(color = DARK_BLUE) - A.scale(0.80) - - self.play(Write(A)) - - rows = TextMobject(r"Rows of A $\rightarrow$", - r"$\left( \begin{array}{c c c} 1 & 2 & 1 \end{array} \right)$,", - r"$ \left( \begin{array}{c c c} 1 & 3 & 1 \end{array} \right)$,", - r"$\left( \begin{array}{c c c} 2 & 1 & 4 \end{array} \right)$,", - r"$ \left( \begin{array}{c c c} 3 & 2 & 3 \end{array} \right)$") - rows.scale(0.75) - rows[1:5].set_color(DARK_BLUE) - self.play(Write(rows)) - - ac_defn1 = TextMobject("According to Definition 1 : ") - ac_defn1.move_to(DOWN) - - RS_A = TextMobject(r"Row Space of $A = x_{1}$", - r"$\left( \begin{array}{c c c} 1 & 2 & 1 \end{array} \right)$", - r"$+x_{2}$", - r"$ \left( \begin{array}{c c c} 1 & 3 & 1 \end{array} \right)$", - r"$ + x_{3}$", - r"$\left( \begin{array}{c c c} 2 & 1 & 4 \end{array} \right)$", - r"$+x_{4}$", - r"$ \left( \begin{array}{c c c} 3 & 2 & 3 \end{array} \right)$") - RS_A.move_to(DOWN+DOWN) - RS_A[6].move_to(2*DOWN+DOWN) - RS_A[7].move_to(2*DOWN+2*RIGHT+DOWN) - RS_A[1].set_color(color = DARK_BLUE) - RS_A[3].set_color(color = DARK_BLUE) - RS_A[5].set_color(color = DARK_BLUE) - RS_A[7].set_color(color = DARK_BLUE) - RS_A.scale(0.75) - - self.play(FadeOut(rows[0]),Transform(rows[1],RS_A[1]),Transform(rows[2],RS_A[3]),Transform(rows[3],RS_A[5]),Transform(rows[4],RS_A[7])) - self.play(FadeIn(ac_defn1), Write(RS_A)) - self.wait(1) - - self.play(FadeOut(rows[1]), FadeOut(rows[2]), FadeOut(rows[3]), FadeOut(rows[4]), FadeOut(RS_A), FadeOut(ac_defn1)) - - A_T = TextMobject(r"$A^{T} = $",r"$\left( \begin{array}{c c c c} 1 & 1 & 2 & 3 \\ 2 & 3 & 1 & 2 \\ 1 & 1 & 4 & 3 \end{array} \right)$") - A_T.move_to(2*UP+3*RIGHT) - A_T[1].set_color(color = DARK_BLUE) - A_T.scale(0.80) - - self.play(Write(A_T)) - - change1 = TextMobject(r"Rows of $A\equiv$ Columns of $A^{T}$") - change2 = TextMobject(r"Columns of $A\equiv$ Rows of $A^{T}$") - change2.move_to(DOWN) - - change3 = TextMobject(r"Row Space of $A$ = Linear Combination of",r"Rows","of",r"A") - change3.move_to(2*DOWN) - change3[1].set_color(DARK_BLUE) - change3[3].set_color(DARK_BLUE) - - self.play(Write(change1)) - self.play(Write(change2)) - self.play(Write(change3)) - - columns = TextMobject("Columns") - columns.scale(0.6) - columns.set_color(DARK_BLUE) - columns.move_to(2*DOWN+4.1*RIGHT) - - a = TextMobject(r"$A^{T}$") - a.set_color(DARK_BLUE) - a.move_to(1.95*DOWN+5.6*RIGHT) - - self.wait(0.5) - - self.play(Transform(change3[1],columns), Transform(change3[3],a)) - - equal = TextMobject(r"= Column Space($A^{T}$)") - equal.move_to(3*DOWN+0.5*RIGHT) - - self.play(Write(equal)) - - self.play(FadeOut(A_T), FadeOut(change1), FadeOut(change2), FadeOut(change3), FadeOut(A), FadeOut(equal)) - - ac_defn1.move_to(3*UP) - RS_A.move_to(1.5*UP) - RS_A[6].move_to(UP) - RS_A[7].move_to(UP+1.5*RIGHT) - - self.play(Write(RS_A),FadeIn(ac_defn1)) - - CS_AT = TextMobject(r"Row Space of $A = x_{1}$", - r"$\left( \begin{array}{c} 1 \\ 2 \\ 1 \end{array} \right)$", - r"$+x_{2}$", - r"$ \left( \begin{array}{c} 1 \\ 3 \\ 1 \end{array} \right)$", - r"$ + x_{3}$", - r"$\left( \begin{array}{c} 2 \\ 1 \\ 4 \end{array} \right)$", - r"$+x_{4}$", - r"$ \left( \begin{array}{c} 3 \\ 2 \\ 3 \end{array} \right)$") - CS_AT.move_to(1.5*DOWN) - CS_AT[1].set_color(color = DARK_BLUE) - CS_AT[3].set_color(color = DARK_BLUE) - CS_AT[5].set_color(color = DARK_BLUE) - CS_AT[7].set_color(color = DARK_BLUE) - CS_AT.scale(0.75) - - ac_defn2 = TextMobject("According to Definition 2 : ") - equivalent = TextMobject(r"Hence, Definition 1 $\equiv$ Definition 2") - equivalent.move_to(3*DOWN) - - self.play(Write(CS_AT),FadeIn(ac_defn2)) - self.play(Write(equivalent)) - - self.wait() diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py new file mode 100644 index 0000000..eb310f3 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py @@ -0,0 +1,77 @@ +from manimlib.imports import * +class solution(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$ (before Linear Transformation)") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + A = TextMobject(r"Consider the matrix the of this linear transformation $A$ = $\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$") + A.move_to(3*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(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + arrow2 = Arrow(start = ORIGIN, end = 2*DOWN+2*LEFT) + arrow2.set_color(PURPLE) + arrow2.scale(1.2) + self.play(ShowCreation(arrow2)) + self.wait() + + o1 = TextMobject("If the ","vector b"," lies in the transformed vector space") + o2 = TextMobject("(the line) then the solution exist") + o1.move_to(2.5*DOWN+2*RIGHT) + o1[1].set_color(PURPLE) + o2.move_to(3*DOWN+2.5*RIGHT) + o1.scale(0.75) + o2.scale(0.75) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + self.play(FadeOut(o1), FadeOut(o2)) + + self.play(FadeOut(arrow2)) + + arrow1 = Arrow(start = ORIGIN, end = 2*UP+RIGHT) + arrow1.set_color(ORANGE) + arrow1.scale(1.3) + self.play(ShowCreation(arrow1)) + self.wait() + + o1 = TextMobject("If the ","vector b"," does lies in the transformed") + o2 = TextMobject("vector space then the does not solution exist") + o1.move_to(2.5*DOWN+2*RIGHT) + o1[1].set_color(ORANGE) + o2.move_to(3*DOWN+2.5*RIGHT) + o1.scale(0.75) + o2.scale(0.75) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + self.play(FadeOut(o1), FadeOut(o2)) + + self.play(FadeOut(arrow1)) + \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py new file mode 100644 index 0000000..3c52677 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py @@ -0,0 +1,91 @@ +from manimlib.imports import * +class null_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a particular vector $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + o1 = TextMobject("Notice, entire set of vectors which belongs to the vector") + o2 = TextMobject(r"subspace(Linear Span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$) transforms to zero") + o1.move_to(2*DOWN+2.5*RIGHT) + o2.move_to(2.75*DOWN+2.5*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait() + + self.play(FadeOut(o1), FadeOut(o2)) + + o = TextMobject(r"Hence, the vector space formed by linear span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$ is the null space of $A$") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait(2) + self.play(FadeOut(o), FadeOut(arrow), FadeOut(arrow1), FadeOut(arrow2), FadeOut(arrow3), FadeOut(arrow4), FadeOut(arrow5), FadeOut(arrow6), FadeOut(arrow7)) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py new file mode 100644 index 0000000..5259eb4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py @@ -0,0 +1,68 @@ +from manimlib.imports import * +class LS(Scene): + def construct(self): + text1 = TextMobject(r"Consider a matrix $A =$") + text2 = TextMobject(r"[") + text3 = TextMobject(r"$\begin{array}{c c} 1 & -2\end{array}$") + text4 = TextMobject(r"$\begin{array}{c c} 1 & -1\end{array}$") + text5 = TextMobject(r"]") + + text2.scale(2) + text5.scale(2) + + text1.set_color(DARK_BLUE) + text2.set_color(DARK_BLUE) + text3.set_color(PURPLE) + text4.set_color(YELLOW) + text5.set_color(DARK_BLUE) + + text1.move_to(3.5*LEFT+3*UP+2*RIGHT) + text2.move_to(0.75*LEFT+3*UP+2*RIGHT) + text3.move_to(3.25*UP+2*RIGHT) + text4.move_to(2.75*UP+2*RIGHT) + text5.move_to(0.75*RIGHT+3*UP+2*RIGHT) + + self.play(FadeIn(text1), FadeIn(text2), FadeIn(text3), FadeIn(text4), FadeIn(text5)) + self.wait() + + ttext1 = TextMobject(r"$A^T =$") + ttext2 = TextMobject(r"[") + ttext3 = TextMobject(r"$\begin{array}{c} 1 \\ -2\end{array}$") + ttext4 = TextMobject(r"$\begin{array}{c} 1 \\ -1\end{array}$") + ttext5 = TextMobject(r"]") + + ttext2.scale(2) + ttext5.scale(2) + + ttext1.set_color(DARK_BLUE) + ttext2.set_color(DARK_BLUE) + ttext3.set_color(PURPLE) + ttext4.set_color(YELLOW) + ttext5.set_color(DARK_BLUE) + + ttext1.move_to(2*LEFT+1.5*UP+2*RIGHT) + ttext2.move_to(1*LEFT+1.5*UP+2*RIGHT) + ttext3.move_to(0.5*LEFT+1.5*UP+2*RIGHT) + ttext4.move_to(0.5*RIGHT+1.5*UP+2*RIGHT) + ttext5.move_to(1*RIGHT+1.5*UP+2*RIGHT) + + self.play(FadeIn(ttext1), FadeIn(ttext2), FadeIn(ttext3), FadeIn(ttext4), FadeIn(ttext5)) + + rtext = TextMobject(r"Row Space of $A$ = Column Space of $A^T = a_1$",r"$\left[\begin{array}{c} 1 \\ -2\end{array}\right]$",r"$+a_2$",r"$\left[\begin{array}{c} 1 \\ -1\end{array}\right]$") + rtext[1].set_color(PURPLE) + rtext[3].set_color(YELLOW) + rtext.move_to(2*DOWN+1.5*LEFT) + rtext.scale(0.75) + + self.play(Write(rtext)) + self.wait() + + arrow1 = Arrow(start = 1.5*RIGHT+UP, end = 1.25*(DOWN+RIGHT)) + arrow2 = Arrow(start = 2.5*RIGHT+UP, end = 1.25*DOWN+3.25*RIGHT) + arrow1.scale(1.25) + arrow2.scale(1.25) + arrow1.set_color(PURPLE) + arrow2.set_color(YELLOW) + + self.play(ShowCreation(arrow1), ShowCreation(arrow2)) + self.wait(2) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.py new file mode 100644 index 0000000..b16a32a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.py @@ -0,0 +1,145 @@ +from manimlib.imports import * + +class Row_Space(Scene): + def construct(self): + + Heading = TextMobject("Row Space") + defn1 = TextMobject("Definition 1: Row Space of a matrix is the linear combination of the rows of that matrix.") + defn2 = TextMobject("Definition 2: It is a vector space generated by a linear combination of the columns of $A^{T}$.") + equivalent = TextMobject(r"Definition 1 $\equiv$ Definition 2") + + Heading.move_to(2*UP) + Heading.set_color(color = DARK_BLUE) + + defn1.move_to(UP) + defn1.scale(0.75) + + defn2.scale(0.75) + + equivalent.move_to(DOWN) + + self.play(Write(Heading)) + self.play(Write(defn1)) + self.play(Write(defn2)) + self.play(Write(equivalent)) + + self.wait(2) + self.play(FadeOut(Heading),FadeOut(defn1),FadeOut(defn2),ApplyMethod(equivalent.move_to,2*UP)) + + how = TextMobject("Let us see, How?") + how.move_to(UP) + self.play(Write(how)) + self.play(FadeOut(equivalent),FadeOut(how)) + + A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \end{array} \right)$") + A.move_to(2*UP+3*LEFT) + A[1].set_color(color = DARK_BLUE) + A.scale(0.80) + + self.play(Write(A)) + + rows = TextMobject(r"Rows of A $\rightarrow$", + r"$\left( \begin{array}{c c c} 1 & 2 & 1 \end{array} \right)$,", + r"$ \left( \begin{array}{c c c} 1 & 3 & 1 \end{array} \right)$,", + r"$\left( \begin{array}{c c c} 2 & 1 & 4 \end{array} \right)$,", + r"$ \left( \begin{array}{c c c} 3 & 2 & 3 \end{array} \right)$") + rows.scale(0.75) + rows[1:5].set_color(DARK_BLUE) + self.play(Write(rows)) + + ac_defn1 = TextMobject("According to Definition 1 : ") + ac_defn1.move_to(DOWN) + + RS_A = TextMobject(r"Row Space of $A = x_{1}$", + r"$\left( \begin{array}{c c c} 1 & 2 & 1 \end{array} \right)$", + r"$+x_{2}$", + r"$ \left( \begin{array}{c c c} 1 & 3 & 1 \end{array} \right)$", + r"$ + x_{3}$", + r"$\left( \begin{array}{c c c} 2 & 1 & 4 \end{array} \right)$", + r"$+x_{4}$", + r"$ \left( \begin{array}{c c c} 3 & 2 & 3 \end{array} \right)$") + RS_A.move_to(DOWN+DOWN) + RS_A[6].move_to(2*DOWN+DOWN) + RS_A[7].move_to(2*DOWN+2*RIGHT+DOWN) + RS_A[1].set_color(color = DARK_BLUE) + RS_A[3].set_color(color = DARK_BLUE) + RS_A[5].set_color(color = DARK_BLUE) + RS_A[7].set_color(color = DARK_BLUE) + RS_A.scale(0.75) + + self.play(FadeOut(rows[0]),Transform(rows[1],RS_A[1]),Transform(rows[2],RS_A[3]),Transform(rows[3],RS_A[5]),Transform(rows[4],RS_A[7])) + self.play(FadeIn(ac_defn1), Write(RS_A)) + self.wait(1) + + self.play(FadeOut(rows[1]), FadeOut(rows[2]), FadeOut(rows[3]), FadeOut(rows[4]), FadeOut(RS_A), FadeOut(ac_defn1)) + + A_T = TextMobject(r"$A^{T} = $",r"$\left( \begin{array}{c c c c} 1 & 1 & 2 & 3 \\ 2 & 3 & 1 & 2 \\ 1 & 1 & 4 & 3 \end{array} \right)$") + A_T.move_to(2*UP+3*RIGHT) + A_T[1].set_color(color = DARK_BLUE) + A_T.scale(0.80) + + self.play(Write(A_T)) + + change1 = TextMobject(r"Rows of $A\equiv$ Columns of $A^{T}$") + change2 = TextMobject(r"Columns of $A\equiv$ Rows of $A^{T}$") + change2.move_to(DOWN) + + change3 = TextMobject(r"Row Space of $A$ = Linear Combination of",r"Rows","of",r"A") + change3.move_to(2*DOWN) + change3[1].set_color(DARK_BLUE) + change3[3].set_color(DARK_BLUE) + + self.play(Write(change1)) + self.play(Write(change2)) + self.play(Write(change3)) + + columns = TextMobject("Columns") + columns.scale(0.6) + columns.set_color(DARK_BLUE) + columns.move_to(2*DOWN+4.1*RIGHT) + + a = TextMobject(r"$A^{T}$") + a.set_color(DARK_BLUE) + a.move_to(1.95*DOWN+5.6*RIGHT) + + self.wait(0.5) + + self.play(Transform(change3[1],columns), Transform(change3[3],a)) + + equal = TextMobject(r"= Column Space($A^{T}$)") + equal.move_to(3*DOWN+0.5*RIGHT) + + self.play(Write(equal)) + + self.play(FadeOut(A_T), FadeOut(change1), FadeOut(change2), FadeOut(change3), FadeOut(A), FadeOut(equal)) + + ac_defn1.move_to(3*UP) + RS_A.move_to(1.5*UP) + RS_A[6].move_to(UP) + RS_A[7].move_to(UP+1.5*RIGHT) + + self.play(Write(RS_A),FadeIn(ac_defn1)) + + CS_AT = TextMobject(r"Row Space of $A = x_{1}$", + r"$\left( \begin{array}{c} 1 \\ 2 \\ 1 \end{array} \right)$", + r"$+x_{2}$", + r"$ \left( \begin{array}{c} 1 \\ 3 \\ 1 \end{array} \right)$", + r"$ + x_{3}$", + r"$\left( \begin{array}{c} 2 \\ 1 \\ 4 \end{array} \right)$", + r"$+x_{4}$", + r"$ \left( \begin{array}{c} 3 \\ 2 \\ 3 \end{array} \right)$") + CS_AT.move_to(1.5*DOWN) + CS_AT[1].set_color(color = DARK_BLUE) + CS_AT[3].set_color(color = DARK_BLUE) + CS_AT[5].set_color(color = DARK_BLUE) + CS_AT[7].set_color(color = DARK_BLUE) + CS_AT.scale(0.75) + + ac_defn2 = TextMobject("According to Definition 2 : ") + equivalent = TextMobject(r"Hence, Definition 1 $\equiv$ Definition 2") + equivalent.move_to(3*DOWN) + + self.play(Write(CS_AT),FadeIn(ac_defn2)) + self.play(Write(equivalent)) + + self.wait() diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py new file mode 100644 index 0000000..c81d370 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py @@ -0,0 +1,150 @@ +from manimlib.imports import * +class row_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$i.e. the null space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow.set_color(YELLOW) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow1.set_color(YELLOW) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow2.set_color(YELLOW) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow3.set_color(YELLOW) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow4.set_color(YELLOW) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow5.set_color(YELLOW) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow6.set_color(YELLOW) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + arrow7.set_color(YELLOW) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$i.e. the row space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(PURPLE) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(PURPLE) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(PURPLE) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(PURPLE) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(PURPLE) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(PURPLE) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(PURPLE) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(PURPLE) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + self.add_transformable_mobject(rarrow) + self.add_transformable_mobject(rarrow1) + self.add_transformable_mobject(rarrow2) + self.add_transformable_mobject(rarrow3) + self.add_transformable_mobject(rarrow4) + self.add_transformable_mobject(rarrow5) + self.add_transformable_mobject(rarrow6) + self.add_transformable_mobject(rarrow7) + + o1 = TextMobject("Notice, entire set of vectors which belong to the null space of $A$ transforms to zero") + o2 = TextMobject(r"and entire set of vectors which belong to the row space of $A$ transforms to column space of $A$.") + o1.move_to(2.5*DOWN) + o2.move_to(3.5*DOWN) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait(3) + + self.play(FadeOut(o1), FadeOut(o2)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py new file mode 100755 index 0000000..fd05e75 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py @@ -0,0 +1,26 @@ +from manimlib.imports import * + +class Left_Null_Space(Scene): + def construct(self): + + A = TextMobject(r"Left Null Space of A") + A.move_to(3*UP) + defn = TextMobject(r"It is a vector space that consists of all the solution $x$ to the equation $A^{T}x=0$") + defn.move_to(2*UP) + defn.scale(0.75) + eqn1 = TextMobject(r"$A^{T}x=0 \cdots (i)$") + eqn1.move_to(UP) + self.play(Write(A), Write(defn), Write(eqn1),run_time=1) + statement = TextMobject(r"Taking transpose of eqn $(i)$") + eqn = TextMobject(r"$(A^{T}x)^{T}=0$") + eqn.move_to(DOWN) + eqn2 = TextMobject(r"$x^{T}(A^{T})^{T}=0$") + eqn2.move_to(DOWN) + eqn3 = TextMobject(r"$x^{T}A=0$") + eqn3.move_to(DOWN) + self.play(Write(statement),Write(eqn),run_time=1) + self.wait(0.5) + self.play(Transform(eqn,eqn2),run_time=1) + self.wait(0.5) + self.play(Transform(eqn,eqn3),run_time=1) + self.wait(0.5) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py new file mode 100644 index 0000000..61285be --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py @@ -0,0 +1,186 @@ +from manimlib.imports import * +class row_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$i.e. the null space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow.set_color(YELLOW) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow1.set_color(YELLOW) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow2.set_color(YELLOW) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow3.set_color(YELLOW) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow4.set_color(YELLOW) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow5.set_color(YELLOW) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow6.set_color(YELLOW) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + arrow7.set_color(YELLOW) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a vector $\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$i.e. the row space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(PURPLE) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(PURPLE) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(PURPLE) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(PURPLE) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(PURPLE) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(PURPLE) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(PURPLE) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(PURPLE) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + self.add_transformable_mobject(rarrow) + self.add_transformable_mobject(rarrow1) + self.add_transformable_mobject(rarrow2) + self.add_transformable_mobject(rarrow3) + self.add_transformable_mobject(rarrow4) + self.add_transformable_mobject(rarrow5) + self.add_transformable_mobject(rarrow6) + self.add_transformable_mobject(rarrow7) + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait(3) + + o1 = TextMobject("Consider a set of vectors which are linear span of a vector") + o2 = TextMobject(r"$\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$ which is orthogonal to column space i.e. Left Null Space") + o1.move_to(2*DOWN) + o2.move_to(2.75*DOWN) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(YELLOW) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(YELLOW) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(YELLOW) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(YELLOW) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(YELLOW) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(YELLOW) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(YELLOW) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(YELLOW) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py deleted file mode 100644 index c686710..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/null_space.py +++ /dev/null @@ -1,91 +0,0 @@ -from manimlib.imports import * -class null_space(LinearTransformationScene): - def construct(self): - - self.setup() - self.wait() - - o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") - o.move_to(DOWN) - o.scale(0.75) - o.add_background_rectangle() - self.play(Write(o)) - self.wait() - self.play(FadeOut(o)) - - o1 = TextMobject("Consider a set of vectors which are linear") - o2 = TextMobject(r"span of a particular vector $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$") - o1.move_to(2*DOWN+3*RIGHT) - o2.move_to(2.75*DOWN+3*RIGHT) - o1.scale(0.7) - o2.scale(0.7) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - - arrow = Arrow(start = ORIGIN, end = UP+RIGHT) - arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) - arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) - arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) - arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) - arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) - arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) - arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) - - arrow.scale(1.5) - arrow1.scale(1.2) - arrow2.scale(1.15) - arrow3.scale(1.1) - arrow4.scale(1.5) - arrow5.scale(1.2) - arrow6.scale(1.15) - arrow7.scale(1.1) - - self.play(ShowCreation(arrow), - ShowCreation(arrow1), - ShowCreation(arrow2), - ShowCreation(arrow3), - ShowCreation(arrow4), - ShowCreation(arrow5), - ShowCreation(arrow6), - ShowCreation(arrow7), - ) - - self.wait(2) - self.play(FadeOut(o1), FadeOut(o2)) - - self.add_transformable_mobject(arrow) - self.add_transformable_mobject(arrow1) - self.add_transformable_mobject(arrow2) - self.add_transformable_mobject(arrow3) - self.add_transformable_mobject(arrow4) - self.add_transformable_mobject(arrow5) - self.add_transformable_mobject(arrow6) - self.add_transformable_mobject(arrow7) - - o1 = TextMobject("Notice, entire set of vectors which belong to the vector") - o2 = TextMobject(r"subspace(Linear Span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$) transforms to zero") - o1.move_to(2*DOWN+2.5*RIGHT) - o2.move_to(2.75*DOWN+2.5*RIGHT) - o1.scale(0.7) - o2.scale(0.7) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - self.wait() - - matrix = [[1,-1],[1,-1]] - self.apply_matrix(matrix) - self.wait() - - self.play(FadeOut(o1), FadeOut(o2)) - - o = TextMobject(r"Hence, the vector space formed by linear span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$ is the null space of $A$") - o.move_to(DOWN) - o.scale(0.75) - o.add_background_rectangle() - self.play(Write(o)) - self.wait(2) - self.play(FadeOut(o), FadeOut(arrow), FadeOut(arrow1), FadeOut(arrow2), FadeOut(arrow3), FadeOut(arrow4), FadeOut(arrow5), FadeOut(arrow6), FadeOut(arrow7)) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py deleted file mode 100644 index c81d370..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/row_space.py +++ /dev/null @@ -1,150 +0,0 @@ -from manimlib.imports import * -class row_space(LinearTransformationScene): - def construct(self): - - self.setup() - self.wait() - - o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") - o.move_to(DOWN) - o.scale(0.75) - o.add_background_rectangle() - self.play(Write(o)) - self.wait() - self.play(FadeOut(o)) - - o1 = TextMobject("Consider a set of vectors which are linear") - o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$i.e. the null space.") - o1.move_to(2*DOWN+3*RIGHT) - o2.move_to(2.75*DOWN+3*RIGHT) - o1.scale(0.7) - o2.scale(0.7) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - - arrow = Arrow(start = ORIGIN, end = UP+RIGHT) - arrow.set_color(YELLOW) - arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) - arrow1.set_color(YELLOW) - arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) - arrow2.set_color(YELLOW) - arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) - arrow3.set_color(YELLOW) - arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) - arrow4.set_color(YELLOW) - arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) - arrow5.set_color(YELLOW) - arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) - arrow6.set_color(YELLOW) - arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) - arrow7.set_color(YELLOW) - - arrow.scale(1.5) - arrow1.scale(1.2) - arrow2.scale(1.15) - arrow3.scale(1.1) - arrow4.scale(1.5) - arrow5.scale(1.2) - arrow6.scale(1.15) - arrow7.scale(1.1) - - self.play(ShowCreation(arrow), - ShowCreation(arrow1), - ShowCreation(arrow2), - ShowCreation(arrow3), - ShowCreation(arrow4), - ShowCreation(arrow5), - ShowCreation(arrow6), - ShowCreation(arrow7), - ) - - self.wait(2) - self.play(FadeOut(o1), FadeOut(o2)) - - o1 = TextMobject("Consider a set of vectors which are linear") - o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$i.e. the row space.") - o1.move_to(2*DOWN+3*RIGHT) - o2.move_to(2.75*DOWN+3*RIGHT) - o1.scale(0.7) - o2.scale(0.7) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - - rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) - rarrow.set_color(PURPLE) - rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) - rarrow1.set_color(PURPLE) - rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) - rarrow2.set_color(PURPLE) - rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) - rarrow3.set_color(PURPLE) - rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) - rarrow4.set_color(PURPLE) - rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) - rarrow5.set_color(PURPLE) - rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) - rarrow6.set_color(PURPLE) - rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) - rarrow7.set_color(PURPLE) - - rarrow.scale(1.5) - rarrow1.scale(1.2) - rarrow2.scale(1.15) - rarrow3.scale(1.1) - rarrow4.scale(1.5) - rarrow5.scale(1.2) - rarrow6.scale(1.15) - rarrow7.scale(1.1) - - self.play(ShowCreation(rarrow), - ShowCreation(rarrow1), - ShowCreation(rarrow2), - ShowCreation(rarrow3), - ShowCreation(rarrow4), - ShowCreation(rarrow5), - ShowCreation(rarrow6), - ShowCreation(rarrow7), - ) - - self.wait(2) - self.play(FadeOut(o1), FadeOut(o2)) - - self.add_transformable_mobject(arrow) - self.add_transformable_mobject(arrow1) - self.add_transformable_mobject(arrow2) - self.add_transformable_mobject(arrow3) - self.add_transformable_mobject(arrow4) - self.add_transformable_mobject(arrow5) - self.add_transformable_mobject(arrow6) - self.add_transformable_mobject(arrow7) - - self.add_transformable_mobject(rarrow) - self.add_transformable_mobject(rarrow1) - self.add_transformable_mobject(rarrow2) - self.add_transformable_mobject(rarrow3) - self.add_transformable_mobject(rarrow4) - self.add_transformable_mobject(rarrow5) - self.add_transformable_mobject(rarrow6) - self.add_transformable_mobject(rarrow7) - - o1 = TextMobject("Notice, entire set of vectors which belong to the null space of $A$ transforms to zero") - o2 = TextMobject(r"and entire set of vectors which belong to the row space of $A$ transforms to column space of $A$.") - o1.move_to(2.5*DOWN) - o2.move_to(3.5*DOWN) - o1.scale(0.7) - o2.scale(0.7) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - self.wait() - - matrix = [[1,-1],[1,-1]] - self.apply_matrix(matrix) - self.wait(3) - - self.play(FadeOut(o1), FadeOut(o2)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py deleted file mode 100644 index fb31881..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/solution.py +++ /dev/null @@ -1,75 +0,0 @@ -from manimlib.imports import * -class solution(LinearTransformationScene): - def construct(self): - - self.setup() - self.wait() - - o = TextMobject(r"This is the original $2D$ vector space(before Linear Transformation)") - o.move_to(DOWN) - o.scale(0.75) - o.add_background_rectangle() - self.play(Write(o)) - self.wait() - self.play(FadeOut(o)) - - A = TextMobject("Let $A$ denote the matrix the of this linear transformation.") - A.move_to(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 i.e. a line ($1D$)") - o.move_to(DOWN) - o.scale(0.75) - o.add_background_rectangle() - self.play(Write(o)) - self.wait() - self.play(FadeOut(o)) - - arrow2 = Arrow(start = ORIGIN, end = 2*DOWN+2*LEFT) - arrow2.set_color(DARK_BLUE) - arrow2.scale(1.2) - self.play(ShowCreation(arrow2)) - self.wait() - - o1 = TextMobject("If the vector lies in the transformed vector space") - o2 = TextMobject("(the line) then the solution exist") - o1.move_to(2*DOWN+2*RIGHT) - o2.move_to(2.5*DOWN+2*RIGHT) - o1.scale(0.75) - o2.scale(0.75) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - self.wait() - self.play(FadeOut(o1), FadeOut(o2)) - - self.play(FadeOut(arrow2)) - - arrow1 = Arrow(start = ORIGIN, end = 2*UP+RIGHT) - arrow1.set_color(DARK_BLUE) - arrow1.scale(1.3) - self.play(ShowCreation(arrow1)) - self.wait() - - o1 = TextMobject("If the vector does lies in the transformed") - o2 = TextMobject("vector space then the does not solution exist") - o1.move_to(2*DOWN+2*RIGHT) - o2.move_to(2.5*DOWN+2*RIGHT) - o1.scale(0.75) - o2.scale(0.75) - o1.add_background_rectangle() - o2.add_background_rectangle() - self.play(Write(o1)) - self.play(Write(o2)) - self.wait() - self.play(FadeOut(o1), FadeOut(o2)) - - self.play(FadeOut(arrow1)) - \ No newline at end of file -- cgit From 4f4895fd2ff4973edbf15b2eed70513cfd96719c Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Tue, 7 Jul 2020 20:12:25 +0530 Subject: semi final commit over LT --- .../Linear-Transformations-(Linear-Maps)/file.txt | 3 - ...2_Understand_Linear_Transformations_visually.py | 193 ---------------- .../file2_before_matrix.py | 232 +++++++++++++++++++ .../file3_Uniform_Scaling.py | 91 -------- .../file3_square.py | 246 +++++++++++++++++++++ .../file4_Horizontal_Shear.py | 53 ----- .../file4_Horizontal_Shear_gif.gif | Bin 1566999 -> 0 bytes ...4_Understand_Linear_Transformations_visually.py | 193 ++++++++++++++++ .../file5_Uniform_Scaling.py | 91 ++++++++ .../file5_Vertical_Shear.py | 52 ----- .../file5_Vertical_Shear_gif.gif | Bin 1347079 -> 0 bytes .../file6_Horizontal_Shear.py | 53 +++++ .../file6_Horizontal_Shear_gif.gif | Bin 0 -> 1566999 bytes .../file6_linear_transformation.py | 27 --- .../file7_Vertical_Shear.py | 52 +++++ .../file7_Vertical_Shear_gif.gif | Bin 0 -> 1347079 bytes .../file8_linear_transformation.py | 27 +++ .../file_before_matrix.py | 232 ------------------- .../Linear-Transformations-(Linear-Maps)/square.py | 246 --------------------- 19 files changed, 894 insertions(+), 897 deletions(-) delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_Understand_Linear_Transformations_visually.py create mode 100755 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_Uniform_Scaling.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear_gif.gif create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear_gif.gif create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif delete mode 100755 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif create mode 100755 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_linear_transformation.py delete mode 100755 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt deleted file mode 100644 index cae98ce..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt +++ /dev/null @@ -1,3 +0,0 @@ -file 'text.mp4' -file 'LinearTransformation.mp4' -file 'NonLinearTransformation.mp4' diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_Understand_Linear_Transformations_visually.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_Understand_Linear_Transformations_visually.py deleted file mode 100644 index 577032d..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_Understand_Linear_Transformations_visually.py +++ /dev/null @@ -1,193 +0,0 @@ -from manimlib.imports import * - -class Rotation(GraphScene): - CONFIG = { - "x_min" : -5, - "x_max" : 5, - "y_min" : -5, - "y_max" : 5, - "graph_origin" : ORIGIN+3.5*LEFT, - "x_axis_width" : 7, - "y_axis_height" : 7 - #"x_labeled_nums" : list(range(-5,6)), - #"y_labeled_nums" : list(range(-5,6)), - } - - def construct(self): - XTD = self.x_axis_width/(self.x_max-self.x_min) - YTD = self.y_axis_height/(self.y_max-self.y_min) - - introText = TextMobject("Understanding Linear Transformations") - self.play(Write(introText)) - self.wait(1) - - introText1 = TextMobject("Visually ... ") - introText1.move_to(DOWN) - self.play(Write(introText1)) - self.wait(1) - self.play(FadeOut(introText), FadeOut(introText1)) - - Text1 = TextMobject("Let $\overrightarrow{v}$ be $2\hat{i}+3\hat{j}$") - Text2 = TextMobject("$\overrightarrow{v} = 2\hat{i}+3\hat{j}$") - - Text1.move_to(4*RIGHT+2*UP) - Text2.move_to(4*RIGHT+1*UP) - self.play(Write(Text1)) - self.wait() - self.play(Transform(Text1,Text2)) - - self.setup_axes(animate=True) - arrow_v = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*LEFT + 0.25*DOWN, end = self.graph_origin+2*XTD*RIGHT+3*YTD*UP+ 0.15*RIGHT + 0.25*UP) - self.play(ShowCreation(arrow_v)) - - Text_i = TextMobject("$\hat{i}$") - Text_i.move_to(self.graph_origin+0.5*XTD*RIGHT+0.5*YTD*DOWN) - Text_i.scale(0.75) - Text_j = TextMobject("$\hat{j}$") - Text_j.move_to(self.graph_origin+0.5*XTD*LEFT+0.5*YTD*UP) - Text_j.scale(0.75) - - arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) - arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*YTD*UP+0.25*UP) - self.play(ShowCreation(arrow_i), ShowCreation(arrow_j), Write(Text_i), Write(Text_j)) - - Text_2i = TextMobject("$2\hat{i}$") - Text_2i.move_to(self.graph_origin+1*XTD*RIGHT+1*YTD*DOWN) - Text_3j = TextMobject("$3\hat{j}$") - Text_3j.move_to(self.graph_origin+1*XTD*LEFT+1.5*YTD*UP) - - arrow_2i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+2*XTD*RIGHT+ 0.25*RIGHT) - arrow_2i.set_color(YELLOW) - arrow_3j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+3*YTD*UP+0.25*UP) - arrow_3j.set_color(RED) - self.wait(0.5) - self.play(Transform(arrow_i,arrow_2i), Transform(arrow_j,arrow_3j), Transform(Text_i,Text_2i), Transform(Text_j,Text_3j)) - self.play(ApplyMethod(arrow_j.move_to,self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) , ApplyMethod(Text_j.move_to,self.graph_origin+2.5*XTD*RIGHT+1.5*YTD*UP+ 0.15*RIGHT + 0.25*UP)) - - new_Text_v = TextMobject("$\overrightarrow{v}$") - new_Text_v.move_to(self.graph_origin+0.5*XTD*RIGHT+1.5*YTD*UP) - self.play(Write(new_Text_v)) - - new_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) - new_arrow_i.set_color(YELLOW) - new_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*YTD*UP+0.25*UP) - new_arrow_j.set_color(RED) - - new_Text_i = TextMobject("$\hat{i}$") - new_Text_i.move_to(self.graph_origin+0.5*XTD*RIGHT+0.5*YTD*DOWN) - new_Text_i.scale(0.75) - new_Text_j = TextMobject("$\hat{j}$") - new_Text_j.move_to(self.graph_origin+0.5*XTD*LEFT+0.5*YTD*UP) - new_Text_j.scale(0.75) - - self.wait(1) - - self.play(FadeOut(Text_i), - FadeOut(Text_j), - FadeOut(arrow_i), - FadeOut(arrow_j), - ShowCreation(new_arrow_i), - ShowCreation(new_arrow_j), - Write(new_Text_i), - Write(new_Text_j)) - - self.play(ApplyMethod(Text1.move_to,4*RIGHT)) - Text3 = TextMobject("Let the be a linear transformation function") - Text3.scale(0.5) - Text4 = TextMobject("$T$ which rotates the vectors by angle of $90^{\circ}$") - Text4.scale(0.5) - Text3.move_to(4*RIGHT+3*UP) - Text4.move_to(4*RIGHT+2.5*UP) - self.play(Write(Text3), Write(Text4)) - self.wait(2) - - Text6 = TextMobject(r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") - Text6.scale(0.75) - Text6.set_color(YELLOW) - Text6.move_to(self.graph_origin+1*XTD*RIGHT+1*YTD*DOWN) - Text7 = TextMobject(r"$\begin{pmatrix} 0 \\ 1 \end{pmatrix}$") - Text7.scale(0.75) - Text7.set_color(RED) - Text7.move_to(self.graph_origin+1*XTD*LEFT+1*YTD*UP) - - self.play(Transform(new_Text_i,Text6)) - self.play(Transform(new_Text_j,Text7)) - - Text5 = TextMobject(r"$\overrightarrow{v} = 2 $", r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$", r"+3", r"$\begin{pmatrix} 0 \\ 1 \end{pmatrix}$") - Text5[1].set_color(YELLOW) - Text5[3].set_color(RED) - Text5.move_to(4*RIGHT) - - self.play(Transform(Text1, Text5)) - self.wait() - - arrow_modified_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*UP, end = self.graph_origin-(1*YTD*UP+0.25*UP)) - arrow_modified_i.set_color(YELLOW) - arrow_modified_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) - arrow_modified_j.set_color(RED) - - yellow_i = TextMobject(r"$\begin{pmatrix} 0 \\ -1 \end{pmatrix}$") - yellow_i.set_color(YELLOW).scale(0.75) - yellow_i.move_to(self.graph_origin + 1*XTD*DOWN + 1*YTD*LEFT) - - red_j = TextMobject(r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") - red_j.set_color(RED).scale(0.75) - red_j.move_to(self.graph_origin + 1*XTD*UP + 1*YTD*RIGHT) - - Text8 = TextMobject(r"$\overrightarrow{v}_{transformed} = 2 $", r"$\begin{pmatrix} 0 \\ -1 \end{pmatrix}$", r"+3", r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") - Text8[1].set_color(YELLOW) - Text8[3].set_color(RED) - Text8.move_to(4*RIGHT+1.5*DOWN) - Text8.scale(0.75) - - new_Text__v = TextMobject("$\overrightarrow{v}_{transformed}$") - new_Text__v.scale(0.75) - arrow_modified_v = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT + 0.15*UP, end = self.graph_origin+2*XTD*DOWN+3*YTD*RIGHT+ 0.15*DOWN + 0.25*RIGHT) - self.play(Transform(arrow_v, arrow_modified_v), - Transform(new_arrow_i, arrow_modified_i), - Transform(new_arrow_j, arrow_modified_j), - Transform(new_Text_i,yellow_i), - Transform(new_Text_j,red_j), - FadeOut(new_Text_v), - ApplyMethod(new_Text__v.move_to,self.graph_origin+3*XTD*RIGHT+0.5*YTD*DOWN), - Write(Text8)) - - self.play(FadeOut(Text1), FadeOut(Text3), FadeOut(Text4), ApplyMethod(Text8.move_to,4*RIGHT+3*UP)) - - Text9 = TextMobject(r"$\overrightarrow{v}_{transformed} = 2 $", r"$\hat{i}_{transformed}$", r"+3", r"$\hat{j}_{transformed}$") - Text9[1].set_color(YELLOW) - Text9[3].set_color(RED) - Text9.move_to(4*RIGHT+2*UP) - Text9.scale(0.5) - - self.play(Write(Text9)) - - v_transformed = TextMobject(r"$\overrightarrow{v}_{transformed} \equiv T(\overrightarrow{v})$") - v_transformed.scale(0.75).move_to(4*RIGHT+UP) - i_transformed = TextMobject(r"$\hat{i}_{transformed} \equiv T(\hat{i})$") - i_transformed.set_color(YELLOW).scale(0.75).move_to(4*RIGHT) - j_transformed = TextMobject(r"$\hat{v}_{transformed} \equiv T(\hat{j})$") - j_transformed.set_color(RED).scale(0.75).move_to(4*RIGHT+DOWN) - - self.play(Write(v_transformed), Write(i_transformed), Write(j_transformed)) - self.wait(3) - - Text10 = TextMobject(r"$T(\overrightarrow{v}) = $", r"$\begin{pmatrix} 3 \\ -2 \end{pmatrix}$") - Text10[1].set_color(BLUE_E) - Text10.move_to(4*RIGHT+1*UP) - Text10.scale(0.75) - - self.play(Write(Text10), ApplyMethod(v_transformed.move_to,4*RIGHT+2*UP), FadeOut(i_transformed), FadeOut(j_transformed), FadeOut(Text9)) - self.wait(1) - - self.play(FadeOut(self.axes), - FadeOut(arrow_v), - FadeOut(new_arrow_i), - FadeOut(new_arrow_j), - FadeOut(new_Text_i), - FadeOut(new_Text_i), - FadeOut(new_Text_j), - FadeOut(new_Text__v), - FadeOut(Text10), - FadeOut(v_transformed), - FadeOut(Text8)) diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py new file mode 100755 index 0000000..96e456d --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py @@ -0,0 +1,232 @@ +from manimlib.imports import * + +class Linear(GraphScene): + + CONFIG = { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "x_labeled_nums": list(range(-5, 6)), + "y_labeled_nums": list(range(-5, 6)), + "x_axis_width": 7, + "y_axis_height": 7, + } + + def construct(self): + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate = True) + heading = TextMobject(r"$T(x,y) = T(x+2y,x-y)$") + heading.move_to(UP*3+LEFT*4) + heading.scale(0.7) + self.play(Write(heading)) + self.wait() + + before = TextMobject("Before Linear Transformation") + before.set_color(ORANGE) + before.move_to(3*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(self.graph_origin+1*XTD*RIGHT+1*YTD*UP) + dot2 = Dot().shift(self.graph_origin+2*XTD*RIGHT+1*YTD*UP) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + p1 = TextMobject(r"$P_1$") + p1.scale(0.75) + p1.set_color(ORANGE) + p1.move_to(self.graph_origin+1*XTD*RIGHT+1.5*YTD*UP) + p2 = TextMobject(r"$P_2$") + p2.set_color(ORANGE) + p2.scale(0.75) + p2.move_to(self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) + + after = TextMobject("After applying Linear Transformation") + after.set_color(YELLOW) + after.move_to(3*UP+4.5*RIGHT) + after.scale(0.5) + dot3 = Dot().shift(self.graph_origin+3*XTD*RIGHT+0*YTD*UP) + dot4 = Dot().shift(self.graph_origin+4*XTD*RIGHT+1*YTD*UP) + dot3.set_color(YELLOW) + dot4.set_color(YELLOW) + p3 = TextMobject(r"$T(P_1)$") + p3.scale(0.7) + p3.set_color(YELLOW) + p3.move_to(self.graph_origin+3*XTD*RIGHT-1.1*YTD*UP) + p4 = TextMobject(r"$T(P_2)$") + p4.scale(0.7) + p4.set_color(YELLOW) + p4.move_to(self.graph_origin+4*XTD*RIGHT+1.5*YTD*UP) + + self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) + self.wait(3) + self.play(Transform(before,after), Transform(dot1,dot3), Transform(dot2,dot4), Transform(p2,p4), Transform(p1,p3)) + self.wait(3) + + +class withgrid(LinearTransformationScene): + def construct(self): + + heading = TextMobject(r"Now, Imagine this happening for all the vectors") + heading.scale(0.5) + heading.move_to(UP*2.5+LEFT*4) + self.play(Write(heading)) + self.wait() + + before = TextMobject("Before Linear Transformation") + before.set_color(ORANGE) + before.move_to(3.5*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(1*RIGHT+1*UP) + dot2 = Dot().shift(2*RIGHT+1*UP) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) + dot2_c = Dot(radius = 0.05).shift(2*RIGHT+1*UP) + dot1_c.set_color(YELLOW) + dot2_c.set_color(YELLOW) + self.add_transformable_mobject(dot1_c) + self.add_transformable_mobject(dot2_c) + + p1 = TextMobject(r"$P_1$") + p1.scale(0.75) + p1.set_color(ORANGE) + p1.move_to(1*RIGHT+1.5*UP) + p2 = TextMobject(r"$P_2$") + p2.scale(0.75) + p2.set_color(ORANGE) + p2.move_to(2*RIGHT+1.5*UP) + + after = TextMobject("After applying Linear Transformation") + after.set_color(YELLOW) + after.move_to(3.5*UP+3.5*RIGHT) + after.scale(0.75) + dot3 = Dot().shift(3*RIGHT+0*UP) + dot4 = Dot().shift(4*RIGHT+1*UP) + dot3.set_color(YELLOW) + dot4.set_color(YELLOW) + p3 = TextMobject(r"$T(P_1)$") + p3.scale(0.75) + p3.set_color(YELLOW) + p3.move_to(3*RIGHT-0.6*UP) + p4 = TextMobject(r"$T(P_2)$") + p4.scale(0.75) + p4.set_color(YELLOW) + p4.move_to(4*RIGHT+1.5*UP) + + self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) + self.wait(3) + matrix = [[1,2],[1,-1]] + dot1.set_color(GREY) + dot2.set_color(GREY) + self.play(FadeIn(dot1),FadeIn(dot2)) + self.apply_matrix(matrix) + self.play(Transform(before,after), Transform(p2,p4), Transform(p1,p3)) + self.play(Transform(before,after)) + self.wait(3) + + ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+2y \\ x-y\end{array}\right]$") + ending.move_to(UP*2+LEFT*4) + self.play(Transform(heading,ending)) + self.wait() + +from manimlib.imports import * +class ThreeDExplanation(ThreeDScene): + + def construct(self): + + text = TextMobject(r"$T(x,y) = (x+y,x-y,x+2y)$") + text.scale(0.75) + text.move_to(UP*2.5+LEFT*4) + self.add_fixed_in_frame_mobjects(text) + self.play(Write(text)) + self.wait() + + before = TextMobject("Before Linear Transformation") + self.add_fixed_in_frame_mobjects(before) + before.set_color(ORANGE) + before.move_to(3.5*UP+4*RIGHT) + before.scale(0.75) + + p1 = TextMobject(r"$P_1$") + p2 = TextMobject(r"$P_2$") + p3 = TextMobject(r"$P_3$") + p1.scale(0.75) + p2.scale(0.75) + p3.scale(0.75) + dot1 = Dot().shift(1*RIGHT+1*UP) + dot2 = Dot().shift(2*RIGHT+1*UP) + dot3 = Dot().shift(1*RIGHT+1*DOWN) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + dot3.set_color(ORANGE) + self.play(ShowCreation(before)) + + p1.move_to(1*RIGHT+1*UP+[0,0,0.5]) + p2.move_to(2*RIGHT+1*UP+[0,0,0.5]) + p3.move_to(1*RIGHT-1*UP+[0,0,0.5]) + + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) + dot2_c = Dot(radius = 0.05).shift(0*RIGHT+2*UP) + dot3_c = Dot(radius = 0.05).shift(1*RIGHT-1*UP) + dot1_c.set_color(YELLOW) + dot2_c.set_color(YELLOW) + dot3_c.set_color(YELLOW) + + axes = ThreeDAxes(x_min = -7,x_max=7,y_min=-4,y_max=4,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + self.move_camera(distance = 100, phi=30*DEGREES,theta=45*DEGREES,run_time=3) + + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(1) + self.stop_ambient_camera_rotation() + + plane = NumberPlane() + self.add_fixed_orientation_mobjects(p1) + self.add_fixed_orientation_mobjects(p2) + self.add_fixed_orientation_mobjects(p3) + self.play(ShowCreation(dot1),ShowCreation(dot3),ShowCreation(dot2),ShowCreation(plane)) + + self.play(FadeOut(before)) + after = TextMobject("After applying Linear Transformation") + self.add_fixed_in_frame_mobjects(after) + after.set_color(YELLOW) + after.move_to(3.5*UP+3.5*RIGHT) + after.scale(0.75) + + self.play(FadeOut(p1),FadeOut(p2),FadeOut(p3)) + matrix = [[1,1],[1,-1],[2,1]] + self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(dot3),ApplyMethod(plane.apply_matrix,matrix),ApplyMethod(dot1_c.apply_matrix,matrix),ApplyMethod(dot3_c.apply_matrix,matrix),ApplyMethod(dot2_c.apply_matrix,matrix)) + + p4 = TextMobject(r"$T(P_1)$") + p5 = TextMobject(r"$T(P_2)$") + p6 = TextMobject(r"$T(P_3)$") + p4.scale(0.75) + p5.scale(0.75) + p6.scale(0.75) + p4.move_to(2*RIGHT+0*UP+[0,0,3.5]) + p5.move_to(2*RIGHT-2*UP+[0,0,2.5]) + p6.move_to(0*RIGHT+2*UP+[0,0,1.5]) + self.add_fixed_orientation_mobjects(p5) + self.add_fixed_orientation_mobjects(p4) + self.add_fixed_orientation_mobjects(p6) + + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(3) + self.stop_ambient_camera_rotation() + + ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+y \\ x-y \\ x+2y \end{array}\right]$") + ending.scale(0.75) + ending.move_to(-UP*2+LEFT*4) + self.play(Transform(text,ending)) + self.add_fixed_in_frame_mobjects(ending) + + self.play(FadeOut(plane)) + self.wait(3) + + self.begin_ambient_camera_rotation(rate=0.5) + self.wait(5) + self.stop_ambient_camera_rotation() diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_Uniform_Scaling.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_Uniform_Scaling.py deleted file mode 100644 index a7856a5..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_Uniform_Scaling.py +++ /dev/null @@ -1,91 +0,0 @@ -from manimlib.imports import * - -class Scaling(GraphScene): - CONFIG = { - "x_min" : -5, - "x_max" : 5, - "y_min" : -5, - "y_max" : 5, - "graph_origin" : ORIGIN+3.5*LEFT, - "x_axis_width" : 7, - "y_axis_height" : 7 - #"x_labeled_nums" : list(range(-5,6)), - #"y_labeled_nums" : list(range(-5,6)), - } - - def construct(self): - XTD = self.x_axis_width/(self.x_max-self.x_min) - YTD = self.y_axis_height/(self.y_max-self.y_min) - - introText = TextMobject("Scaling") - self.play(Write(introText)) - self.wait(1) - self.play(FadeOut(introText)) - - introText = TextMobject("Uniform Scaling") - self.play(Write(introText)) - self.wait(1) - self.play(FadeOut(introText)) - - Text1 = TextMobject("Let $\overrightarrow{v}$ be $3\hat{i}+3\hat{j}$") - Text2 = TextMobject("$\overrightarrow{v} = 3\hat{i}+3\hat{j}$") - - Text1.move_to(4*RIGHT+2*UP) - Text2.move_to(4*RIGHT+1*UP) - self.play(Write(Text1)) - self.wait() - self.play(Transform(Text1,Text2)) - - self.setup_axes(animate=True) - arrow_v = Arrow(stroke_width = 4, start = self.graph_origin + 0.15*LEFT + 0.15*DOWN, end = self.graph_origin+3*XTD*RIGHT+3*YTD*UP+ 0.15*RIGHT + 0.15*UP) - vector_v = TextMobject(r"$\vec{v}$") - vector_v.move_to(self.graph_origin + 1*XTD*RIGHT + 2*YTD*UP ) - self.play(ShowCreation(arrow_v),Write(vector_v)) - scaling_factor = TextMobject(r"Scaling Factor = $\frac{4}{3}$") - scaling_factor.scale(0.75) - scaled_vector = TextMobject(r"$T(\vec{v}) = \frac{4}{3} \left[ \begin{array} {c} 3 \\ 3 \end{array} \right] = \left[ \begin{array} {c} 4 \\ 4 \end{array} \right]$") - scaled_vector.set_color(DARK_BLUE) - scaled_vector.scale(0.75) - scaling_factor.move_to(4*RIGHT) - scaled_vector.move_to(4*RIGHT+DOWN) - self.play(Write(scaling_factor)) - self.wait() - self.play(Write(scaled_vector)) - - transformed_arrow_v = Arrow(stroke_width = 2, start = self.graph_origin + 0.15*LEFT + 0.15*DOWN, end = self.graph_origin+4*XTD*RIGHT+4*YTD*UP+ 0.15*RIGHT + 0.15*UP) - transformed_arrow_v.set_color(DARK_BLUE) - transformed_vector_v = TextMobject(r"$T(\vec{v})$") - transformed_vector_v.move_to(self.graph_origin + 4.5*XTD*RIGHT + 4.5*YTD*UP ) - transformed_vector_v.set_color(DARK_BLUE) - self.play(ShowCreation(transformed_arrow_v), Write(transformed_vector_v)) - - self.wait() - - represent_text1 = TextMobject("Representation of scaling") - represent_text2 = TextMobject("of vectors in point form") - represent_text1.move_to(4*RIGHT+3*UP) - represent_text2.move_to(4*RIGHT+2*UP) - self.play(Write(represent_text1), Write(represent_text2)) - - dot_init = Dot(self.graph_origin+3*XTD*RIGHT+3*YTD*UP) - dot_trans = Dot(self.graph_origin+4*XTD*RIGHT+4*YTD*UP) - - self.play(ApplyMethod(vector_v.move_to,self.graph_origin+2.5*XTD*RIGHT+2.5*YTD*UP), - ApplyMethod(transformed_vector_v.move_to,self.graph_origin+4.5*XTD*RIGHT+4.5*YTD*UP), - ShowCreation(dot_init), - Transform(arrow_v,dot_init), - Transform(transformed_arrow_v,dot_trans)) - - self.wait(2) - - self.play(FadeOut(dot_init), - FadeOut(arrow_v), - FadeOut(transformed_arrow_v), - FadeOut(represent_text1), - FadeOut(represent_text2), - FadeOut(self.axes), - FadeOut(scaling_factor), - FadeOut(scaled_vector), - FadeOut(transformed_vector_v), - FadeOut(vector_v), - FadeOut(Text1)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py new file mode 100644 index 0000000..e828de4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py @@ -0,0 +1,246 @@ +from manimlib.imports import * + +class Linear(GraphScene): + CONFIG = { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "x_labeled_nums": list(range(-5, 6)), + "y_labeled_nums": list(range(-5, 6)), + "x_axis_width": 7, + "y_axis_height": 7, + } + def construct(self): + + text = TextMobject("T(x,y) = T(x+y,y)") + text.scale(0.75) + text.set_color(PURPLE) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate = True) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3+3*RIGHT) + + a = TextMobject("(1,1)") + b = TextMobject("(3,1)") + c = TextMobject("(3,2)") + d = TextMobject("(1,2)") + a.scale(0.5) + b.scale(0.5) + c.scale(0.5) + d.scale(0.5) + a.move_to(self.graph_origin+0.6*UP+0.6*RIGHT) + b.move_to(self.graph_origin+0.6*UP+3.4*RIGHT) + c.move_to(self.graph_origin+2.4*UP+3.4*RIGHT) + d.move_to(self.graph_origin+2.6*UP+0.6*RIGHT) + + square = Polygon(self.graph_origin+UP+RIGHT,self.graph_origin+UP+3*RIGHT,self.graph_origin+2*UP+3*RIGHT,self.graph_origin+2*UP+RIGHT) + + self.play(Write(text1), Write(a), Write(b), Write(c), Write(d), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1), FadeOut(a), FadeOut(b), FadeOut(c), FadeOut(d), ApplyMethod(square.apply_matrix,[[1,1],[0,1]])) + + a = TextMobject("(2,1)") + b = TextMobject("(4,1)") + c = TextMobject("(3,2)") + d = TextMobject("(5,2)") + a.scale(0.5) + b.scale(0.5) + c.scale(0.5) + d.scale(0.5) + a.move_to(self.graph_origin+0.6*UP+1.6*RIGHT) + b.move_to(self.graph_origin+0.6*UP+4.4*RIGHT) + d.move_to(self.graph_origin+2.4*UP+5.4*RIGHT) + c.move_to(self.graph_origin+2.4*UP+2.6*RIGHT) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3+3*RIGHT) + + self.play(Write(text1), Write(a), Write(b), Write(c), Write(d)) + + self.wait(2) + +class grid(LinearTransformationScene): + def construct(self): + + text = TextMobject("Now, consider all the vectors.") + text.scale(0.75) + text.set_color(PURPLE) + text.move_to(2.5*UP+3*LEFT) + self.play(Write(text)) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) + square.set_color(YELLOW) + + self.play(Write(text1), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1)) + self.add_transformable_mobject(square) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + matrix = [[1,1],[0,1]] + + self.apply_matrix(matrix) + self.play(Write(text1)) + + self.wait() + +class grid2(LinearTransformationScene): + CONFIG = { + "include_background_plane": True, + "include_foreground_plane": False, + "show_coordinates": True, + "show_basis_vectors": True, + "basis_vector_stroke_width": 3, + "i_hat_color": X_COLOR, + "j_hat_color": Y_COLOR, + "leave_ghost_vectors": True, + } + + def construct(self): + + text = TextMobject("Now, let us focus only on the standard basis") + text.scale(0.7) + text.set_color(PURPLE) + text.move_to(2.5*UP+3.5*LEFT) + self.play(Write(text)) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) + square.set_color(YELLOW) + + self.play(Write(text1), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1)) + self.add_transformable_mobject(square) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + matrix = [[1,1],[0,1]] + + self.apply_matrix(matrix) + self.play(Write(text1)) + + self.play(FadeOut(square), FadeOut(text1)) + + cor_x = TextMobject("(1,0)") + cor_y = TextMobject("(1,1)") + cor_x.scale(0.65) + cor_y.scale(0.65) + cor_y.move_to(1.25*RIGHT+1.5*UP) + cor_x.move_to(0.75*RIGHT-0.5*UP) + cor_x.set_color(GREEN) + cor_y.set_color(RED) + + x_cor = TextMobject(r"$\left[\begin{array}{c} 1\\0\end{array}\right]$") + x_cor.set_color(GREEN) + x_cor.scale(0.5) + y_cor = TextMobject(r"$\left[\begin{array}{c} 1\\1\end{array}\right]$") + x_cor.move_to(0.75*RIGHT-0.5*UP) + y_cor.move_to(1.25*RIGHT+1.5*UP) + y_cor.set_color(RED) + y_cor.scale(0.5) + + text1 = TextMobject(r"$T(\left[\begin{array}{c} x\\y \end{array}\right]) = $",r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") + text1.scale(0.7) + text1.set_color(PURPLE) + text1.move_to(1.5*UP+3*LEFT) + + text = TextMobject(r"$T(x,y) = (x+y,y)$") + text.scale(0.6) + text.set_color(PURPLE) + text.move_to(1.5*UP+3*LEFT) + + self.play(FadeIn(text),FadeIn(cor_x), FadeIn(cor_y)) + self.wait() + + self.play(Transform(text,text1), Transform(cor_x,x_cor), Transform(cor_y,y_cor)) + + text3 = TextMobject(r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") + text3.scale(0.7) + text3.set_color(PURPLE) + text3.move_to(1.5*DOWN+5*LEFT) + + equal = TextMobject("=") + equal.move_to(1.5*DOWN+3.5*LEFT) + + text3 = TextMobject("[") + text4 = TextMobject(r"$\begin{array}{c} (1)x\\(0)x \end{array}$") + text5 = TextMobject(r"$\begin{array}{c} + \\ + \end{array}$") + text6 = TextMobject(r"$\begin{array}{c} (1)y\\(1)y \end{array}$") + text7 = TextMobject("]") + text3.scale(2) + text4.scale(0.7) + text5.scale(0.7) + text6.scale(0.7) + text7.scale(2) + text4.set_color(GREEN) + text5.set_color(PURPLE) + text6.set_color(RED) + text3.move_to(1.5*DOWN+3*LEFT) + text4.move_to(1.5*DOWN+2.5*LEFT) + text5.move_to(1.5*DOWN+2*LEFT) + text6.move_to(1.5*DOWN+1.5*LEFT) + text7.move_to(1.5*DOWN+1*LEFT) + + text1[1].scale(1.2) + self.play(FadeOut(text1[0]), ApplyMethod(text1[1].move_to,1.5*DOWN+5*LEFT), FadeIn(text3), FadeIn(equal), FadeIn(text4), FadeIn(text5), FadeIn(text6), FadeIn(text7)) + + self.wait() + self.play(FadeOut(text1[1])) + + self.play(ApplyMethod(text3.move_to,1.5*DOWN+6*LEFT), + ApplyMethod(text4.move_to,1.5*DOWN+5.5*LEFT), + ApplyMethod(text5.move_to,1.5*DOWN+5*LEFT), + ApplyMethod(text6.move_to,1.5*DOWN+4.5*LEFT), + ApplyMethod(text7.move_to,1.5*DOWN+4*LEFT)) + + text10 = TextMobject("[") + text11 = TextMobject(r"$\begin{array}{c} 1\\0 \end{array}$") + text13 = TextMobject(r"$\begin{array}{c} 1\\1 \end{array}$") + text14 = TextMobject("]") + text10.scale(2) + text11.scale(0.7) + text13.scale(0.7) + text14.scale(2) + text11.set_color(GREEN) + text13.set_color(RED) + text10.move_to(1.5*DOWN+3*LEFT) + text11.move_to(1.5*DOWN+2.75*LEFT) + text13.move_to(1.5*DOWN+2.25*LEFT) + text14.move_to(1.5*DOWN+2*LEFT) + + self.play(FadeIn(text10), Transform(x_cor,text11), Transform(y_cor,text13), FadeIn(text14)) + + text15 = TextMobject(r"$\left[\begin{array}{c} x\\y \end{array}\right]$") + text15.scale(0.7) + text15.set_color(PURPLE) + text15.move_to(1.5*DOWN+1.5*LEFT) + + self.play(FadeIn(text15)) + self.play(FadeOut(text3), FadeOut(text4), FadeOut(text5), FadeOut(text7), FadeOut(text6)) + + text1[0].scale(1.2) + self.play(ApplyMethod(text1[0].move_to,1.5*DOWN+4.5*LEFT), FadeOut(equal)) + self.wait(2) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear.py deleted file mode 100644 index 91f098e..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear.py +++ /dev/null @@ -1,53 +0,0 @@ -from manimlib.imports import * - -class Hori_Shear(GraphScene): - CONFIG = { - "x_min" : -5, - "x_max" : 5, - "y_min" : -5, - "y_max" : 5, - "graph_origin" : ORIGIN+3.5*LEFT, - "x_axis_width" : 7, - "y_axis_height" : 7 - #"x_labeled_nums" : list(range(-5,6)), - #"y_labeled_nums" : list(range(-5,6)), - } - - def construct(self): - XTD = self.x_axis_width/(self.x_max-self.x_min) - YTD = self.y_axis_height/(self.y_max-self.y_min) - - Text1 = TextMobject("Before"," Horizontal") - Text1[0].set_color(YELLOW) - Text2 = TextMobject("Shear Transformation") - - Text1.move_to(4*RIGHT+2*UP) - Text2.move_to(4*RIGHT+1*UP) - - self.setup_axes(animate=False) - arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) - arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+0.25*UP) - arrow_i.set_color(YELLOW) - arrow_j.set_color(YELLOW) - - square = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+2*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*YTD*UP) - square.set_color(DARK_BLUE) - self.play(ShowCreation(square), Write(Text1), Write(Text2), ShowCreation(arrow_i), ShowCreation(arrow_j)) - self.wait(1) - - Text3 = TextMobject("After"," Horizontal") - Text3[0].set_color(RED) - Text4 = TextMobject("Shear Transformation") - - Text3.move_to(4*RIGHT+2*UP) - Text4.move_to(4*RIGHT+1*UP) - - trans_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) - trans_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*DOWN + 0.15*LEFT, end = self.graph_origin+1*XTD*UP+1*YTD*RIGHT+0.25*UP+0.25*RIGHT) - trans_arrow_i.set_color(RED) - trans_arrow_j.set_color(RED) - - rhombus = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+4*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*XTD*RIGHT+2*YTD*UP) - square.set_color(DARK_BLUE) - self.play(Transform(arrow_i,trans_arrow_i), Transform(arrow_j,trans_arrow_j), Transform(square,rhombus), Transform(Text1,Text3), Transform(Text2,Text4)) - self.wait(1) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear_gif.gif deleted file mode 100644 index 9bef1b6..0000000 Binary files a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear_gif.gif and /dev/null differ diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py new file mode 100644 index 0000000..577032d --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py @@ -0,0 +1,193 @@ +from manimlib.imports import * + +class Rotation(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + def construct(self): + XTD = self.x_axis_width/(self.x_max-self.x_min) + YTD = self.y_axis_height/(self.y_max-self.y_min) + + introText = TextMobject("Understanding Linear Transformations") + self.play(Write(introText)) + self.wait(1) + + introText1 = TextMobject("Visually ... ") + introText1.move_to(DOWN) + self.play(Write(introText1)) + self.wait(1) + self.play(FadeOut(introText), FadeOut(introText1)) + + Text1 = TextMobject("Let $\overrightarrow{v}$ be $2\hat{i}+3\hat{j}$") + Text2 = TextMobject("$\overrightarrow{v} = 2\hat{i}+3\hat{j}$") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + self.play(Write(Text1)) + self.wait() + self.play(Transform(Text1,Text2)) + + self.setup_axes(animate=True) + arrow_v = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*LEFT + 0.25*DOWN, end = self.graph_origin+2*XTD*RIGHT+3*YTD*UP+ 0.15*RIGHT + 0.25*UP) + self.play(ShowCreation(arrow_v)) + + Text_i = TextMobject("$\hat{i}$") + Text_i.move_to(self.graph_origin+0.5*XTD*RIGHT+0.5*YTD*DOWN) + Text_i.scale(0.75) + Text_j = TextMobject("$\hat{j}$") + Text_j.move_to(self.graph_origin+0.5*XTD*LEFT+0.5*YTD*UP) + Text_j.scale(0.75) + + arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*YTD*UP+0.25*UP) + self.play(ShowCreation(arrow_i), ShowCreation(arrow_j), Write(Text_i), Write(Text_j)) + + Text_2i = TextMobject("$2\hat{i}$") + Text_2i.move_to(self.graph_origin+1*XTD*RIGHT+1*YTD*DOWN) + Text_3j = TextMobject("$3\hat{j}$") + Text_3j.move_to(self.graph_origin+1*XTD*LEFT+1.5*YTD*UP) + + arrow_2i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+2*XTD*RIGHT+ 0.25*RIGHT) + arrow_2i.set_color(YELLOW) + arrow_3j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+3*YTD*UP+0.25*UP) + arrow_3j.set_color(RED) + self.wait(0.5) + self.play(Transform(arrow_i,arrow_2i), Transform(arrow_j,arrow_3j), Transform(Text_i,Text_2i), Transform(Text_j,Text_3j)) + self.play(ApplyMethod(arrow_j.move_to,self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) , ApplyMethod(Text_j.move_to,self.graph_origin+2.5*XTD*RIGHT+1.5*YTD*UP+ 0.15*RIGHT + 0.25*UP)) + + new_Text_v = TextMobject("$\overrightarrow{v}$") + new_Text_v.move_to(self.graph_origin+0.5*XTD*RIGHT+1.5*YTD*UP) + self.play(Write(new_Text_v)) + + new_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + new_arrow_i.set_color(YELLOW) + new_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*YTD*UP+0.25*UP) + new_arrow_j.set_color(RED) + + new_Text_i = TextMobject("$\hat{i}$") + new_Text_i.move_to(self.graph_origin+0.5*XTD*RIGHT+0.5*YTD*DOWN) + new_Text_i.scale(0.75) + new_Text_j = TextMobject("$\hat{j}$") + new_Text_j.move_to(self.graph_origin+0.5*XTD*LEFT+0.5*YTD*UP) + new_Text_j.scale(0.75) + + self.wait(1) + + self.play(FadeOut(Text_i), + FadeOut(Text_j), + FadeOut(arrow_i), + FadeOut(arrow_j), + ShowCreation(new_arrow_i), + ShowCreation(new_arrow_j), + Write(new_Text_i), + Write(new_Text_j)) + + self.play(ApplyMethod(Text1.move_to,4*RIGHT)) + Text3 = TextMobject("Let the be a linear transformation function") + Text3.scale(0.5) + Text4 = TextMobject("$T$ which rotates the vectors by angle of $90^{\circ}$") + Text4.scale(0.5) + Text3.move_to(4*RIGHT+3*UP) + Text4.move_to(4*RIGHT+2.5*UP) + self.play(Write(Text3), Write(Text4)) + self.wait(2) + + Text6 = TextMobject(r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") + Text6.scale(0.75) + Text6.set_color(YELLOW) + Text6.move_to(self.graph_origin+1*XTD*RIGHT+1*YTD*DOWN) + Text7 = TextMobject(r"$\begin{pmatrix} 0 \\ 1 \end{pmatrix}$") + Text7.scale(0.75) + Text7.set_color(RED) + Text7.move_to(self.graph_origin+1*XTD*LEFT+1*YTD*UP) + + self.play(Transform(new_Text_i,Text6)) + self.play(Transform(new_Text_j,Text7)) + + Text5 = TextMobject(r"$\overrightarrow{v} = 2 $", r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$", r"+3", r"$\begin{pmatrix} 0 \\ 1 \end{pmatrix}$") + Text5[1].set_color(YELLOW) + Text5[3].set_color(RED) + Text5.move_to(4*RIGHT) + + self.play(Transform(Text1, Text5)) + self.wait() + + arrow_modified_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*UP, end = self.graph_origin-(1*YTD*UP+0.25*UP)) + arrow_modified_i.set_color(YELLOW) + arrow_modified_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_modified_j.set_color(RED) + + yellow_i = TextMobject(r"$\begin{pmatrix} 0 \\ -1 \end{pmatrix}$") + yellow_i.set_color(YELLOW).scale(0.75) + yellow_i.move_to(self.graph_origin + 1*XTD*DOWN + 1*YTD*LEFT) + + red_j = TextMobject(r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") + red_j.set_color(RED).scale(0.75) + red_j.move_to(self.graph_origin + 1*XTD*UP + 1*YTD*RIGHT) + + Text8 = TextMobject(r"$\overrightarrow{v}_{transformed} = 2 $", r"$\begin{pmatrix} 0 \\ -1 \end{pmatrix}$", r"+3", r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") + Text8[1].set_color(YELLOW) + Text8[3].set_color(RED) + Text8.move_to(4*RIGHT+1.5*DOWN) + Text8.scale(0.75) + + new_Text__v = TextMobject("$\overrightarrow{v}_{transformed}$") + new_Text__v.scale(0.75) + arrow_modified_v = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT + 0.15*UP, end = self.graph_origin+2*XTD*DOWN+3*YTD*RIGHT+ 0.15*DOWN + 0.25*RIGHT) + self.play(Transform(arrow_v, arrow_modified_v), + Transform(new_arrow_i, arrow_modified_i), + Transform(new_arrow_j, arrow_modified_j), + Transform(new_Text_i,yellow_i), + Transform(new_Text_j,red_j), + FadeOut(new_Text_v), + ApplyMethod(new_Text__v.move_to,self.graph_origin+3*XTD*RIGHT+0.5*YTD*DOWN), + Write(Text8)) + + self.play(FadeOut(Text1), FadeOut(Text3), FadeOut(Text4), ApplyMethod(Text8.move_to,4*RIGHT+3*UP)) + + Text9 = TextMobject(r"$\overrightarrow{v}_{transformed} = 2 $", r"$\hat{i}_{transformed}$", r"+3", r"$\hat{j}_{transformed}$") + Text9[1].set_color(YELLOW) + Text9[3].set_color(RED) + Text9.move_to(4*RIGHT+2*UP) + Text9.scale(0.5) + + self.play(Write(Text9)) + + v_transformed = TextMobject(r"$\overrightarrow{v}_{transformed} \equiv T(\overrightarrow{v})$") + v_transformed.scale(0.75).move_to(4*RIGHT+UP) + i_transformed = TextMobject(r"$\hat{i}_{transformed} \equiv T(\hat{i})$") + i_transformed.set_color(YELLOW).scale(0.75).move_to(4*RIGHT) + j_transformed = TextMobject(r"$\hat{v}_{transformed} \equiv T(\hat{j})$") + j_transformed.set_color(RED).scale(0.75).move_to(4*RIGHT+DOWN) + + self.play(Write(v_transformed), Write(i_transformed), Write(j_transformed)) + self.wait(3) + + Text10 = TextMobject(r"$T(\overrightarrow{v}) = $", r"$\begin{pmatrix} 3 \\ -2 \end{pmatrix}$") + Text10[1].set_color(BLUE_E) + Text10.move_to(4*RIGHT+1*UP) + Text10.scale(0.75) + + self.play(Write(Text10), ApplyMethod(v_transformed.move_to,4*RIGHT+2*UP), FadeOut(i_transformed), FadeOut(j_transformed), FadeOut(Text9)) + self.wait(1) + + self.play(FadeOut(self.axes), + FadeOut(arrow_v), + FadeOut(new_arrow_i), + FadeOut(new_arrow_j), + FadeOut(new_Text_i), + FadeOut(new_Text_i), + FadeOut(new_Text_j), + FadeOut(new_Text__v), + FadeOut(Text10), + FadeOut(v_transformed), + FadeOut(Text8)) diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py new file mode 100644 index 0000000..a7856a5 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py @@ -0,0 +1,91 @@ +from manimlib.imports import * + +class Scaling(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + def construct(self): + XTD = self.x_axis_width/(self.x_max-self.x_min) + YTD = self.y_axis_height/(self.y_max-self.y_min) + + introText = TextMobject("Scaling") + self.play(Write(introText)) + self.wait(1) + self.play(FadeOut(introText)) + + introText = TextMobject("Uniform Scaling") + self.play(Write(introText)) + self.wait(1) + self.play(FadeOut(introText)) + + Text1 = TextMobject("Let $\overrightarrow{v}$ be $3\hat{i}+3\hat{j}$") + Text2 = TextMobject("$\overrightarrow{v} = 3\hat{i}+3\hat{j}$") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + self.play(Write(Text1)) + self.wait() + self.play(Transform(Text1,Text2)) + + self.setup_axes(animate=True) + arrow_v = Arrow(stroke_width = 4, start = self.graph_origin + 0.15*LEFT + 0.15*DOWN, end = self.graph_origin+3*XTD*RIGHT+3*YTD*UP+ 0.15*RIGHT + 0.15*UP) + vector_v = TextMobject(r"$\vec{v}$") + vector_v.move_to(self.graph_origin + 1*XTD*RIGHT + 2*YTD*UP ) + self.play(ShowCreation(arrow_v),Write(vector_v)) + scaling_factor = TextMobject(r"Scaling Factor = $\frac{4}{3}$") + scaling_factor.scale(0.75) + scaled_vector = TextMobject(r"$T(\vec{v}) = \frac{4}{3} \left[ \begin{array} {c} 3 \\ 3 \end{array} \right] = \left[ \begin{array} {c} 4 \\ 4 \end{array} \right]$") + scaled_vector.set_color(DARK_BLUE) + scaled_vector.scale(0.75) + scaling_factor.move_to(4*RIGHT) + scaled_vector.move_to(4*RIGHT+DOWN) + self.play(Write(scaling_factor)) + self.wait() + self.play(Write(scaled_vector)) + + transformed_arrow_v = Arrow(stroke_width = 2, start = self.graph_origin + 0.15*LEFT + 0.15*DOWN, end = self.graph_origin+4*XTD*RIGHT+4*YTD*UP+ 0.15*RIGHT + 0.15*UP) + transformed_arrow_v.set_color(DARK_BLUE) + transformed_vector_v = TextMobject(r"$T(\vec{v})$") + transformed_vector_v.move_to(self.graph_origin + 4.5*XTD*RIGHT + 4.5*YTD*UP ) + transformed_vector_v.set_color(DARK_BLUE) + self.play(ShowCreation(transformed_arrow_v), Write(transformed_vector_v)) + + self.wait() + + represent_text1 = TextMobject("Representation of scaling") + represent_text2 = TextMobject("of vectors in point form") + represent_text1.move_to(4*RIGHT+3*UP) + represent_text2.move_to(4*RIGHT+2*UP) + self.play(Write(represent_text1), Write(represent_text2)) + + dot_init = Dot(self.graph_origin+3*XTD*RIGHT+3*YTD*UP) + dot_trans = Dot(self.graph_origin+4*XTD*RIGHT+4*YTD*UP) + + self.play(ApplyMethod(vector_v.move_to,self.graph_origin+2.5*XTD*RIGHT+2.5*YTD*UP), + ApplyMethod(transformed_vector_v.move_to,self.graph_origin+4.5*XTD*RIGHT+4.5*YTD*UP), + ShowCreation(dot_init), + Transform(arrow_v,dot_init), + Transform(transformed_arrow_v,dot_trans)) + + self.wait(2) + + self.play(FadeOut(dot_init), + FadeOut(arrow_v), + FadeOut(transformed_arrow_v), + FadeOut(represent_text1), + FadeOut(represent_text2), + FadeOut(self.axes), + FadeOut(scaling_factor), + FadeOut(scaled_vector), + FadeOut(transformed_vector_v), + FadeOut(vector_v), + FadeOut(Text1)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear.py deleted file mode 100644 index 718e4e0..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear.py +++ /dev/null @@ -1,52 +0,0 @@ -from manimlib.imports import * - -class Ver_Shear(GraphScene): - CONFIG = { - "x_min" : -5, - "x_max" : 5, - "y_min" : -5, - "y_max" : 5, - "graph_origin" : ORIGIN+3.5*LEFT, - "x_axis_width" : 7, - "y_axis_height" : 7 - #"x_labeled_nums" : list(range(-5,6)), - #"y_labeled_nums" : list(range(-5,6)), - } - - def construct(self): - XTD = self.x_axis_width/(self.x_max-self.x_min) - YTD = self.y_axis_height/(self.y_max-self.y_min) - - Text1 = TextMobject("Before"," Vertical") - Text1[0].set_color(YELLOW) - Text2 = TextMobject("Shear Transformation") - - Text1.move_to(4*RIGHT+2*UP) - Text2.move_to(4*RIGHT+1*UP) - - self.setup_axes(animate=False) - arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) - arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+0.25*UP) - arrow_i.set_color(YELLOW) - arrow_j.set_color(YELLOW) - - square = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+2*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*YTD*UP) - square.set_color(DARK_BLUE) - self.play(ShowCreation(square), Write(Text1), Write(Text2), ShowCreation(arrow_i), ShowCreation(arrow_j)) - self.wait(1) - - Text3 = TextMobject("After"," Vertical") - Text3[0].set_color(RED) - Text4 = TextMobject("Shear Transformation") - - Text3.move_to(4*RIGHT+2*UP) - Text4.move_to(4*RIGHT+1*UP) - - trans_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*DOWN + 0.15*LEFT, end = self.graph_origin+1*XTD*UP+1*YTD*RIGHT+0.25*UP+0.25*RIGHT) - trans_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+ 0.25*UP) - trans_arrow_i.set_color(RED) - trans_arrow_j.set_color(RED) - - rhombus = Polygon(self.graph_origin,self.graph_origin+2*XTD*UP, self.graph_origin+2*XTD*RIGHT+4*YTD*UP, self.graph_origin+2*XTD*RIGHT+2*YTD*UP) - self.play(Transform(arrow_i,trans_arrow_i), Transform(arrow_j,trans_arrow_j), FadeOut(square), ShowCreation(rhombus), Transform(Text1,Text3), Transform(Text2,Text4)) - self.wait(1) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear_gif.gif deleted file mode 100644 index 7ca323f..0000000 Binary files a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear_gif.gif and /dev/null differ diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py new file mode 100644 index 0000000..91f098e --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py @@ -0,0 +1,53 @@ +from manimlib.imports import * + +class Hori_Shear(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + def construct(self): + XTD = self.x_axis_width/(self.x_max-self.x_min) + YTD = self.y_axis_height/(self.y_max-self.y_min) + + Text1 = TextMobject("Before"," Horizontal") + Text1[0].set_color(YELLOW) + Text2 = TextMobject("Shear Transformation") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + + self.setup_axes(animate=False) + arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+0.25*UP) + arrow_i.set_color(YELLOW) + arrow_j.set_color(YELLOW) + + square = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+2*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*YTD*UP) + square.set_color(DARK_BLUE) + self.play(ShowCreation(square), Write(Text1), Write(Text2), ShowCreation(arrow_i), ShowCreation(arrow_j)) + self.wait(1) + + Text3 = TextMobject("After"," Horizontal") + Text3[0].set_color(RED) + Text4 = TextMobject("Shear Transformation") + + Text3.move_to(4*RIGHT+2*UP) + Text4.move_to(4*RIGHT+1*UP) + + trans_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + trans_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*DOWN + 0.15*LEFT, end = self.graph_origin+1*XTD*UP+1*YTD*RIGHT+0.25*UP+0.25*RIGHT) + trans_arrow_i.set_color(RED) + trans_arrow_j.set_color(RED) + + rhombus = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+4*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*XTD*RIGHT+2*YTD*UP) + square.set_color(DARK_BLUE) + self.play(Transform(arrow_i,trans_arrow_i), Transform(arrow_j,trans_arrow_j), Transform(square,rhombus), Transform(Text1,Text3), Transform(Text2,Text4)) + self.wait(1) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif new file mode 100644 index 0000000..9bef1b6 Binary files /dev/null and b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif differ diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py deleted file mode 100755 index 01a0cef..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py +++ /dev/null @@ -1,27 +0,0 @@ -from manimlib.imports import * -class LinearTrans(LinearTransformationScene,MovingCameraScene): - CONFIG = { - "basis_vector_stroke_width": 1, - "leave_ghost_vectors": True, - } - - def setup(self): - LinearTransformationScene.setup(self) - MovingCameraScene.setup(self) - - def construct(self): - self.setup() - self.camera_frame.save_state() - self.play(self.camera_frame.set_width, 7) - matrix = [[0.866,-0.5],[0.5,0.866]] - self.apply_matrix(matrix) - arc1 = Arc(radius = 0.25,angle=TAU/12) - arc2 = Arc(radius = 0.25,angle=TAU/12,start_angle=TAU/4) - text1 = TextMobject(r"$\theta$") - text1.scale(0.5) - text1.move_to(0.5*UP+0.125*LEFT) - text2 = TextMobject(r"$\theta$") - text2.scale(0.5) - text2.move_to(0.5*RIGHT+0.125*UP) - self.play(ShowCreation(arc1),ShowCreation(arc2),Write(text1),Write(text2),run_time=1) - self.wait() diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py new file mode 100644 index 0000000..718e4e0 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py @@ -0,0 +1,52 @@ +from manimlib.imports import * + +class Ver_Shear(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + def construct(self): + XTD = self.x_axis_width/(self.x_max-self.x_min) + YTD = self.y_axis_height/(self.y_max-self.y_min) + + Text1 = TextMobject("Before"," Vertical") + Text1[0].set_color(YELLOW) + Text2 = TextMobject("Shear Transformation") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + + self.setup_axes(animate=False) + arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+0.25*UP) + arrow_i.set_color(YELLOW) + arrow_j.set_color(YELLOW) + + square = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+2*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*YTD*UP) + square.set_color(DARK_BLUE) + self.play(ShowCreation(square), Write(Text1), Write(Text2), ShowCreation(arrow_i), ShowCreation(arrow_j)) + self.wait(1) + + Text3 = TextMobject("After"," Vertical") + Text3[0].set_color(RED) + Text4 = TextMobject("Shear Transformation") + + Text3.move_to(4*RIGHT+2*UP) + Text4.move_to(4*RIGHT+1*UP) + + trans_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*DOWN + 0.15*LEFT, end = self.graph_origin+1*XTD*UP+1*YTD*RIGHT+0.25*UP+0.25*RIGHT) + trans_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+ 0.25*UP) + trans_arrow_i.set_color(RED) + trans_arrow_j.set_color(RED) + + rhombus = Polygon(self.graph_origin,self.graph_origin+2*XTD*UP, self.graph_origin+2*XTD*RIGHT+4*YTD*UP, self.graph_origin+2*XTD*RIGHT+2*YTD*UP) + self.play(Transform(arrow_i,trans_arrow_i), Transform(arrow_j,trans_arrow_j), FadeOut(square), ShowCreation(rhombus), Transform(Text1,Text3), Transform(Text2,Text4)) + self.wait(1) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif new file mode 100644 index 0000000..7ca323f Binary files /dev/null and b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif differ diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_linear_transformation.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_linear_transformation.py new file mode 100755 index 0000000..01a0cef --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_linear_transformation.py @@ -0,0 +1,27 @@ +from manimlib.imports import * +class LinearTrans(LinearTransformationScene,MovingCameraScene): + CONFIG = { + "basis_vector_stroke_width": 1, + "leave_ghost_vectors": True, + } + + def setup(self): + LinearTransformationScene.setup(self) + MovingCameraScene.setup(self) + + def construct(self): + self.setup() + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 7) + matrix = [[0.866,-0.5],[0.5,0.866]] + self.apply_matrix(matrix) + arc1 = Arc(radius = 0.25,angle=TAU/12) + arc2 = Arc(radius = 0.25,angle=TAU/12,start_angle=TAU/4) + text1 = TextMobject(r"$\theta$") + text1.scale(0.5) + text1.move_to(0.5*UP+0.125*LEFT) + text2 = TextMobject(r"$\theta$") + text2.scale(0.5) + text2.move_to(0.5*RIGHT+0.125*UP) + self.play(ShowCreation(arc1),ShowCreation(arc2),Write(text1),Write(text2),run_time=1) + self.wait() diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py deleted file mode 100755 index 96e456d..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file_before_matrix.py +++ /dev/null @@ -1,232 +0,0 @@ -from manimlib.imports import * - -class Linear(GraphScene): - - CONFIG = { - "x_min": -5, - "x_max": 5, - "y_min": -5, - "y_max": 5, - "graph_origin": ORIGIN, - "x_labeled_nums": list(range(-5, 6)), - "y_labeled_nums": list(range(-5, 6)), - "x_axis_width": 7, - "y_axis_height": 7, - } - - def construct(self): - - XTD = self.x_axis_width/(self.x_max- self.x_min) - YTD = self.y_axis_height/(self.y_max- self.y_min) - - self.setup_axes(animate = True) - heading = TextMobject(r"$T(x,y) = T(x+2y,x-y)$") - heading.move_to(UP*3+LEFT*4) - heading.scale(0.7) - self.play(Write(heading)) - self.wait() - - before = TextMobject("Before Linear Transformation") - before.set_color(ORANGE) - before.move_to(3*UP+4*RIGHT) - before.scale(0.75) - dot1 = Dot().shift(self.graph_origin+1*XTD*RIGHT+1*YTD*UP) - dot2 = Dot().shift(self.graph_origin+2*XTD*RIGHT+1*YTD*UP) - dot1.set_color(ORANGE) - dot2.set_color(ORANGE) - p1 = TextMobject(r"$P_1$") - p1.scale(0.75) - p1.set_color(ORANGE) - p1.move_to(self.graph_origin+1*XTD*RIGHT+1.5*YTD*UP) - p2 = TextMobject(r"$P_2$") - p2.set_color(ORANGE) - p2.scale(0.75) - p2.move_to(self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) - - after = TextMobject("After applying Linear Transformation") - after.set_color(YELLOW) - after.move_to(3*UP+4.5*RIGHT) - after.scale(0.5) - dot3 = Dot().shift(self.graph_origin+3*XTD*RIGHT+0*YTD*UP) - dot4 = Dot().shift(self.graph_origin+4*XTD*RIGHT+1*YTD*UP) - dot3.set_color(YELLOW) - dot4.set_color(YELLOW) - p3 = TextMobject(r"$T(P_1)$") - p3.scale(0.7) - p3.set_color(YELLOW) - p3.move_to(self.graph_origin+3*XTD*RIGHT-1.1*YTD*UP) - p4 = TextMobject(r"$T(P_2)$") - p4.scale(0.7) - p4.set_color(YELLOW) - p4.move_to(self.graph_origin+4*XTD*RIGHT+1.5*YTD*UP) - - self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) - self.wait(3) - self.play(Transform(before,after), Transform(dot1,dot3), Transform(dot2,dot4), Transform(p2,p4), Transform(p1,p3)) - self.wait(3) - - -class withgrid(LinearTransformationScene): - def construct(self): - - heading = TextMobject(r"Now, Imagine this happening for all the vectors") - heading.scale(0.5) - heading.move_to(UP*2.5+LEFT*4) - self.play(Write(heading)) - self.wait() - - before = TextMobject("Before Linear Transformation") - before.set_color(ORANGE) - before.move_to(3.5*UP+4*RIGHT) - before.scale(0.75) - dot1 = Dot().shift(1*RIGHT+1*UP) - dot2 = Dot().shift(2*RIGHT+1*UP) - dot1.set_color(ORANGE) - dot2.set_color(ORANGE) - - dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) - dot2_c = Dot(radius = 0.05).shift(2*RIGHT+1*UP) - dot1_c.set_color(YELLOW) - dot2_c.set_color(YELLOW) - self.add_transformable_mobject(dot1_c) - self.add_transformable_mobject(dot2_c) - - p1 = TextMobject(r"$P_1$") - p1.scale(0.75) - p1.set_color(ORANGE) - p1.move_to(1*RIGHT+1.5*UP) - p2 = TextMobject(r"$P_2$") - p2.scale(0.75) - p2.set_color(ORANGE) - p2.move_to(2*RIGHT+1.5*UP) - - after = TextMobject("After applying Linear Transformation") - after.set_color(YELLOW) - after.move_to(3.5*UP+3.5*RIGHT) - after.scale(0.75) - dot3 = Dot().shift(3*RIGHT+0*UP) - dot4 = Dot().shift(4*RIGHT+1*UP) - dot3.set_color(YELLOW) - dot4.set_color(YELLOW) - p3 = TextMobject(r"$T(P_1)$") - p3.scale(0.75) - p3.set_color(YELLOW) - p3.move_to(3*RIGHT-0.6*UP) - p4 = TextMobject(r"$T(P_2)$") - p4.scale(0.75) - p4.set_color(YELLOW) - p4.move_to(4*RIGHT+1.5*UP) - - self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) - self.wait(3) - matrix = [[1,2],[1,-1]] - dot1.set_color(GREY) - dot2.set_color(GREY) - self.play(FadeIn(dot1),FadeIn(dot2)) - self.apply_matrix(matrix) - self.play(Transform(before,after), Transform(p2,p4), Transform(p1,p3)) - self.play(Transform(before,after)) - self.wait(3) - - ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+2y \\ x-y\end{array}\right]$") - ending.move_to(UP*2+LEFT*4) - self.play(Transform(heading,ending)) - self.wait() - -from manimlib.imports import * -class ThreeDExplanation(ThreeDScene): - - def construct(self): - - text = TextMobject(r"$T(x,y) = (x+y,x-y,x+2y)$") - text.scale(0.75) - text.move_to(UP*2.5+LEFT*4) - self.add_fixed_in_frame_mobjects(text) - self.play(Write(text)) - self.wait() - - before = TextMobject("Before Linear Transformation") - self.add_fixed_in_frame_mobjects(before) - before.set_color(ORANGE) - before.move_to(3.5*UP+4*RIGHT) - before.scale(0.75) - - p1 = TextMobject(r"$P_1$") - p2 = TextMobject(r"$P_2$") - p3 = TextMobject(r"$P_3$") - p1.scale(0.75) - p2.scale(0.75) - p3.scale(0.75) - dot1 = Dot().shift(1*RIGHT+1*UP) - dot2 = Dot().shift(2*RIGHT+1*UP) - dot3 = Dot().shift(1*RIGHT+1*DOWN) - dot1.set_color(ORANGE) - dot2.set_color(ORANGE) - dot3.set_color(ORANGE) - self.play(ShowCreation(before)) - - p1.move_to(1*RIGHT+1*UP+[0,0,0.5]) - p2.move_to(2*RIGHT+1*UP+[0,0,0.5]) - p3.move_to(1*RIGHT-1*UP+[0,0,0.5]) - - dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) - dot2_c = Dot(radius = 0.05).shift(0*RIGHT+2*UP) - dot3_c = Dot(radius = 0.05).shift(1*RIGHT-1*UP) - dot1_c.set_color(YELLOW) - dot2_c.set_color(YELLOW) - dot3_c.set_color(YELLOW) - - axes = ThreeDAxes(x_min = -7,x_max=7,y_min=-4,y_max=4,z_min=-4,z_max=4) - self.play(ShowCreation(axes)) - self.move_camera(distance = 100, phi=30*DEGREES,theta=45*DEGREES,run_time=3) - - self.begin_ambient_camera_rotation(rate=0.3) - self.wait(1) - self.stop_ambient_camera_rotation() - - plane = NumberPlane() - self.add_fixed_orientation_mobjects(p1) - self.add_fixed_orientation_mobjects(p2) - self.add_fixed_orientation_mobjects(p3) - self.play(ShowCreation(dot1),ShowCreation(dot3),ShowCreation(dot2),ShowCreation(plane)) - - self.play(FadeOut(before)) - after = TextMobject("After applying Linear Transformation") - self.add_fixed_in_frame_mobjects(after) - after.set_color(YELLOW) - after.move_to(3.5*UP+3.5*RIGHT) - after.scale(0.75) - - self.play(FadeOut(p1),FadeOut(p2),FadeOut(p3)) - matrix = [[1,1],[1,-1],[2,1]] - self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(dot3),ApplyMethod(plane.apply_matrix,matrix),ApplyMethod(dot1_c.apply_matrix,matrix),ApplyMethod(dot3_c.apply_matrix,matrix),ApplyMethod(dot2_c.apply_matrix,matrix)) - - p4 = TextMobject(r"$T(P_1)$") - p5 = TextMobject(r"$T(P_2)$") - p6 = TextMobject(r"$T(P_3)$") - p4.scale(0.75) - p5.scale(0.75) - p6.scale(0.75) - p4.move_to(2*RIGHT+0*UP+[0,0,3.5]) - p5.move_to(2*RIGHT-2*UP+[0,0,2.5]) - p6.move_to(0*RIGHT+2*UP+[0,0,1.5]) - self.add_fixed_orientation_mobjects(p5) - self.add_fixed_orientation_mobjects(p4) - self.add_fixed_orientation_mobjects(p6) - - self.begin_ambient_camera_rotation(rate=0.3) - self.wait(3) - self.stop_ambient_camera_rotation() - - ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+y \\ x-y \\ x+2y \end{array}\right]$") - ending.scale(0.75) - ending.move_to(-UP*2+LEFT*4) - self.play(Transform(text,ending)) - self.add_fixed_in_frame_mobjects(ending) - - self.play(FadeOut(plane)) - self.wait(3) - - self.begin_ambient_camera_rotation(rate=0.5) - self.wait(5) - self.stop_ambient_camera_rotation() diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py deleted file mode 100644 index e828de4..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/square.py +++ /dev/null @@ -1,246 +0,0 @@ -from manimlib.imports import * - -class Linear(GraphScene): - CONFIG = { - "x_min": -5, - "x_max": 5, - "y_min": -5, - "y_max": 5, - "graph_origin": ORIGIN, - "x_labeled_nums": list(range(-5, 6)), - "y_labeled_nums": list(range(-5, 6)), - "x_axis_width": 7, - "y_axis_height": 7, - } - def construct(self): - - text = TextMobject("T(x,y) = T(x+y,y)") - text.scale(0.75) - text.set_color(PURPLE) - text.move_to(3*UP+5*LEFT) - self.play(Write(text)) - - XTD = self.x_axis_width/(self.x_max- self.x_min) - YTD = self.y_axis_height/(self.y_max- self.y_min) - - self.setup_axes(animate = True) - - text1 = TextMobject("Before Linear Transformation") - text1.scale(0.6) - text1.move_to(UP*3+3*RIGHT) - - a = TextMobject("(1,1)") - b = TextMobject("(3,1)") - c = TextMobject("(3,2)") - d = TextMobject("(1,2)") - a.scale(0.5) - b.scale(0.5) - c.scale(0.5) - d.scale(0.5) - a.move_to(self.graph_origin+0.6*UP+0.6*RIGHT) - b.move_to(self.graph_origin+0.6*UP+3.4*RIGHT) - c.move_to(self.graph_origin+2.4*UP+3.4*RIGHT) - d.move_to(self.graph_origin+2.6*UP+0.6*RIGHT) - - square = Polygon(self.graph_origin+UP+RIGHT,self.graph_origin+UP+3*RIGHT,self.graph_origin+2*UP+3*RIGHT,self.graph_origin+2*UP+RIGHT) - - self.play(Write(text1), Write(a), Write(b), Write(c), Write(d), ShowCreation(square)) - self.wait(2) - self.play(FadeOut(text1), FadeOut(a), FadeOut(b), FadeOut(c), FadeOut(d), ApplyMethod(square.apply_matrix,[[1,1],[0,1]])) - - a = TextMobject("(2,1)") - b = TextMobject("(4,1)") - c = TextMobject("(3,2)") - d = TextMobject("(5,2)") - a.scale(0.5) - b.scale(0.5) - c.scale(0.5) - d.scale(0.5) - a.move_to(self.graph_origin+0.6*UP+1.6*RIGHT) - b.move_to(self.graph_origin+0.6*UP+4.4*RIGHT) - d.move_to(self.graph_origin+2.4*UP+5.4*RIGHT) - c.move_to(self.graph_origin+2.4*UP+2.6*RIGHT) - - text1 = TextMobject("After Linear Transformation") - text1.scale(0.6) - text1.move_to(UP*3+3*RIGHT) - - self.play(Write(text1), Write(a), Write(b), Write(c), Write(d)) - - self.wait(2) - -class grid(LinearTransformationScene): - def construct(self): - - text = TextMobject("Now, consider all the vectors.") - text.scale(0.75) - text.set_color(PURPLE) - text.move_to(2.5*UP+3*LEFT) - self.play(Write(text)) - - text1 = TextMobject("Before Linear Transformation") - text1.scale(0.6) - text1.move_to(UP*3.5+3.5*RIGHT) - - square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) - square.set_color(YELLOW) - - self.play(Write(text1), ShowCreation(square)) - self.wait(2) - self.play(FadeOut(text1)) - self.add_transformable_mobject(square) - - text1 = TextMobject("After Linear Transformation") - text1.scale(0.6) - text1.move_to(UP*3.5+3.5*RIGHT) - - matrix = [[1,1],[0,1]] - - self.apply_matrix(matrix) - self.play(Write(text1)) - - self.wait() - -class grid2(LinearTransformationScene): - CONFIG = { - "include_background_plane": True, - "include_foreground_plane": False, - "show_coordinates": True, - "show_basis_vectors": True, - "basis_vector_stroke_width": 3, - "i_hat_color": X_COLOR, - "j_hat_color": Y_COLOR, - "leave_ghost_vectors": True, - } - - def construct(self): - - text = TextMobject("Now, let us focus only on the standard basis") - text.scale(0.7) - text.set_color(PURPLE) - text.move_to(2.5*UP+3.5*LEFT) - self.play(Write(text)) - - text1 = TextMobject("Before Linear Transformation") - text1.scale(0.6) - text1.move_to(UP*3.5+3.5*RIGHT) - - square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) - square.set_color(YELLOW) - - self.play(Write(text1), ShowCreation(square)) - self.wait(2) - self.play(FadeOut(text1)) - self.add_transformable_mobject(square) - - text1 = TextMobject("After Linear Transformation") - text1.scale(0.6) - text1.move_to(UP*3.5+3.5*RIGHT) - - matrix = [[1,1],[0,1]] - - self.apply_matrix(matrix) - self.play(Write(text1)) - - self.play(FadeOut(square), FadeOut(text1)) - - cor_x = TextMobject("(1,0)") - cor_y = TextMobject("(1,1)") - cor_x.scale(0.65) - cor_y.scale(0.65) - cor_y.move_to(1.25*RIGHT+1.5*UP) - cor_x.move_to(0.75*RIGHT-0.5*UP) - cor_x.set_color(GREEN) - cor_y.set_color(RED) - - x_cor = TextMobject(r"$\left[\begin{array}{c} 1\\0\end{array}\right]$") - x_cor.set_color(GREEN) - x_cor.scale(0.5) - y_cor = TextMobject(r"$\left[\begin{array}{c} 1\\1\end{array}\right]$") - x_cor.move_to(0.75*RIGHT-0.5*UP) - y_cor.move_to(1.25*RIGHT+1.5*UP) - y_cor.set_color(RED) - y_cor.scale(0.5) - - text1 = TextMobject(r"$T(\left[\begin{array}{c} x\\y \end{array}\right]) = $",r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") - text1.scale(0.7) - text1.set_color(PURPLE) - text1.move_to(1.5*UP+3*LEFT) - - text = TextMobject(r"$T(x,y) = (x+y,y)$") - text.scale(0.6) - text.set_color(PURPLE) - text.move_to(1.5*UP+3*LEFT) - - self.play(FadeIn(text),FadeIn(cor_x), FadeIn(cor_y)) - self.wait() - - self.play(Transform(text,text1), Transform(cor_x,x_cor), Transform(cor_y,y_cor)) - - text3 = TextMobject(r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") - text3.scale(0.7) - text3.set_color(PURPLE) - text3.move_to(1.5*DOWN+5*LEFT) - - equal = TextMobject("=") - equal.move_to(1.5*DOWN+3.5*LEFT) - - text3 = TextMobject("[") - text4 = TextMobject(r"$\begin{array}{c} (1)x\\(0)x \end{array}$") - text5 = TextMobject(r"$\begin{array}{c} + \\ + \end{array}$") - text6 = TextMobject(r"$\begin{array}{c} (1)y\\(1)y \end{array}$") - text7 = TextMobject("]") - text3.scale(2) - text4.scale(0.7) - text5.scale(0.7) - text6.scale(0.7) - text7.scale(2) - text4.set_color(GREEN) - text5.set_color(PURPLE) - text6.set_color(RED) - text3.move_to(1.5*DOWN+3*LEFT) - text4.move_to(1.5*DOWN+2.5*LEFT) - text5.move_to(1.5*DOWN+2*LEFT) - text6.move_to(1.5*DOWN+1.5*LEFT) - text7.move_to(1.5*DOWN+1*LEFT) - - text1[1].scale(1.2) - self.play(FadeOut(text1[0]), ApplyMethod(text1[1].move_to,1.5*DOWN+5*LEFT), FadeIn(text3), FadeIn(equal), FadeIn(text4), FadeIn(text5), FadeIn(text6), FadeIn(text7)) - - self.wait() - self.play(FadeOut(text1[1])) - - self.play(ApplyMethod(text3.move_to,1.5*DOWN+6*LEFT), - ApplyMethod(text4.move_to,1.5*DOWN+5.5*LEFT), - ApplyMethod(text5.move_to,1.5*DOWN+5*LEFT), - ApplyMethod(text6.move_to,1.5*DOWN+4.5*LEFT), - ApplyMethod(text7.move_to,1.5*DOWN+4*LEFT)) - - text10 = TextMobject("[") - text11 = TextMobject(r"$\begin{array}{c} 1\\0 \end{array}$") - text13 = TextMobject(r"$\begin{array}{c} 1\\1 \end{array}$") - text14 = TextMobject("]") - text10.scale(2) - text11.scale(0.7) - text13.scale(0.7) - text14.scale(2) - text11.set_color(GREEN) - text13.set_color(RED) - text10.move_to(1.5*DOWN+3*LEFT) - text11.move_to(1.5*DOWN+2.75*LEFT) - text13.move_to(1.5*DOWN+2.25*LEFT) - text14.move_to(1.5*DOWN+2*LEFT) - - self.play(FadeIn(text10), Transform(x_cor,text11), Transform(y_cor,text13), FadeIn(text14)) - - text15 = TextMobject(r"$\left[\begin{array}{c} x\\y \end{array}\right]$") - text15.scale(0.7) - text15.set_color(PURPLE) - text15.move_to(1.5*DOWN+1.5*LEFT) - - self.play(FadeIn(text15)) - self.play(FadeOut(text3), FadeOut(text4), FadeOut(text5), FadeOut(text7), FadeOut(text6)) - - text1[0].scale(1.2) - self.play(ApplyMethod(text1[0].move_to,1.5*DOWN+4.5*LEFT), FadeOut(equal)) - self.wait(2) \ No newline at end of file -- cgit From 90cc46c2527f7798b5e9e442da56c1358322e2bf Mon Sep 17 00:00:00 2001 From: Archit Sangal Date: Tue, 7 Jul 2020 20:17:17 +0530 Subject: semi final round complete --- .../file1_introduction.py | 33 ++ .../file1_projections.py | 79 ----- .../file2_orthonormal.py | 333 --------------------- .../file2_projections.py | 79 +++++ .../file3_Non_Standard_Basis.py | 51 ---- .../file3_orthonormal.py | 333 +++++++++++++++++++++ .../file4_Non_Standard_Basis.py | 51 ++++ .../file_introduction.py | 33 -- 8 files changed, 496 insertions(+), 496 deletions(-) create mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_introduction.py delete mode 100755 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py create mode 100755 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_projections.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_orthonormal.py create mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file4_Non_Standard_Basis.py delete mode 100644 FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py (limited to 'FSF-2020/linear-algebra/linear-transformations') diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_introduction.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_introduction.py new file mode 100644 index 0000000..ccd23c9 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_introduction.py @@ -0,0 +1,33 @@ +from manimlib.imports import * + +class Orthonormal(Scene): + def construct(self): + Centre = DOWN + arrow_1 = Arrow(start = Centre+ORIGIN,end = Centre+1.414*(UP+RIGHT)) + arrow_2 = Arrow(start = Centre+ORIGIN,end = Centre+2*UP) + arrow_1.scale(1.35) + arrow_2.scale(1.35) + text = TextMobject("This is a set of linearly independent vectors") + text.scale(0.75) + text.move_to(3*UP+3*LEFT) + text.set_color(PURPLE_E) + arrow_1.set_color(PURPLE_E) + arrow_2.set_color(PURPLE_E) + self.play(Write(text)) + self.play(ShowCreation(arrow_1), ShowCreation(arrow_2)) + self.wait(2) + text1 = TextMobject("After we apply Gram-Schmidt Orthogonalization Process to set of linearly independent vectors") + text1.scale(0.6) + text1.move_to(3*UP+2*LEFT) + text1.set_color(GREEN) + arrow_a = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+RIGHT)) + arrow_a.set_color(GREEN) + arrow_a.scale(2) + self.play(Transform(text,text1)) + self.wait(2) + self.play(Transform(arrow_1,arrow_a)) + arrow_b = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+LEFT)) + arrow_b.set_color(GREEN) + arrow_b.scale(2) + self.play(Transform(arrow_2,arrow_b)) + self.wait(2) \ No newline at end of file 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 deleted file mode 100755 index dd4b8d4..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file1_projections.py +++ /dev/null @@ -1,79 +0,0 @@ -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"Consider 2 linearly independent vectors $a$ and $b$") - text.set_color(DARK_BLUE) - text.scale(0.6) - text.move_to(3*YTD*UP+5*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(3*UP+4*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)) \ 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 deleted file mode 100644 index af51fc6..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_orthonormal.py +++ /dev/null @@ -1,333 +0,0 @@ -from manimlib.imports import * - -class Algo(ThreeDScene): - def construct(self): - - axes = ThreeDAxes(x_min = -5,x_max=5,y_min=-3,y_max=3,z_min=-4,z_max=4) - self.play(ShowCreation(axes)) - - text = TextMobject(r"This is the vector $\beta_1(=\left[\begin{array}{c} 4\\0\\0 \end{array}\right])$") - text.set_color(GREEN) - text.scale(0.6) - text.move_to(3*UP+5*LEFT) - self.play(Write(text)) - - arrow_a = Arrow(start = ORIGIN, end = 4*RIGHT) - arrow_a.set_color(GREEN) - arrow_a.scale(1.15) - self.play(ShowCreation(arrow_a)) - - text_a = TextMobject(r"$\beta_1$") - text_a.move_to(0.4*DOWN+3*RIGHT) - text_a.set_color(GREEN) - text_a.scale(0.75) - self.play(Write(text_a)) - self.wait() - self.play(FadeOut(text)) - - text = TextMobject(r"Normalize $\beta_1$ to get $\alpha_1$") - text.set_color(DARK_BLUE) - text.scale(0.75) - text.move_to(3*UP+5*LEFT) - self.play(Write(text)) - - alpha_1 = Arrow(start = ORIGIN,end = RIGHT) - alpha_1.scale(1.9) - alpha_1.set_color(DARK_BLUE) - text_alpha_1 = TextMobject(r"$\alpha_1$") - text_alpha_1.move_to(0.4*DOWN+RIGHT) - text_alpha_1.set_color(DARK_BLUE) - text_alpha_1.scale(0.75) - self.play(Transform(text_a,text_alpha_1), Transform(arrow_a,alpha_1)) - self.wait() - self.play(FadeOut(text)) - - text = TextMobject(r"Consider another vector $\beta_2(=\left[\begin{array}{c} 2\\2\\0 \end{array}\right])$") - text1 = TextMobject(r"which is linearly independent to $\beta_1$") - text.set_color(GREEN) - text1.set_color(GREEN) - text.scale(0.6) - text1.scale(0.6) - text.move_to(3*UP+4*LEFT) - text1.move_to(2*UP+4*LEFT) - self.play(Write(text)) - self.play(Write(text1)) - - arrow_b = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) - arrow_b.scale(1.2) - arrow_b.set_color(GREEN) - text_b = TextMobject(r"$\beta_2$") - text_b.move_to(1.5*UP+RIGHT) - text_b.set_color(GREEN) - text_b.scale(0.75) - - self.play(ShowCreation(arrow_b), Write(text_b)) - self.wait() - - arrow_b_copy = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) - arrow_b_copy.scale(1.2) - - arrow_p = Arrow(start = ORIGIN, end = 2*RIGHT) - arrow_p.scale(1.35) - 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), FadeOut(text1), Transform(arrow_b_copy,arrow_p), FadeOut(text_a), FadeOut(text_b)) - text = TextMobject(r"$p$ is the projection of $\beta_2$ on $\alpha_1$") - text.set_color(GOLD_E) - text.move_to(3*UP+4*LEFT) - text.scale(0.8) - self.play(Write(text),Write(text_p)) - self.wait() - - self.play(FadeIn(text_b)) - - arrow_o = Arrow(start = 2*RIGHT, end = 2*UP+2*RIGHT) - arrow_o.scale(1.35) - arrow_o.set_color(PURPLE_E) - - text_o = TextMobject(r"$\beta_2-p$") - text_o.move_to(UP+2.7*RIGHT) - text_o.scale(0.75) - text_o.set_color(PURPLE_E) - - self.play(ShowCreation(arrow_o)) - self.play(FadeOut(text),Write(text_o)) - - text = TextMobject(r"$\beta_2-p$ is orthogonal to p") - text1 = TextMobject(r"(and hence orthogonal to $\alpha_1$ also)") - text.set_color(PURPLE_E) - text1.set_color(PURPLE_E) - text.scale(0.7) - text1.scale(0.7) - text.move_to(3*UP+4*LEFT) - text1.move_to(2.5*UP+4*LEFT) - self.play(Write(text)) - self.play(Write(text1)) - self.wait(2) - - self.play(FadeOut(text_p), FadeIn(arrow_a), FadeOut(text), FadeOut(text1), FadeOut(arrow_b_copy), FadeOut(arrow_p), FadeOut(text_b), FadeOut(arrow_b)) - self.play(ApplyMethod(arrow_o.move_to,UP), ApplyMethod(text_o.move_to,RIGHT+UP)) - - text = TextMobject(r"Now, Normalize $\beta_2-p$") - text.set_color(DARK_BLUE) - text.scale(0.6) - text.move_to(3*UP+4*LEFT) - self.play(Write(text)) - - alpha_2 = Arrow(start = ORIGIN,end = UP) - alpha_2.scale(1.9) - alpha_2.set_color(DARK_BLUE) - text_alpha_2 = TextMobject(r"$\alpha_2$") - text_alpha_2.move_to(0.4*LEFT+UP) - text_alpha_2.set_color(DARK_BLUE) - text_alpha_2.scale(0.75) - self.play(Transform(text_o,text_alpha_2), Transform(arrow_o,alpha_2), FadeIn(text_a)) - self.wait() - self.play(FadeOut(text),FadeOut(text_a),FadeOut(text_o)) - - self.add(axes) - ############################################################################# - axis = TextMobject(r"$\alpha_1$",r"$\alpha_2$",r"$\alpha_3$",r"$\beta_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$") - axis.scale(0.5) - axis[0].move_to(0.5*RIGHT+[0,0,-0.5]) - axis[1].move_to(0.5*UP+[0,0,-0.5]) - axis[2].move_to(np.array([0,0,0.5])) - axis[3].move_to(np.array([1,1,1.5])) - self.add_fixed_orientation_mobjects(axis[0]) - self.add_fixed_orientation_mobjects(axis[1]) - ############################################################################# - - text = TextMobject(r"These are the same two orthonormal vectors $\alpha_{1}$ and $\alpha_{2}$") - text.scale(0.6) - text.set_color(DARK_BLUE) - self.add_fixed_in_frame_mobjects(text) - text.move_to(3*(DOWN+RIGHT)) - self.play(Write(text)) - - 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), FadeOut(arrow_a), FadeOut(arrow_o)) - 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"Now, we have a vector $\beta_3(=\left[\begin{array}{c} 2\\2\\2 \end{array}\right])$") - text.set_color(GOLD_E) - text.scale(0.7) - self.add_fixed_in_frame_mobjects(text) - self.add_fixed_orientation_mobjects(axis[3]) - 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.6) - text.set_color(GOLD_E) - 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.set_color(GREEN_E) - text.scale(0.6) - 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), FadeOut(axis[3]), - 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(PURPLE_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(PURPLE_E) - last_a_tip.set_color(PURPLE_E) - - self.wait() - text = TextMobject(r"Take projection on $\alpha_2$") - text.scale(0.6) - text.set_color(GOLD_E) - 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.set_color(PURPLE_E) - text.scale(0.6) - self.add_fixed_in_frame_mobjects(text) - text.move_to(3*DOWN+3.5*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(PURPLE_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(PURPLE_E) - ltip3.set_color(PURPLE_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"Normalize, the vector") - text1 = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$ + projection of $\beta_3$ on $\alpha_2$") - text.set_color(PURPLE_E) - text1.set_color(PURPLE_E) - text.scale(0.6) - text1.scale(0.6) - self.add_fixed_in_frame_mobjects(text) - self.add_fixed_in_frame_mobjects(text1) - text.move_to(3*DOWN+3*RIGHT) - text1.move_to(3.5*DOWN+3*RIGHT) - self.play(Write(text)) - self.play(Write(text1)) - - 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.add_fixed_orientation_mobjects(axis[2]) - - self.wait() - self.play(FadeOut(text),FadeOut(text1)) - - text = TextMobject(r"These are the three orthonormal vectors $\alpha_1, \alpha_2, \alpha_3$") - text.set_color(DARK_BLUE) - self.add_fixed_in_frame_mobjects(text) - text.scale(0.6) - text.move_to(3*DOWN+3.5*RIGHT) - self.play(Write(text)) - - self.wait(3) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_projections.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_projections.py new file mode 100755 index 0000000..dd4b8d4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file2_projections.py @@ -0,0 +1,79 @@ +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"Consider 2 linearly independent vectors $a$ and $b$") + text.set_color(DARK_BLUE) + text.scale(0.6) + text.move_to(3*YTD*UP+5*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(3*UP+4*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)) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py deleted file mode 100644 index 6410a2c..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_Non_Standard_Basis.py +++ /dev/null @@ -1,51 +0,0 @@ -from manimlib.imports import * - -class NSB(ThreeDScene): - def construct(self): - - axes = ThreeDAxes(x_min = -4,x_max=4,y_min=-4,y_max=4,z_min=-4,z_max=4) - self.play(ShowCreation(axes)) - self.move_camera(phi=60*DEGREES,theta=45*DEGREES,run_time=3) - self.begin_ambient_camera_rotation(rate=0.5) - - matrix = [[0.577,0.577,0.577],[-0.577,0.577,0.577],[0.577,-0.577,0.577]] - - line1 = Line(start = ORIGIN,end = 1*RIGHT) - line1.set_color(DARK_BLUE) - tip1 = Polygon(RIGHT,0.9*RIGHT-0.1*DOWN,0.9*RIGHT-0.1*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.9*UP-0.1*RIGHT,0.9*UP-0.1*LEFT) - tip2.set_opacity(1) - tip2.set_fill(DARK_BLUE) - tip2.set_color(DARK_BLUE) - arrow2.set_color(DARK_BLUE) - - arrow3 = Line(start = ORIGIN,end = [0,0,1]) - arrow3.set_color(DARK_BLUE) - tip3 = Polygon([0,0,1],[0,0,0.9]-0.1*RIGHT,[0,0,0.9]-0.1*LEFT) - tip3.set_opacity(1) - tip3.set_fill(DARK_BLUE) - tip3.set_color(DARK_BLUE) - - line1.apply_matrix(matrix) - tip1.apply_matrix(matrix) - arrow2.apply_matrix(matrix) - tip2.apply_matrix(matrix) - arrow3.apply_matrix(matrix) - tip3.apply_matrix(matrix) - - self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), ShowCreation(arrow3), ShowCreation(tip3)) - - text = TextMobject(r"This is also a set of Orthonormal Vectors") - text.set_color(DARK_BLUE) - self.add_fixed_in_frame_mobjects(text) - text.scale(0.6) - text.move_to(3*DOWN+3.5*RIGHT) - self.play(Write(text)) - - self.wait(7) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_orthonormal.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_orthonormal.py new file mode 100644 index 0000000..af51fc6 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file3_orthonormal.py @@ -0,0 +1,333 @@ +from manimlib.imports import * + +class Algo(ThreeDScene): + def construct(self): + + axes = ThreeDAxes(x_min = -5,x_max=5,y_min=-3,y_max=3,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + + text = TextMobject(r"This is the vector $\beta_1(=\left[\begin{array}{c} 4\\0\\0 \end{array}\right])$") + text.set_color(GREEN) + text.scale(0.6) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + arrow_a = Arrow(start = ORIGIN, end = 4*RIGHT) + arrow_a.set_color(GREEN) + arrow_a.scale(1.15) + self.play(ShowCreation(arrow_a)) + + text_a = TextMobject(r"$\beta_1$") + text_a.move_to(0.4*DOWN+3*RIGHT) + text_a.set_color(GREEN) + text_a.scale(0.75) + self.play(Write(text_a)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"Normalize $\beta_1$ to get $\alpha_1$") + text.set_color(DARK_BLUE) + text.scale(0.75) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + alpha_1 = Arrow(start = ORIGIN,end = RIGHT) + alpha_1.scale(1.9) + alpha_1.set_color(DARK_BLUE) + text_alpha_1 = TextMobject(r"$\alpha_1$") + text_alpha_1.move_to(0.4*DOWN+RIGHT) + text_alpha_1.set_color(DARK_BLUE) + text_alpha_1.scale(0.75) + self.play(Transform(text_a,text_alpha_1), Transform(arrow_a,alpha_1)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"Consider another vector $\beta_2(=\left[\begin{array}{c} 2\\2\\0 \end{array}\right])$") + text1 = TextMobject(r"which is linearly independent to $\beta_1$") + text.set_color(GREEN) + text1.set_color(GREEN) + text.scale(0.6) + text1.scale(0.6) + text.move_to(3*UP+4*LEFT) + text1.move_to(2*UP+4*LEFT) + self.play(Write(text)) + self.play(Write(text1)) + + arrow_b = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) + arrow_b.scale(1.2) + arrow_b.set_color(GREEN) + text_b = TextMobject(r"$\beta_2$") + text_b.move_to(1.5*UP+RIGHT) + text_b.set_color(GREEN) + text_b.scale(0.75) + + self.play(ShowCreation(arrow_b), Write(text_b)) + self.wait() + + arrow_b_copy = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) + arrow_b_copy.scale(1.2) + + arrow_p = Arrow(start = ORIGIN, end = 2*RIGHT) + arrow_p.scale(1.35) + 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), FadeOut(text1), Transform(arrow_b_copy,arrow_p), FadeOut(text_a), FadeOut(text_b)) + text = TextMobject(r"$p$ is the projection of $\beta_2$ on $\alpha_1$") + text.set_color(GOLD_E) + text.move_to(3*UP+4*LEFT) + text.scale(0.8) + self.play(Write(text),Write(text_p)) + self.wait() + + self.play(FadeIn(text_b)) + + arrow_o = Arrow(start = 2*RIGHT, end = 2*UP+2*RIGHT) + arrow_o.scale(1.35) + arrow_o.set_color(PURPLE_E) + + text_o = TextMobject(r"$\beta_2-p$") + text_o.move_to(UP+2.7*RIGHT) + text_o.scale(0.75) + text_o.set_color(PURPLE_E) + + self.play(ShowCreation(arrow_o)) + self.play(FadeOut(text),Write(text_o)) + + text = TextMobject(r"$\beta_2-p$ is orthogonal to p") + text1 = TextMobject(r"(and hence orthogonal to $\alpha_1$ also)") + text.set_color(PURPLE_E) + text1.set_color(PURPLE_E) + text.scale(0.7) + text1.scale(0.7) + text.move_to(3*UP+4*LEFT) + text1.move_to(2.5*UP+4*LEFT) + self.play(Write(text)) + self.play(Write(text1)) + self.wait(2) + + self.play(FadeOut(text_p), FadeIn(arrow_a), FadeOut(text), FadeOut(text1), FadeOut(arrow_b_copy), FadeOut(arrow_p), FadeOut(text_b), FadeOut(arrow_b)) + self.play(ApplyMethod(arrow_o.move_to,UP), ApplyMethod(text_o.move_to,RIGHT+UP)) + + text = TextMobject(r"Now, Normalize $\beta_2-p$") + text.set_color(DARK_BLUE) + text.scale(0.6) + text.move_to(3*UP+4*LEFT) + self.play(Write(text)) + + alpha_2 = Arrow(start = ORIGIN,end = UP) + alpha_2.scale(1.9) + alpha_2.set_color(DARK_BLUE) + text_alpha_2 = TextMobject(r"$\alpha_2$") + text_alpha_2.move_to(0.4*LEFT+UP) + text_alpha_2.set_color(DARK_BLUE) + text_alpha_2.scale(0.75) + self.play(Transform(text_o,text_alpha_2), Transform(arrow_o,alpha_2), FadeIn(text_a)) + self.wait() + self.play(FadeOut(text),FadeOut(text_a),FadeOut(text_o)) + + self.add(axes) + ############################################################################# + axis = TextMobject(r"$\alpha_1$",r"$\alpha_2$",r"$\alpha_3$",r"$\beta_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$") + axis.scale(0.5) + axis[0].move_to(0.5*RIGHT+[0,0,-0.5]) + axis[1].move_to(0.5*UP+[0,0,-0.5]) + axis[2].move_to(np.array([0,0,0.5])) + axis[3].move_to(np.array([1,1,1.5])) + self.add_fixed_orientation_mobjects(axis[0]) + self.add_fixed_orientation_mobjects(axis[1]) + ############################################################################# + + text = TextMobject(r"These are the same two orthonormal vectors $\alpha_{1}$ and $\alpha_{2}$") + text.scale(0.6) + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*(DOWN+RIGHT)) + self.play(Write(text)) + + 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), FadeOut(arrow_a), FadeOut(arrow_o)) + 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"Now, we have a vector $\beta_3(=\left[\begin{array}{c} 2\\2\\2 \end{array}\right])$") + text.set_color(GOLD_E) + text.scale(0.7) + self.add_fixed_in_frame_mobjects(text) + self.add_fixed_orientation_mobjects(axis[3]) + 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.6) + text.set_color(GOLD_E) + 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.set_color(GREEN_E) + text.scale(0.6) + 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), FadeOut(axis[3]), + 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(PURPLE_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(PURPLE_E) + last_a_tip.set_color(PURPLE_E) + + self.wait() + text = TextMobject(r"Take projection on $\alpha_2$") + text.scale(0.6) + text.set_color(GOLD_E) + 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.set_color(PURPLE_E) + text.scale(0.6) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN+3.5*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(PURPLE_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(PURPLE_E) + ltip3.set_color(PURPLE_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"Normalize, the vector") + text1 = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$ + projection of $\beta_3$ on $\alpha_2$") + text.set_color(PURPLE_E) + text1.set_color(PURPLE_E) + text.scale(0.6) + text1.scale(0.6) + self.add_fixed_in_frame_mobjects(text) + self.add_fixed_in_frame_mobjects(text1) + text.move_to(3*DOWN+3*RIGHT) + text1.move_to(3.5*DOWN+3*RIGHT) + self.play(Write(text)) + self.play(Write(text1)) + + 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.add_fixed_orientation_mobjects(axis[2]) + + self.wait() + self.play(FadeOut(text),FadeOut(text1)) + + text = TextMobject(r"These are the three orthonormal vectors $\alpha_1, \alpha_2, \alpha_3$") + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.scale(0.6) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) + + self.wait(3) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file4_Non_Standard_Basis.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file4_Non_Standard_Basis.py new file mode 100644 index 0000000..6410a2c --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file4_Non_Standard_Basis.py @@ -0,0 +1,51 @@ +from manimlib.imports import * + +class NSB(ThreeDScene): + def construct(self): + + axes = ThreeDAxes(x_min = -4,x_max=4,y_min=-4,y_max=4,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + self.move_camera(phi=60*DEGREES,theta=45*DEGREES,run_time=3) + self.begin_ambient_camera_rotation(rate=0.5) + + matrix = [[0.577,0.577,0.577],[-0.577,0.577,0.577],[0.577,-0.577,0.577]] + + line1 = Line(start = ORIGIN,end = 1*RIGHT) + line1.set_color(DARK_BLUE) + tip1 = Polygon(RIGHT,0.9*RIGHT-0.1*DOWN,0.9*RIGHT-0.1*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.9*UP-0.1*RIGHT,0.9*UP-0.1*LEFT) + tip2.set_opacity(1) + tip2.set_fill(DARK_BLUE) + tip2.set_color(DARK_BLUE) + arrow2.set_color(DARK_BLUE) + + arrow3 = Line(start = ORIGIN,end = [0,0,1]) + arrow3.set_color(DARK_BLUE) + tip3 = Polygon([0,0,1],[0,0,0.9]-0.1*RIGHT,[0,0,0.9]-0.1*LEFT) + tip3.set_opacity(1) + tip3.set_fill(DARK_BLUE) + tip3.set_color(DARK_BLUE) + + line1.apply_matrix(matrix) + tip1.apply_matrix(matrix) + arrow2.apply_matrix(matrix) + tip2.apply_matrix(matrix) + arrow3.apply_matrix(matrix) + tip3.apply_matrix(matrix) + + self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), ShowCreation(arrow3), ShowCreation(tip3)) + + text = TextMobject(r"This is also a set of Orthonormal Vectors") + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.scale(0.6) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) + + self.wait(7) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py b/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py deleted file mode 100644 index ccd23c9..0000000 --- a/FSF-2020/linear-algebra/linear-transformations/Gram Schmidt Orthonormalization Process/file_introduction.py +++ /dev/null @@ -1,33 +0,0 @@ -from manimlib.imports import * - -class Orthonormal(Scene): - def construct(self): - Centre = DOWN - arrow_1 = Arrow(start = Centre+ORIGIN,end = Centre+1.414*(UP+RIGHT)) - arrow_2 = Arrow(start = Centre+ORIGIN,end = Centre+2*UP) - arrow_1.scale(1.35) - arrow_2.scale(1.35) - text = TextMobject("This is a set of linearly independent vectors") - text.scale(0.75) - text.move_to(3*UP+3*LEFT) - text.set_color(PURPLE_E) - arrow_1.set_color(PURPLE_E) - arrow_2.set_color(PURPLE_E) - self.play(Write(text)) - self.play(ShowCreation(arrow_1), ShowCreation(arrow_2)) - self.wait(2) - text1 = TextMobject("After we apply Gram-Schmidt Orthogonalization Process to set of linearly independent vectors") - text1.scale(0.6) - text1.move_to(3*UP+2*LEFT) - text1.set_color(GREEN) - arrow_a = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+RIGHT)) - arrow_a.set_color(GREEN) - arrow_a.scale(2) - self.play(Transform(text,text1)) - self.wait(2) - self.play(Transform(arrow_1,arrow_a)) - arrow_b = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+LEFT)) - arrow_b.set_color(GREEN) - arrow_b.scale(2) - self.play(Transform(arrow_2,arrow_b)) - self.wait(2) \ No newline at end of file -- cgit