From 10641b7f85bb04b9e680b48881006bfadd67cbed Mon Sep 17 00:00:00 2001 From: simranchhattani Date: Wed, 24 Jun 2020 14:44:01 +0530 Subject: Add files via upload --- .../Function_Scalar_Multiplication.py | 62 +++++++++++++++ .../Function_Space_Addition.py | 89 ++++++++++++++++++++++ .../Integral_Properties.py | 77 +++++++++++++++++++ 3 files changed, 228 insertions(+) create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py create mode 100644 FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py (limited to 'FSF-2020/linear-algebra/vector-spaces/Vector-Spaces') diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py new file mode 100644 index 0000000..ac74792 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py @@ -0,0 +1,62 @@ +from manimlib.imports import * +from scipy import exp +class FunctionScalarMultiplication(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color":LIGHT_GRAY, + "graph_origin": ORIGIN, + } + def construct(self): + self.setup_axes(animate = True) + curve1 = self.get_graph(lambda x : 1/3*(x**2)+1, x_min=-2,x_max=2.5,color=ORANGE) + curve2 = self.get_graph(lambda x : 2*(1/3*(x**2)+1), x_min=-2,x_max=2.5,color=GOLD) + fx= TextMobject("$f(x)$").scale(0.6).shift(1.25*UP + 2.2*LEFT) + gx= TextMobject("$2 \cdot f(x)$").scale(0.6).shift(0.5*UP + 2.1*LEFT) + f1 = self.get_vertical_line_to_graph(-2,curve1,color=YELLOW) + f2 = self.get_vertical_line_to_graph(-1.5,curve1,color=YELLOW) + f3 = self.get_vertical_line_to_graph(-1,curve1,color=YELLOW) + f4 = self.get_vertical_line_to_graph(-0.5,curve1,color=YELLOW) + f5 = self.get_vertical_line_to_graph(0,curve1,color=YELLOW) + f6 = self.get_vertical_line_to_graph(0.5,curve1,color=YELLOW) + f7 = self.get_vertical_line_to_graph(1,curve1,color=YELLOW) + f8 = self.get_vertical_line_to_graph(1.5,curve1,color=YELLOW) + f9 = self.get_vertical_line_to_graph(2,curve1,color=YELLOW) + f10 = self.get_vertical_line_to_graph(2.5,curve1,color=YELLOW) + self.play(ShowCreation(curve1),ShowCreation(fx)) + self.wait(1.5) + self.play(ShowCreation(f1),ShowCreation(f2),ShowCreation(f3),ShowCreation(f4),ShowCreation(f5),ShowCreation(f6),ShowCreation(f7),ShowCreation(f8),ShowCreation(f9),ShowCreation(f10)) + self.wait(1.7) + line1=Line(color=YELLOW).shift(5*LEFT+1.8*UP).scale(0.5) + line1.rotate(np.pi/2) + scalar = TextMobject("2 x").scale(0.65).shift(5.5*LEFT+1.9*UP) + equal = TextMobject("=").scale(0.65).shift(4.5*LEFT+1.9*UP) + line2=Line(color=BLUE).shift(4*LEFT+2.3*UP) + line2.rotate(np.pi/2) + self.play(ShowCreation(line1),ShowCreation(scalar),ShowCreation(equal),ShowCreation(line2)) + g1 = self.get_vertical_line_to_graph(-2,curve2,color=BLUE) + g2 = self.get_vertical_line_to_graph(-1.5,curve2,color=BLUE) + g3 = self.get_vertical_line_to_graph(-1,curve2,color=BLUE) + g4 = self.get_vertical_line_to_graph(-0.5,curve2,color=BLUE) + g5 = self.get_vertical_line_to_graph(0,curve2,color=BLUE) + g6 = self.get_vertical_line_to_graph(0.5,curve2,color=BLUE) + g7 = self.get_vertical_line_to_graph(1,curve2,color=BLUE) + g8 = self.get_vertical_line_to_graph(1.5,curve2,color=BLUE) + g9 = self.get_vertical_line_to_graph(2,curve2,color=BLUE) + g10 = self.get_vertical_line_to_graph(2.5,curve2,color=BLUE) + self.play(ShowCreation(g1),ShowCreation(g2),ShowCreation(g3),ShowCreation(g4),ShowCreation(g5),ShowCreation(g6),ShowCreation(g7),ShowCreation(g8),ShowCreation(g9),ShowCreation(g10)) + self.wait(2) + fx2=TextMobject("2$\cdot f(x)$").scale(0.6).shift(2.6*UP+2.3*LEFT) + self.play(ShowCreation(curve2),ShowCreation(fx2)) + self.wait(1.5) + self.play(FadeOut(curve1),FadeOut(fx)) + sc_mult=TextMobject("$(2 f(x)) = 2f(x)$",color=GOLD).scale(0.65).shift(0.65*UP + 5*LEFT) + rect = Rectangle(height=0.5,width=2) + rect.surround(sc_mult) + self.play(ShowCreation(sc_mult),ShowCreation(rect)) + self.wait(3) + diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py new file mode 100644 index 0000000..5ce0e11 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py @@ -0,0 +1,89 @@ +from manimlib.imports import * +from scipy import sin,exp +class FunctionalVectorSpace(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color":LIGHT_GRAY, + "graph_origin": ORIGIN, + + + } + def construct(self): + self.setup_axes(animate = True) + curve1 = self.get_graph(lambda x : exp(x) + 0.5, x_min=-2,x_max=2.5,color=ORANGE) + curve2 = self.get_graph(lambda x : 1/3*(x**2)+1, x_min=-2,x_max=2.5,color=DARK_BLUE) + curve3 = self.get_graph(lambda x : 1/3*(x**2)+1 + exp(x) + 0.5, x_min=-2,x_max=2.5,color=BLACK) + fx= TextMobject("$f(x)$").scale(0.6).shift(1.25*UP + 2.1*LEFT) + gx= TextMobject("$g(x)$").scale(0.6).shift(0.5*UP + 2.1*LEFT) + f1 = self.get_vertical_line_to_graph(-2,curve1,color=YELLOW) + f2 = self.get_vertical_line_to_graph(-1.5,curve1,color=YELLOW) + f3 = self.get_vertical_line_to_graph(-1,curve1,color=YELLOW) + f4 = self.get_vertical_line_to_graph(-0.5,curve1,color=YELLOW) + f5 = self.get_vertical_line_to_graph(0,curve1,color=YELLOW) + f6 = self.get_vertical_line_to_graph(0.5,curve1,color=YELLOW) + f7 = self.get_vertical_line_to_graph(1,curve1,color=YELLOW) + f8 = self.get_vertical_line_to_graph(1.5,curve1,color=YELLOW) + f9 = self.get_vertical_line_to_graph(2,curve1,color=YELLOW) + f10 = self.get_vertical_line_to_graph(2.5,curve1,color=YELLOW) + + self.play(ShowCreation(curve1),ShowCreation(gx)) + self.wait(1.2) + self.play(ShowCreation(curve2),ShowCreation(fx)) + self.wait(1.2) + self.play(ShowCreation(f1),ShowCreation(f2),ShowCreation(f3),ShowCreation(f4),ShowCreation(f5),ShowCreation(f6),ShowCreation(f7),ShowCreation(f8),ShowCreation(f9),ShowCreation(f10)) + self.wait(1.7) + g1 = self.get_vertical_line_to_graph(-2,curve2,color=BLUE) + g2 = self.get_vertical_line_to_graph(-1.5,curve2,color=BLUE) + g3 = self.get_vertical_line_to_graph(-1,curve2,color=BLUE) + g4 = self.get_vertical_line_to_graph(-0.5,curve2,color=BLUE) + g5 = self.get_vertical_line_to_graph(0,curve2,color=BLUE) + g6 = self.get_vertical_line_to_graph(0.5,curve2,color=BLUE) + g7 = self.get_vertical_line_to_graph(1,curve2,color=BLUE) + g8 = self.get_vertical_line_to_graph(1.5,curve2,color=BLUE) + g9 = self.get_vertical_line_to_graph(2,curve2,color=BLUE) + g10 = self.get_vertical_line_to_graph(2.5,curve2,color=BLUE) + self.play(ShowCreation(g1),ShowCreation(g2),ShowCreation(g3),ShowCreation(g4),ShowCreation(g5),ShowCreation(g6),ShowCreation(g7),ShowCreation(g8),ShowCreation(g9),ShowCreation(g10)) + line1=Line(color=BLUE).shift(5*LEFT+2.3*UP).scale(0.25) + line1.rotate(np.pi/2) + line2=Line(color=YELLOW).shift(6*LEFT+2.5*UP).scale(0.5) + line2.rotate(np.pi/2) + line3=Line(color=PURPLE_B).shift(4*LEFT+2.7*UP).scale(0.75) + line3.rotate(np.pi/2) + add=TextMobject("+").shift(2.4*UP+5.5*LEFT).scale(0.7) + equal=TextMobject("=").shift(2.4*UP+4.5*LEFT).scale(0.7) + self.play(ShowCreation(line2),ShowCreation(line1),ShowCreation(add),ShowCreation(equal),ShowCreation(line3)) + self.wait(2) + self.play(FadeOut(curve1),FadeOut(curve2)) + self.wait(3) + h1 = self.get_vertical_line_to_graph(-2,curve3,color=PURPLE_B) + h2 = self.get_vertical_line_to_graph(-1.5,curve3,color=PURPLE_B) + h3 = self.get_vertical_line_to_graph(-1,curve3,color=PURPLE_B) + h4 = self.get_vertical_line_to_graph(-0.5,curve3,color=PURPLE_B) + h5 = self.get_vertical_line_to_graph(0,curve3,color=PURPLE_B) + h6 = self.get_vertical_line_to_graph(0.5,curve3,color=PURPLE_B) + h7 = self.get_vertical_line_to_graph(1,curve3,color=PURPLE_B) + h8 = self.get_vertical_line_to_graph(1.5,curve3,color=PURPLE_B) + h9 = self.get_vertical_line_to_graph(2,curve3,color=PURPLE_B) + h10 = self.get_vertical_line_to_graph(2.5,curve3,color=PURPLE_B) + + line1.shift(1*LEFT+0.9*UP) + equal.shift(0.3*LEFT+0.2*UP) + f=TextMobject("$f(x)$").scale(0.5).shift(5.6*LEFT+3.2*UP) + g=TextMobject("$g(x)$").scale(0.5).shift(5.6*LEFT+2.4*UP) + fg=TextMobject("$(f + g)(x)$").scale(0.5).shift(2.85*UP+3.3*LEFT) + self.play(FadeOut(add),ShowCreation(equal),ShowCreation(line1),ShowCreation(f),ShowCreation(g),ShowCreation(fg),FadeOut(fx),FadeOut(gx)) + self.wait(1.7) + self.play(ShowCreation(h1),ShowCreation(h2),ShowCreation(h3),ShowCreation(h4),ShowCreation(h5),ShowCreation(h6),ShowCreation(h7),ShowCreation(h8),ShowCreation(h9),ShowCreation(h10)) + curve3 = self.get_graph(lambda x : 1/3*(x**2)+1 + exp(x) + 0.5, x_min=-2,x_max=2.5,color=RED_A) + fgx=TextMobject("$(f + g)(x)$").scale(0.5).shift(1.65*UP+2.4*LEFT) + self.play(ShowCreation(curve3),ShowCreation(fgx)) + sum=TextMobject("$(f + g)(x) = f(x) + g(x)$",color=GOLD).scale(0.65).shift(0.8*UP + 5*LEFT) + rect = Rectangle(height=0.5,width=2) + rect.surround(sum) + self.play(ShowCreation(sum),ShowCreation(rect)) + self.wait(3) \ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py new file mode 100644 index 0000000..97c0e09 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py @@ -0,0 +1,77 @@ +from manimlib.imports import * +from scipy import sin +class Integral_Properties(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 5, + "y_min" : 0, + "y_max" : 6, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color":LIGHT_GRAY, + "x_labeled_nums" : list(range(6)), + "y_labeled_nums" : list(range(6)) + } + def construct(self): + self.setup_axes(animate=False) + curve1 = self.get_graph(lambda x : sin(x), x_min=0,x_max=2.5,color=RED) + curve2 = self.get_graph(lambda x : x, x_min=0,x_max=2.5,color=DARK_BLUE) + curve3 = self.get_graph(lambda x : sin(x) + x, x_min=0,x_max=2.5,color=GREEN) + fx = TextMobject(r"$f(x)$").scale(0.5).shift(1*RIGHT+1.8*DOWN) + gx = TextMobject(r"$g(x)$").scale(0.5).shift(1*RIGHT) + sum = TextMobject(r"$f(x) + g(x)$").scale(0.5).shift(1.3*RIGHT+0.6*UP) + area1 = self.get_area(curve1,0,2.5) + area2 = self.get_area(curve2,0,2.5) + area3 = self.get_area(curve3,0,2.5) + area2.set_fill(color=PURPLE) + area3.set_fill(color=ORANGE) + text1=TextMobject(r"$\int_{0}^{2.5}$ f(x) dx = Area under the curve f(x)",color=BLUE_C).scale(0.7).shift(2.7*RIGHT+3*UP) + text2=TextMobject(r"$\int_{0}^{2.5}$ g(x) dx = Area under the curve g(x)",color=PURPLE_B).scale(0.7).shift(2.7*RIGHT+2.4*UP) + text3=TextMobject(r"Area under the curve f(x) + g(x) = $\int_{0}^{2.5} (f(x) + g(x)) dx$",color=ORANGE).scale(0.7).shift(2.7*RIGHT+1.8*UP) + text4=TextMobject(r"\text{$\int_{0}^{2.5}$ (f(x) + g(x)) dx}",r"\text{ = }",r"\text{ $\int_{0}^{2.5}$ f(x) dx }",r"\text{+}",r"\text{$\int_{0}^{2.5}$ g(x) dx}").scale(0.62).shift(2.7*RIGHT+2.7*UP) + text4[0].set_color(ORANGE) + text4[2].set_color(BLUE_C) + text4[4].set_color(PURPLE_B) + self.play(ShowCreation(curve1), ShowCreation(fx)) + self.wait(1.2) + self.play(ShowCreation(curve2),ShowCreation(gx)) + self.wait(1.2) + self.play(ShowCreation(area1)) + self.play(ShowCreation(text1)) + self.wait(1.5) + self.play(ShowCreation(area2)) + self.play(ShowCreation(text2)) + self.wait(1.5) + self.play(ShowCreation(curve3),ShowCreation(sum)) + self.play(ShowCreation(area3)) + self.play(ShowCreation(text3)) + self.wait(2) + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3)) + self.wait(1) + self.play(ShowCreation(text4)) + self.wait(3) + self.play(FadeOut(curve1),FadeOut(curve2),FadeOut(area1),FadeOut(area2)) + self.wait(1.5) + self.play(FadeOut(text4),FadeOut(area2),FadeOut(curve2),FadeOut(gx),FadeOut(curve3),FadeOut(sum),FadeOut(area3),ShowCreation(curve1),ShowCreation(fx)) + self.wait(1.5) + self.play(ShowCreation(area1),ShowCreation(text1)) + self.wait(1.5) + curve4 = self.get_graph(lambda x : 2*sin(x), x_min=0,x_max=2.5,color=RED) + area4 = self.get_area(curve4,0,2.5) + area4.set_fill(color=YELLOW) + fx2 = TextMobject(r"$2f(x)$").scale(0.7).shift(1*RIGHT+1.2*DOWN) + scalar_mul=TextMobject(r"$\int_{0}^{2.5} ( 2f(x) ) dx$ = 2 $\times$ Area under the curve f(x)",color=YELLOW).scale(0.7).shift(2.7*RIGHT+2.4*UP) + self.play(ShowCreation(curve4),ShowCreation(fx2)) + self.wait(1) + self.play(ShowCreation(area4)) + self.wait(2) + self.play(ShowCreation(scalar_mul)) + self.wait(2) + text5=TextMobject(r"\text{$\int_{0}^{2.5}$ (2 f(x)) dx}",r"\text{ = }",r"\text{2 $\int_{0}^{2.5}$ f(x) dx }").scale(0.67).shift(2.7*RIGHT+2.7*UP) + text5[0].set_color(YELLOW) + text5[2].set_color(BLUE_C) + self.play(FadeOut(text1),FadeOut(scalar_mul)) + self.wait(1) + self.play(ShowCreation(text5)) + self.wait(3) + -- cgit