From 5c947bf68465241eee3abcec931ae53054ae4eef Mon Sep 17 00:00:00 2001 From: simranchhattani Date: Sat, 11 Jul 2020 00:59:15 +0530 Subject: Add files via upload --- .../Dual-Spaces/Basis_of_a_dual_vector_space.py | 126 +++++++++++++++++++++ .../Dual-Spaces/Dual_Basis_Example.py | 97 ++++++++++++++++ .../Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py | 38 +++++++ .../Vector-Spaces/Dual-Spaces/Duality_in_Sets.py | 25 ++++ .../Vector-Spaces/Dual-Spaces/Linear_Functional.py | 29 +++++ 5 files changed, 315 insertions(+) create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Basis_of_a_dual_vector_space.py create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py (limited to 'FSF-2020/linear-algebra/vector-spaces/Vector-Spaces') diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Basis_of_a_dual_vector_space.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Basis_of_a_dual_vector_space.py new file mode 100644 index 0000000..630670e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Basis_of_a_dual_vector_space.py @@ -0,0 +1,126 @@ +from manimlib.imports import * +class DualVectorSpace(ZoomedScene): + + def construct(self): + c1 = Ellipse(radius = 2,color=BLUE) + c2 = Ellipse(radius = 2,color=YELLOW) + c1.rotate(np.pi/2) + c2.rotate(np.pi/2) + c1.shift(2*LEFT+0.6*UP) + c2.shift(2*RIGHT+0.6*UP) + c1.scale(2) + c2.scale(2) + self.play(ShowCreation(c1)) + self.play(ShowCreation(c2)) + dot1 = SmallDot(color=BLUE).shift(2*LEFT+2*UP) + dot2 = SmallDot(color=BLUE).shift(2*LEFT+1.5*UP) + dot3 = SmallDot(color=BLUE).shift(2*LEFT+1*UP) + dot4 = SmallDot(color=BLUE).shift(2*LEFT+0.5*UP) + dot5 = SmallDot(color=BLUE).shift(2*LEFT) + dot6 = SmallDot(color=BLUE).shift(2*LEFT+0.5*DOWN) + dot7 = SmallDot(color=BLUE).shift(2*LEFT+1*DOWN) + text1 = TextMobject(r"$V$").scale(0.6).shift(3*UP+2*LEFT) + text2 = TextMobject(r"$V^* = \{T:V\rightarrow F\}$").scale(0.6).shift(3*UP+2.5*RIGHT) + self.play(ShowCreation(dot1),ShowCreation(dot2),ShowCreation(dot3),ShowCreation(dot4),ShowCreation(dot5),ShowCreation(dot6),ShowCreation(dot7)) + v1 = TextMobject(r"$v_1$").scale(0.5).shift(2.2*LEFT+2*UP) + v2 = TextMobject(r"$v_2$").scale(0.5).shift(2.2*LEFT+1.5*UP) + v3 = TextMobject(r"$v_3$").scale(0.5).shift(2.2*LEFT+1*UP) + v4 = TextMobject(r"$v_4$").scale(0.5).shift(2.2*LEFT+0.5*UP) + v5 = TextMobject(r"$v_5$").scale(0.5).shift(2.2*LEFT) + v6 = TextMobject(r"$v_6$").scale(0.5).shift(2.2*LEFT+0.5*DOWN) + v7 = TextMobject(r"$v_7$").scale(0.5).shift(2.2*LEFT+1*DOWN) + self.play(ShowCreation(v1),ShowCreation(v2),ShowCreation(v3),ShowCreation(v4),ShowCreation(v5),ShowCreation(v6),ShowCreation(v7)) + self.play(ShowCreation(text1)) + dot9 = SmallDot(color=YELLOW).shift(2*RIGHT+2*UP) + dot10 = SmallDot(color=YELLOW).shift(2*RIGHT+1.5*UP) + dot11 = SmallDot(color=YELLOW).shift(2*RIGHT+1*UP) + dot12 = SmallDot(color=YELLOW).shift(2*RIGHT+0.5*UP) + dot13 = SmallDot(color=YELLOW).shift(2*RIGHT) + dot14 = SmallDot(color=YELLOW).shift(2*RIGHT+0.5*DOWN) + dot15 = SmallDot(color=YELLOW).shift(2*RIGHT+1*DOWN) + self.play(ShowCreation(dot9),ShowCreation(dot10),ShowCreation(dot11),ShowCreation(dot12),ShowCreation(dot13),ShowCreation(dot14),ShowCreation(dot15)) + v9 = TextMobject(r"${T_1}$").scale(0.5).shift(2.2*RIGHT+2*UP) + v10 = TextMobject(r"${T_2}$").scale(0.5).shift(2.2*RIGHT+1.5*UP) + v11 = TextMobject(r"${T_3}$").scale(0.5).shift(2.2*RIGHT+1*UP) + v12 = TextMobject(r"${T_4}$").scale(0.5).shift(2.2*RIGHT+0.5*UP) + v13 = TextMobject(r"${T_5}$").scale(0.5).shift(2.2*RIGHT) + v14 = TextMobject(r"${T_6}$").scale(0.5).shift(2.2*RIGHT+0.5*DOWN) + v15 = TextMobject(r"${T_7}$").scale(0.5).shift(2.2*RIGHT+1*DOWN) + self.play(ShowCreation(v9),ShowCreation(v10),ShowCreation(v11),ShowCreation(v12),ShowCreation(v13),ShowCreation(v14),ShowCreation(v15)) + self.play(ShowCreation(text2)) + line1 = Line(start=dot1,end=dot9,stroke_width=0.95) + line2 = Line(start=dot2,end=dot10,stroke_width=0.95) + line3 = Line(start=dot3,end=dot11,stroke_width=0.95) + line4 = Line(start=dot4,end=dot12,stroke_width=0.95) + line5 = Line(start=dot5,end=dot13,stroke_width=0.95) + line6 = Line(start=dot6,end=dot14,stroke_width=0.95) + line7 = Line(start=dot7,end=dot15,stroke_width=0.95) + self.play(ShowCreation(line1),ShowCreation(line2),ShowCreation(line3),ShowCreation(line4),ShowCreation(line5),ShowCreation(line6),ShowCreation(line7)) + self.wait(1.5) + rect1 = Rectangle(stroke_width=0.5,width=1,height=1.9).set_fill(color=BLUE,opacity=0.3) + vgroup1 = VGroup(dot3,dot4,v3,v4) + rect1.surround(vgroup1) + self.play(ShowCreation(rect1)) + text3 = TextMobject(r"Basis of $V$ = $\{v_3, v_4\}$").shift(4.6*LEFT+1*UP).scale(0.5) + self.play(ShowCreation(text3)) + self.wait(1.5) + rect2 = Rectangle(stroke_width=0.5,width=1,height=1.7).set_fill(color=YELLOW,opacity=0.3) + vgroup2 = VGroup(dot11,dot12,v11,v12) + rect2.surround(vgroup2) + self.play(ShowCreation(rect2)) + text4 = TextMobject(r"Basis of $V^*$ = $\{{T_3},{T_4} \}$").shift(4.6*RIGHT+1*UP).scale(0.5) + self.play(ShowCreation(text4)) + self.wait(2.5) + v9.move_to(3*LEFT+3*UP).scale(1.2).set_color(YELLOW) + colon = TextMobject(":").shift(3*UP+2.6*LEFT) + vgroup3 = VGroup(line1,line2,line3,line4,line5,line6,line7) + vgroup4 = VGroup(v10,v11,v12,v13,v14,v15,rect1,rect2,text3,text4,c2) + vgroup5 = VGroup(dot9,dot10,dot11,dot12,dot13,dot14,dot15) + text5 = TextMobject(r"$F$").scale(0.6).shift(3*UP+2*RIGHT) + dot9 = SmallDot(color=GREEN).shift(2*RIGHT+2*UP) + dot10 = SmallDot(color=GREEN).shift(2*RIGHT+1.5*UP) + dot11 = SmallDot(color=GREEN).shift(2*RIGHT+1*UP) + dot12 = SmallDot(color=GREEN).shift(2*RIGHT+0.5*UP) + dot13 = SmallDot(color=GREEN).shift(2*RIGHT) + dot14 = SmallDot(color=GREEN).shift(2*RIGHT+0.5*DOWN) + dot15 = SmallDot(color=GREEN).shift(2*RIGHT+1*DOWN) + f1 = TextMobject(r"${f_1}$").scale(0.5).shift(2.2*RIGHT+2*UP) + f2 = TextMobject(r"${f_2}$").scale(0.5).shift(2.2*RIGHT+1.5*UP) + f3 = TextMobject(r"${f_3}$").scale(0.5).shift(2.2*RIGHT+1*UP) + f4 = TextMobject(r"${f_4}$").scale(0.5).shift(2.2*RIGHT+0.5*UP) + f5 = TextMobject(r"${f_5}$").scale(0.5).shift(2.2*RIGHT) + f6 = TextMobject(r"${f_6}$").scale(0.5).shift(2.2*RIGHT+0.5*DOWN) + f7 = TextMobject(r"${f_7}$").scale(0.5).shift(2.2*RIGHT+1*DOWN) + vgroup6 = VGroup(f1,f2,f3,f4,f5,f6,f7) + arrow = Arrow(stroke_width=1.6).scale(1.5).shift(3*UP) + c3 = Ellipse(radius = 2,color=GREEN) + c3.rotate(np.pi/2) + c3.shift(2*RIGHT+0.6*UP) + c3.scale(2) + self.play(ShowCreation(v9)) + self.wait(1.5) + self.play(ShowCreation(arrow),ShowCreation(colon),Transform(text2,text5),FadeOut(vgroup3),FadeOut(vgroup4),FadeOut(vgroup5)) + self.play(ShowCreation(vgroup5),ShowCreation(vgroup6),ShowCreation(c3)) + self.wait(0.7) + self.play(ShowCreation(vgroup3)) + self.wait(3) + + + + + + + + + + + + + + + + + + + + diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py new file mode 100644 index 0000000..d79ec3e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py @@ -0,0 +1,97 @@ +from manimlib.imports import * +import numpy as np + +class Dual_Basis(GraphScene): + CONFIG={ + "x_min": -7, + "x_max": 7, + "y_min": -7, + "y_max": 7, + "graph_origin": ORIGIN, + "x_axis_label":"$X$", + "y_axis_label":"$Y$", + "x_labeled_nums": list(np.arange(-7, 8,1)), + "y_labeled_nums": list(np.arange(-7, 8,1)), + "x_axis_width": 10, + "y_axis_height": 10, + "x_tick_frequency":1, + "axes_color": GREY, + "area_opacity": 3, + "num_rects": 10, + } + def construct(self): + self.setup_axes(animate = True) + XD = self.x_axis_width/(self.x_max- self.x_min) + YD = self.y_axis_height/(self.y_max- self.y_min) + a1=2*XD*RIGHT+1*YD*UP + a2=3*XD*RIGHT+1*YD*UP + vec1=Vector(direction=a1,stroke_width=2).set_color(RED_E) + vec1.shift(self.graph_origin) + v1_label=TextMobject(r"$v_1$") + v1_label=(v1_label.shift(self.graph_origin+a1+0.1)).scale(.6) + self.play(ShowCreation(vec1),ShowCreation(v1_label)) + text1=TextMobject(r"\text{$v_1$}",r"\text{$= (2,1)$}").scale(.6) + text1[0].set_color(RED_E) + text1.shift(5*LEFT+3.5*UP) + self.play(ShowCreation(text1)) + self.wait(1.5) + vec2=Vector(direction=a2,stroke_width=2).set_color(YELLOW_E) + vec2.shift(self.graph_origin) + v2_label=TextMobject(r"$v_2$") + v2_label=(v2_label.shift(self.graph_origin+a2+0.1)).scale(.6) + self.play(ShowCreation(vec2),ShowCreation(v2_label)) + text2=TextMobject(r"\text{$v_2$}",r"\text{$= (3,1)$}").scale(.6) + text2[0].set_color(YELLOW_E) + text2.shift(5*LEFT+3*UP) + self.play(ShowCreation(text2)) + self.wait(1.5) + text3=TextMobject(r"\text{${T_2}$}",r"\text{$(v_1)$}",r"\text{$= 0$}").scale(.6) + text3[0].set_color(BLUE) + text3[1].set_color(RED_E) + text3.shift(4.94*LEFT+2.5*UP) + self.play(ShowCreation(text3)) + self.wait(1.5) + text4=TextMobject(r"\text{${T_2}$}",r"\text{$= x - 2y$}").scale(.6) + text4[0].set_color(BLUE) + text4.shift(4.9*LEFT+2*UP) + self.play(ShowCreation(text4)) + self.wait(1.5) + line1 = self.get_graph(lambda x : x/2, x_min = -5,x_max=5,color=BLUE) + v1_dual_label = TextMobject(r"${T_2}$").scale(.6).shift(3.9*RIGHT+1.85*UP) + self.play(ShowCreation(line1),ShowCreation(v1_dual_label)) + self.wait(1.5) + text5=TextMobject(r"\text{${T_1}$}",r"\text{$(v_2)$}",r"\text{$= 0$}").scale(.6) + text5[1].set_color(YELLOW_E) + text5[0].set_color(PINK) + text5.shift(4.94*LEFT+1.5*UP) + self.play(ShowCreation(text5)) + self.wait(1.5) + line2 = self.get_graph(lambda x : x/3, x_min = -5,x_max=5,color=PINK) + v2_dual_label = TextMobject(r"${T_1}$").scale(.6).shift(3.9*RIGHT+1.3*UP) + self.play(ShowCreation(line2),ShowCreation(v2_dual_label)) + self.wait(1.5) + text6=TextMobject(r"\text{${T_1}$}",r"\text{$= - x + 3y$}").scale(.6) + text6[0].set_color(PINK) + text6.shift(4.76*LEFT+1*UP) + self.play(ShowCreation(text6)) + self.wait(3) + text7 = TextMobject(r"\text{B =}",r"\text{$[$}",r"\text{$v_1,$}",r"\text{$v_2$}",r"\text{$]$}",r"\text{=}",r"\text{$[(2,1), (3,1)]$}").scale(0.6).shift(3*UP+4.5*LEFT) + text7[2].set_color(RED_E) + text7[3].set_color(YELLOW_E) + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3),FadeOut(text4),FadeOut(text5),FadeOut(text6)) + self.play(ShowCreation(text7)) + self.wait(0.7) + text8 = TextMobject(r"\text{B$^* =$}",r"\text{$[$}",r"\text{${T_1}$,}",r"\text{${T_2} $}",r"\text{$]$}",r"\text{=}",r"\text{$[-x + 3y, x - 2y]$}").scale(0.6).shift(2.3*UP+4.1*LEFT) + text8[3].set_color(BLUE) + text8[2].set_color(PINK) + self.play(ShowCreation(text8)) + self.wait(3) + + + + + + + + + diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py new file mode 100644 index 0000000..a6f501e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py @@ -0,0 +1,38 @@ +from manimlib.imports import * +class Duality(ThreeDScene): + + + def construct(self): + axes = ThreeDAxes() + self.set_camera_orientation(phi = 65*DEGREES,theta =80*DEGREES) + self.begin_ambient_camera_rotation(rate=0.09) + cube = Cube(stroke_width=5,color=WHITE).scale(2) + cube.set_opacity(0.2) + self.play(ShowCreation(cube)) + dot1= Dot(color=RED).scale(0.85).shift([2,0,0]) + self.play(ShowCreation(dot1)) + dot2= Dot(color=YELLOW).scale(0.85).shift([-2,0,0]) + self.play(ShowCreation(dot2)) + dot3= Dot(color=BLUE).scale(0.85).shift([0,-2,0]) + self.play(ShowCreation(dot3)) + dot4= Dot(color=GREEN).scale(0.85).shift([0,2,0]) + self.play(ShowCreation(dot4)) + dot5= Dot(color=ORANGE).scale(0.85).shift([0,0,2]) + self.play(ShowCreation(dot5)) + dot6= Dot(color=PINK).scale(0.85).shift([0,0,-2]) + self.play(ShowCreation(dot6)) + line1 = Line(start=[0,0,2],end=[2,0,0],stroke_width=2.5,color=BLACK) + line2 = Line(start=[0,0,2],end=[-2,0,0],stroke_width=2.5,color=BLACK) + line3 = Line(start=[0,0,2],end=[0,-2,0],stroke_width=2.5,color=BLACK) + line4 = Line(start=[0,0,2],end=[0,2,0],stroke_width=2.5,color=BLACK) + line5 = Line(start=[2,0,0],end=[0,0,-2],stroke_width=2.5,color=BLACK) + line6 = Line(start=[-2,0,0],end=[0,0,-2],stroke_width=2.5,color=BLACK) + line7 = Line(start=[0,-2,0],end=[0,0,-2],stroke_width=2.5,color=BLACK) + line8 = Line(start=[0,2,0],end=[0,0,-2],stroke_width=2.5,color=BLACK) + line9 = Line(start=[0,2,0],end=[-2,0,0],stroke_width=2.5,color=BLACK) + line10 = Line(start=[-2,0,0],end=[0,-2,0],stroke_width=2.5,color=BLACK) + line11 = Line(start=[0,-2,0],end=[2,0,0],stroke_width=2.5,color=BLACK) + line12 = Line(start=[2,0,0],end=[0,2,0],stroke_width=2.5,color=BLACK) + self.play(ShowCreation(line1),ShowCreation(line2),ShowCreation(line3),ShowCreation(line4),ShowCreation(line5),ShowCreation(line6),ShowCreation(line7),ShowCreation(line8),ShowCreation(line9),ShowCreation(line10),ShowCreation(line11),ShowCreation(line12)) + self.wait(10) + diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py new file mode 100644 index 0000000..693017e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py @@ -0,0 +1,25 @@ +from manimlib.imports import * +import numpy as np +class Duality_in_sets(Scene): + def construct(self): + circle1 = Circle(radius=0.4,color=BLACK).shift(2.3*LEFT) + circle1.set_fill(color=RED,opacity=200) + rect1=Rectangle(height=2,width=2,color=GREY).shift(2*LEFT) + rect1.set_fill(color=DARK_BLUE,opacity=1) + text1 = TextMobject("S").scale(0.7).shift(0.9*UP+0.7*LEFT) + text2 = TextMobject("X",color=BLACK,stroke_width=0.5).scale(0.5).shift(2.3*LEFT) + self.play(ShowCreation(rect1),ShowCreation(text1),ShowCreation(circle1),ShowCreation(text2)) + circle2 = Circle(radius=0.4,color=BLACK).shift(1.7*RIGHT) + circle2.set_fill(color=BLACK,opacity=200) + rect2=Rectangle(height=2,width=2,color=GREY).shift(2*RIGHT) + rect2.set_fill(color=DARK_BLUE,opacity=1) + text3 = TextMobject("S").scale(0.7).shift(0.9*UP+3.3*RIGHT) + text4 = TextMobject(r"X$^c$",color=BLACK,stroke_width=0.2).scale(0.5).shift(2.55*RIGHT+0.6*UP) + text5 = TextMobject(r"\text{The subset}",r"\text{X$^c$}",r"\text{is the dual of subset}",r"\text{X}").scale(0.6).shift(2.7*UP+0.5*LEFT) + text5[1].set_color(GREY) + text5[3].set_color(GREY) + self.play(ShowCreation(rect2),ShowCreation(circle2),ShowCreation(text3),ShowCreation(text4)) + self.wait(2) + self.play(ShowCreation(text5)) + self.wait(3) + diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py new file mode 100644 index 0000000..6edc918 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py @@ -0,0 +1,29 @@ +from manimlib.imports import * +import numpy as np +class LinearFunctional(Scene): + def construct(self): + big_box=Rectangle().scale(2.7) + box = Rectangle(height=2,width=2,color=DARK_GREY).set_fill(color=PURPLE,opacity=350) + arrow1 = Arrow(color=RED).shift(1.8*LEFT+0.5*UP) + arrow2 = Arrow(color=RED).shift(1.8*LEFT+0.5*DOWN) + arrow3 = Arrow(color=GREEN).shift(0.5*UP+1.8*RIGHT) + arrow4 = Arrow(color=GREEN).shift(0.5*DOWN+1.8*RIGHT) + Linear = TextMobject("LINEAR",color=BLACK).scale(0.5).shift(0.2*UP) + Functional = TextMobject("FUNCTIONAL",color=BLACK).scale(0.5).shift(0.2*DOWN) + u = TextMobject(r"$\vec{u}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*UP) + v = TextMobject(r"$\vec{v}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*DOWN) + f1 = TextMobject(r"$f_1$",color=YELLOW).scale(0.7).shift(2.8*RIGHT+0.5*UP) + f2 = TextMobject(r"$f_2$",color=YELLOW).scale(0.7).shift(2.8*RIGHT+0.5*DOWN) + text = TextMobject(r"The Linear Functional is a function that takes $\vec{u}, \vec{v} \in$ V as inputs and gives the output $f_1, f_2\in$ F.").scale(0.55).shift(2*DOWN) + self.play(ShowCreation(big_box)) + self.play(ShowCreation(box)) + self.play(ShowCreation(Linear),ShowCreation(Functional)) + self.wait(2) + self.play(ShowCreation(arrow1),ShowCreation(u)) + self.play(ShowCreation(arrow3),ShowCreation(f1)) + self.wait(0.7) + self.play(ShowCreation(arrow2),ShowCreation(v)) + self.play(ShowCreation(arrow4),ShowCreation(f2)) + self.wait(1) + self.play(ShowCreation(text)) + self.wait(4) -- cgit