summaryrefslogtreecommitdiff
path: root/FSF-2020
diff options
context:
space:
mode:
authorsimranchhattani2020-05-27 19:04:23 +0530
committerGitHub2020-05-27 19:04:23 +0530
commit31e59b2ca163acd668a56ac356ebe040e9285a5a (patch)
treea7d6e5ffc8878046eb14ca99fd3490eb72a6f2b1 /FSF-2020
parentc905171679fa8ef186f4594f6713e0b887f730d5 (diff)
downloadFSF-mathematics-python-code-archive-31e59b2ca163acd668a56ac356ebe040e9285a5a.tar.gz
FSF-mathematics-python-code-archive-31e59b2ca163acd668a56ac356ebe040e9285a5a.tar.bz2
FSF-mathematics-python-code-archive-31e59b2ca163acd668a56ac356ebe040e9285a5a.zip
Add files via upload
Diffstat (limited to 'FSF-2020')
-rw-r--r--FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py14
-rw-r--r--FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py137
-rw-r--r--FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py62
3 files changed, 213 insertions, 0 deletions
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py
new file mode 100644
index 0000000..70913eb
--- /dev/null
+++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py
@@ -0,0 +1,14 @@
+from manimlib.imports import *
+class ThreeDSpace(ThreeDScene):
+ def construct(self):
+ curve = ParametricFunction(
+ lambda x: np.array([
+ 0, -x , x]), color = YELLOW, t_min = -2, t_max = 2)
+ axes = ThreeDAxes()
+ axes.set_stroke(width=1,color=GOLD)
+ self.add(axes)
+ self.set_camera_orientation(phi = 70*DEGREES,theta =60*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.3)
+ self.play(ShowCreation(curve))
+ self.wait(6)
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py
new file mode 100644
index 0000000..70af123
--- /dev/null
+++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py
@@ -0,0 +1,137 @@
+from manimlib.imports import *
+import numpy as np
+
+class vectorspace(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": 8,
+ "y_axis_height": 7,
+ "x_tick_frequency":1,
+ "axes_color": GREY,
+ "area_opacity": 3,
+ "num_rects": 10,
+ }
+ def construct(self):
+ XD = self.x_axis_width/(self.x_max- self.x_min)
+ YD = self.y_axis_height/(self.y_max- self.y_min)
+ a1=1*XD*RIGHT+2*YD*UP
+ a2=1*XD*RIGHT+1*YD*UP
+ vec1=Vector(direction=a1).set_color(RED_E)
+ vec1.shift(self.graph_origin)
+ vec2=Vector(direction=a2).set_color(YELLOW_E)
+ vec2.shift(self.graph_origin)
+ vec1_text=TextMobject(r"$\vec{a}$")
+ vec2_text=TextMobject(r"$\vec{b}$")
+ vec1_text=(vec1_text.shift(self.graph_origin+a1+0.2)).scale(.7)
+ vec2_text=(vec2_text.shift(self.graph_origin+a2+0.2)).scale(.7)
+ self.setup_axes(animate=True)
+ self.wait(2)
+ self.play(ShowCreation(vec1))
+ self.play(ShowCreation(vec1_text))
+ self.wait(.7)
+ self.play(ShowCreation(vec2))
+ self.play(ShowCreation(vec2_text))
+ self.wait(.7)
+ a=TextMobject(r"$\vec{a} = (1,2)$",color=RED_B).scale(.6)
+ a.shift(3*LEFT+2.7*UP)
+ b=TextMobject(r"$\vec{b} = (1,1)$",color=YELLOW_E).scale(.6)
+ b.shift(3*LEFT+2*UP)
+ self.play(ShowCreation(a))
+ self.play(ShowCreation(b))
+ self.wait(.5)
+ c=TextMobject(r"$2\cdot\vec{a} = 2\cdot(1,2) = (2,4)$",color=RED_B)
+ c.shift(3*LEFT+2.7*UP)
+ c.scale(.6)
+ self.play(Transform(a,c))
+ scaling1=TextMobject(r"Scaling vector $\vec{a}$ by 2 units",color=GOLD).scale(.5)
+ scaling1.shift(3.4*RIGHT+2.4*UP)
+ self.play(ShowCreation(scaling1))
+ a1=2*XD*RIGHT+4*YD*UP
+ self.play(FadeOut(vec1_text))
+ vec1_scaled=Vector(direction=a1).set_color(RED_E)
+ vec1_scaled.shift(self.graph_origin)
+ self.play(ShowCreation(vec1_scaled))
+ self.play(FadeOut(vec1))
+ vec1_scaled_text=TextMobject(r"$2\vec{a}$").scale(.7)
+ vec1_scaled_text.shift(self.graph_origin+a1+0.2)
+ self.play(ShowCreation(vec1_scaled_text))
+ self.play(FadeOut(scaling1))
+ d=TextMobject(r"$3\cdot\vec{b} = 3\cdot(1,1) = (3,3)$",color=YELLOW_E).scale(.6)
+ d.shift(3*LEFT+2*UP)
+ self.play(Transform(b,d))
+ scaling2=TextMobject(r"Scaling vector $\vec{b}$ by 3 units",color=GOLD).scale(.5)
+ scaling2.shift(3.4*RIGHT+2.4*UP)
+ self.play(ShowCreation(scaling2))
+ a2=3*XD*RIGHT+3*YD*UP
+ self.play(FadeOut(vec2_text))
+ vec2_2=Vector
+ vec2_scaled=Vector(direction=a2).set_color(YELLOW_E)
+ vec2_scaled.shift(self.graph_origin)
+ self.play(ShowCreation(vec2_scaled))
+ self.play(FadeOut(vec2))
+ vec2_scaled_text=TextMobject(r"$3\vec{b}$").scale(.7)
+ vec2_scaled_text.shift(self.graph_origin+a2+0.2)
+ self.play(ShowCreation(vec2_scaled_text))
+ self.wait(.7)
+ self.play(FadeOut(scaling2))
+ add = TextMobject("+").scale(.7)
+ add.shift(4.8*LEFT+2*UP)
+ self.play(ShowCreation(add))
+ self.wait(.5)
+ line = Line()
+ line.shift(3*LEFT+1.6*UP)
+ line.scale(1.8)
+ self.play(ShowCreation(line))
+ self.wait(1)
+ e = TextMobject(r"$\vec{c} = 2\cdot\vec{a} + 3\cdot\vec{b} = (5,7)$",color=GREEN_D).scale(.6)
+ e.shift(3*LEFT+1.3*UP)
+ self.play(ShowCreation(e))
+ self.wait(.5)
+ add1=TextMobject("Addition of the scaled vectors",color=GOLD).scale(.5)
+ add1.shift(4.1*RIGHT+2.4*UP)
+ self.play(ShowCreation(add1))
+ self.wait(.5)
+ self.play(FadeOut(vec1_scaled_text))
+ self.play(FadeOut(vec2_scaled_text))
+ self.play(FadeOut(vec1_scaled))
+ vec1_scaled2=Vector(direction=a1).set_color(RED_E)
+ vec1_scaled2.shift(self.graph_origin+3*RIGHT*XD+3*UP*YD)
+ self.play(ShowCreation(vec1_scaled2))
+ a3=5*XD*RIGHT+7*YD*UP
+ vec3=Vector(direction=a3).set_color(GREEN_C)
+ vec3.shift(self.graph_origin)
+ vec3_text=TextMobject(r"$\vec{c}$").scale(.7)
+ vec3_text.shift(self.graph_origin+a3+0.2)
+ self.play(ShowCreation(vec3))
+ self.wait(.5)
+ self.play(ShowCreation(vec3_text))
+ self.wait(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py
new file mode 100644
index 0000000..4f5614d
--- /dev/null
+++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py
@@ -0,0 +1,62 @@
+from manimlib.imports import *
+from scipy import sin,cos
+class FunctionalVectorSpace(GraphScene):
+ CONFIG = {
+ "x_min": -5,
+ "x_max": 5,
+ "y_min": -5,
+ "y_max": 5,
+ "graph_origin": ORIGIN,
+ }
+ def construct(self):
+ self.setup_axes(animate = True)
+ curve1 = self.get_graph(lambda x : sin(x), x_min=-5,x_max=5,color=YELLOW_E)
+ curve2 = self.get_graph(lambda x : cos(x), x_min=-5,x_max=5,color=RED)
+ self.play(ShowCreation(curve1))
+ fx=TextMobject(r"$f(x)$",color=YELLOW_E).scale(0.7)
+ fx.shift(5*LEFT+0.7*UP)
+ self.play(ShowCreation(fx))
+ self.play(ShowCreation(curve2))
+ gx=TextMobject(r"$g(x)$",color=RED).scale(0.7)
+ gx.shift(5*LEFT+0.2*UP)
+ self.play(ShowCreation(gx))
+ self.wait(2)
+ scaling=TextMobject("Scaling f(x) by 2 units",color=GOLD).scale(0.65)
+ scaling.shift(3*LEFT+2.4*UP)
+ curve3 = self.get_graph(lambda x : 2*sin(x), x_min=-5,x_max=5,color=BLUE)
+ fx2=TextMobject(r"$2f(x)$",color=BLUE).scale(0.7)
+ fx2.shift(5*LEFT+1*UP)
+ self.play(Transform(curve1,curve3),FadeOut(fx),ShowCreation(fx2),ShowCreation(scaling))
+ self.wait(3)
+ hx = TextMobject(r"$h(x)$",color=PURPLE).scale(0.7)
+ hx.shift(4.9*LEFT+1.5*UP)
+ curve4 = self.get_graph(lambda x : 2*sin(x) + cos(x), x_min=-5,x_max=5,color=PURPLE)
+ self.play(ShowCreation(curve4),ShowCreation(hx))
+ self.play(FadeOut(curve2),FadeOut(curve1),FadeOut(fx2),FadeOut(gx),FadeOut(scaling))
+ hxn=TextMobject(r"$h(x)$",color=PURPLE).scale(0.7)
+ hxn.shift(3*RIGHT+2.4*UP)
+ equal = TextMobject("=").scale(0.7)
+ equal.shift(3.5*RIGHT+2.4*UP)
+ fx2n=TextMobject(r"$2f(x)$",color=BLUE).scale(0.7)
+ fx2n.shift(4.2*RIGHT+2.4*UP)
+ add=TextMobject("+").scale(0.7)
+ add.shift(4.8*RIGHT+2.4*UP)
+ gxn=TextMobject(r"$g(x)$",color=RED).scale(0.7)
+ gxn.shift(5.3*RIGHT+2.4*UP)
+ vector_add=TextMobject("Vector Addition",color=GOLD).scale(0.65)
+ vector_add.shift(3*UP+3*RIGHT)
+ self.play(ShowCreation(hxn),ShowCreation(equal),ShowCreation(fx2n),ShowCreation(add),ShowCreation(gxn),ShowCreation(vector_add))
+ self.wait(2)
+
+
+
+
+
+
+
+
+
+
+
+
+ \ No newline at end of file