from manimlib.imports import * class Linear_Dependence(ThreeDScene): def construct(self): axes = ThreeDAxes() axes.set_stroke(width=1,color=GOLD) self.add(axes) self.set_camera_orientation(phi = 70*DEGREES,theta =110*DEGREES) self.begin_ambient_camera_rotation(rate=0.05) self.wait(0.5) text1 = TextMobject(r"Consider 3 linearly dependent vectors in $\mathbb{R}^3$").scale(0.5).shift(2.5*UP+4*LEFT) line1 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-1,1,1]) self.add_fixed_in_frame_mobjects(text1) self.play(ShowCreation(text1)) self.play(ShowCreation(line1)) self.wait(1) line2 = Line(color = RED,opacity=350,start = ORIGIN,end = [1,0.5,0.5]) self.play(ShowCreation(line2)) self.wait(1) line3 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [0.5,1,1]) self.play(ShowCreation(line3)) self.wait(1) text2 = TextMobject("Scaling the Vectors").scale(0.5).shift(2.5*UP+4.5*LEFT) text3 = TextMobject(r"\text{and}",r"\text{Adding}",r"\text{them}").scale(0.5).shift(2*UP+4.5*LEFT) text3[1].set_color(GREEN) line4 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-2,2,2]) line5 = Line(color = RED,opacity = 350,start = ORIGIN,end = [3,1.5,1.5]) line6 = Line(color = BLUE,opacity = 350,start = ORIGIN,end = [-0.5,-1,-1]) self.wait(1.1) self.play(FadeOut(text1)) self.add_fixed_in_frame_mobjects(text2) self.play(ShowCreation(text2)) self.wait(0.7) self.play(Transform(line1,line4)) self.wait(0.5) self.play(Transform(line2,line5)) self.wait(0.5) self.play(Transform(line3,line6)) self.wait(1.5) line7 = Line(color = RED,opacity = 350,start = [-2,2,2],end = [1,3.5,3.5]) line8 = Line(color = BLUE,opacity = 350,start = [1,3.5,3.5],end = [0.5,2.5,2.5]) line9 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [0.5,2.5,2.5]) self.add_fixed_in_frame_mobjects(text3) self.play(ShowCreation(text3)) self.wait(0.7) self.play(FadeOut(line2),ShowCreation(line7)) self.play(FadeOut(line3),ShowCreation(line8)) self.wait(0.7) self.play(ShowCreation(line9)) self.wait(1.2) plane = Polygon([-4,4,4],[4,4,4],[4,-4,-4],[-4,-4,-4]) plane.set_opacity(0.4) plane.set_fill(DARK_BLUE) plane.set_color(DARK_BLUE) self.play(ShowCreation(plane)) self.wait(1.2) text4 = TextMobject("Linearly Combinations").scale(0.65).shift(3.5*UP+4*RIGHT) text5 = TextMobject(r"\text{$\vec{z_1}$}",r"\text{=}",r"\text{2}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{3}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(-1)}",r"\text{$\vec{w}$}",).scale(0.55).shift(2.5*UP+3.9*RIGHT) text5[0].set_color(GREEN) text5[3].set_color(YELLOW) text5[6].set_color(RED) text5[9].set_color(BLUE) self.add_fixed_in_frame_mobjects(text5) self.add_fixed_in_frame_mobjects(text4) self.play(ShowCreation(text4),ShowCreation(text5)) self.wait(3.8) bunch1 = VGroup(line7,line8,line9) line10 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[-0.5,0.5,0.5]) line11 = Line(color=RED,opacity=350,start=ORIGIN,end=[2,1,1]) line12 = Line(color = BLUE,opacity = 350,start = ORIGIN,end = [-1.5,-3,-3]) line13 = Line(color = RED,opacity = 350,start = [-0.5,0.5,0.5],end = [1.5,1.5,1.5]) line14 = Line(color = BLUE,opacity = 350,start = [1.5,1.5,1.5],end = [0,-1.5,-1.5]) line15 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [0,-1.5,-1.5]) bunch2 = VGroup(line13,line14,line15,line10) self.play(FadeOut(line1),Transform(bunch1,bunch2)) self.wait(1.2) text6 = TextMobject(r"\text{$\vec{z_2}$}",r"\text{=}",r"\text{0.5}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{2}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(-3)}",r"\text{$\vec{w}$}",).scale(0.55).shift(2*UP+4*RIGHT) text6[0].set_color(GREEN) text6[3].set_color(YELLOW) text6[6].set_color(RED) text6[9].set_color(BLUE) self.add_fixed_in_frame_mobjects(text6) self.play(ShowCreation(text6)) self.wait(2.8) bunch3 = VGroup(line10,bunch1) line16 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[-2,2,2]) line17 = Line(color=RED,opacity=350,start=ORIGIN,end=[1,0.5,0.5]) line18 = Line(color = RED,opacity = 350,start = [-2,2,2],end = [-1,2.5,2.5]) line19 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [-1,2.5,2.5]) bunch4 = VGroup(line16,line18,line19) self.play(Transform(bunch3,bunch4)) self.wait(1.2) text7 = TextMobject(r"\text{$\vec{z_3}$}",r"\text{=}",r"\text{(-2)}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{2}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(0)}",r"\text{$\vec{w}$}",).scale(0.55).shift(1.5*UP+4*RIGHT) text7[0].set_color(GREEN) text7[3].set_color(YELLOW) text7[6].set_color(RED) text7[9].set_color(BLUE) self.add_fixed_in_frame_mobjects(text7) self.play(ShowCreation(text7)) self.wait(5) self.play(FadeOut(text2),FadeOut(text3)) text8 = TextMobject(r"\text{$\vec{z}$}",r"\text{=}",r"\text{a}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{b}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{c}",r"\text{$\vec{w}$}",).scale(0.55).shift(0.8*UP+4*RIGHT) text8[0].set_color(GREEN) text8[3].set_color(YELLOW) text8[6].set_color(RED) text8[9].set_color(BLUE) rect1 = Rectangle(height=0.7,stroke_width=1.2) rect1.surround(text8) self.add_fixed_in_frame_mobjects(rect1) self.add_fixed_in_frame_mobjects(text8) self.play(ShowCreation(text8)) text9 = TextMobject(r"\text{All the}",r"\text{linear combinations}",r"\text{of linearly dependent vectors}",r"\text{$\vec{u},$}",r"\text{$\vec{v},$}",r"\text{and}",r"\text{$\vec{w}$}",r"\text{spans}").scale(0.5).shift(2.5*DOWN) text9[1].set_color(GREEN) text9[3].set_color(YELLOW) text9[4].set_color(RED) text9[6].set_color(BLUE) text9.add_background_rectangle() text10 = TextMobject(r"this entire plane (and not the entire $\mathbb{R}^3 )$.").scale(0.5).shift(3*DOWN) text10.add_background_rectangle() self.wait(2) self.add_fixed_in_frame_mobjects(text10) self.add_fixed_in_frame_mobjects(text9) self.play(ShowCreation(text9),ShowCreation(text10)) self.wait(7) class Linear_Independence(ThreeDScene): def construct(self): axes = ThreeDAxes() axes.set_stroke(width=1,color=GOLD) self.add(axes) self.set_camera_orientation(phi = 70*DEGREES,theta =110*DEGREES) self.begin_ambient_camera_rotation(rate=0.1) self.wait(0.5) text1 = TextMobject(r"Consider 3 linearly independent vectors in $\mathbb{R}^3$").scale(0.5).shift(2.5*UP+4*LEFT) self.add_fixed_in_frame_mobjects(text1) self.play(ShowCreation(text1)) line1 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-1,1,1]) self.play(ShowCreation(line1)) self.wait(0.7) line2 = Line(color = RED,opacity=350,start = ORIGIN,end = [1,0.5,0.5]) self.play(ShowCreation(line2)) self.wait(0.7) line3 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [0,-1,-2]) self.play(ShowCreation(line3)) self.wait(0.7) self.wait(1) self.play(FadeOut(text1)) text2 = TextMobject("Scaling the Vectors").scale(0.5).shift(2.5*UP+5*LEFT) self.add_fixed_in_frame_mobjects(text2) self.play(ShowCreation(text2)) self.wait(0.7) line4 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-0.5,0.5,0.5]) self.play(Transform(line1,line4)) self.wait(0.7) line5 = Line(color = RED,opacity=350,start = ORIGIN,end = [2,1,1]) self.play(Transform(line2,line5)) self.wait(0.7) line6 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [0,-1.5,-3]) self.play(Transform(line3,line6)) self.wait(1.7) text3 = TextMobject(r"\text{and}",r"\text{Adding}",r"\text{them}").scale(0.5).shift(2*UP+5*LEFT) text3[1].set_color(GREEN) line7 = Line(color = RED,opacity = 350,start = [-0.5,0.5,0.5],end = [1.5,1.5,1.5]) line8 = Line(color = BLUE,opacity = 350,start = [1.5,1.5,1.5],end = [1.5,0,-1.5]) line9 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [1.5,0,-1.5]) self.add_fixed_in_frame_mobjects(text3) self.play(ShowCreation(text3)) self.wait(0.7) self.play(FadeOut(line2),ShowCreation(line7)) self.play(FadeOut(line3),ShowCreation(line8)) self.wait(0.7) self.play(ShowCreation(line9)) self.wait(1.5) plane = Polygon([-4,4,4],[4,4,4],[4,-4,-4],[-4,-4,-4]) plane.set_opacity(0.3) plane.set_fill(DARK_BLUE) plane.set_color(DARK_BLUE) self.play(ShowCreation(plane)) self.wait(1.2) text4 = TextMobject("Linearly Combinations").scale(0.65).shift(3.5*UP+4*RIGHT) self.add_fixed_in_frame_mobjects(text4) self.play(ShowCreation(text4)) self.wait(0.7) text5 = TextMobject(r"\text{$\vec{z_1}$}",r"\text{=}",r"\text{0.5}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{2}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{1.5}",r"\text{$\vec{w}$}").scale(0.55).shift(2.5*UP+3.8*RIGHT) text5[0].set_color(GREEN) text5[3].set_color(YELLOW) text5[6].set_color(RED) text5[9].set_color(BLUE) self.add_fixed_in_frame_mobjects(text5) self.play(ShowCreation(text5)) self.wait(3.8) bunch1 = VGroup(line7,line8,line9) line10 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[-3,3,3]) line11 = Line(color = BLUE,opacity = 350,start = [-3,3,3],end = [-2,3.5,3.5]) line12 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [-2,3.5,3.5]) bunch2 = VGroup(line10,line11,line12) self.play(FadeOut(line1),Transform(bunch1,bunch2)) self.wait(1.2) text6 = TextMobject(r"\text{$\vec{z_2}$}",r"\text{=}",r"\text{3}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{1}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{0}",r"\text{$\vec{w}$}").scale(0.55).shift(2*UP+3.6*RIGHT) text6[0].set_color(GREEN) text6[3].set_color(YELLOW) text6[6].set_color(RED) text6[9].set_color(BLUE) self.add_fixed_in_frame_mobjects(text6) self.play(ShowCreation(text6)) self.wait(2.8) bunch3 = VGroup(line10,bunch1) line13 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[2.5,-2.5,-2.5]) line14 = Line(color=RED,opacity=350,start=[2.5,-2.5,-2.5],end=[0.5,-3.5,-3.5]) line15 = Line(color = BLUE,opacity = 350,start = [0.5,-3.5,-3.5],end = [0.5,-0.5,2.5]) line16 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [0.5,-0.5,2.5]) bunch4 = VGroup(line13,line14,line15,line16) self.play(Transform(bunch3,bunch4)) self.wait(1.2) text7 = TextMobject(r"\text{$\vec{z_3}$}",r"\text{=}",r"\text{(-2.5)}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{(-2)}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(-3)}",r"\text{$\vec{w}$}").scale(0.55).shift(1.5*UP+4.2*RIGHT) text7[0].set_color(GREEN) text7[3].set_color(YELLOW) text7[6].set_color(RED) text7[9].set_color(BLUE) self.add_fixed_in_frame_mobjects(text7) self.play(ShowCreation(text7)) self.play(FadeOut(text3),FadeOut(text2)) self.wait(1.2) text8 = TextMobject(r"\text{$\vec{z}$}",r"\text{=}",r"\text{a}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{b}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{c}",r"\text{$\vec{w}$}").scale(0.55).shift(0.8*UP+3.6*RIGHT) text8[0].set_color(GREEN) text8[3].set_color(YELLOW) text8[6].set_color(RED) text8[9].set_color(BLUE) rect1 = Rectangle(height=0.7,stroke_width=1.2) rect1.surround(text8) self.add_fixed_in_frame_mobjects(rect1) self.add_fixed_in_frame_mobjects(text8) self.play(ShowCreation(text8)) self.wait(1.7) self.play(FadeOut(plane)) self.wait(1.5) text9 = TextMobject(r"\text{All the}",r"\text{linear combinations}",r"\text{of linearly independent vectors}",r"\text{$\vec{u},$}",r"\text{$\vec{v},$}",r"\text{and}",r"\text{$\vec{w}$}",r"\text{spans}").scale(0.5).shift(2.5*DOWN) text9[1].set_color(GREEN) text9[3].set_color(YELLOW) text9[4].set_color(RED) text9[6].set_color(BLUE) text9.add_background_rectangle() text10 = TextMobject("not only the plane but the entire 3-D space.").scale(0.5).shift(3*DOWN) text10.add_background_rectangle() self.add_fixed_in_frame_mobjects(text9) self.add_fixed_in_frame_mobjects(text10) self.play(ShowCreation(text9),ShowCreation(text10)) self.wait(2.3) self.play(FadeOut(text5),FadeOut(text6),FadeOut(text7)) self.wait(0.6) text9 = TextMobject(r"\text{$\vec{z}$}",r"\text{=}",r"\text{a}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{b}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{c}",r"\text{$\vec{w}$}",r"\text{= 0}").scale(0.55).shift(2.6*UP+3.9*RIGHT) text9[0].set_color(GREEN) text9[3].set_color(YELLOW) text9[6].set_color(RED) text9[9].set_color(BLUE) text10 = TextMobject("only when a = b = c = 0.").scale(0.55).shift(2.2*UP+3.9*RIGHT) self.play(FadeOut(text8),FadeOut(rect1)) self.wait(0.7) self.add_fixed_in_frame_mobjects(text9) self.add_fixed_in_frame_mobjects(text10) self.play(ShowCreation(text9),ShowCreation(text10)) self.wait(5)