diff options
Diffstat (limited to 'FSF-2020/calculus/series-and-transformations')
55 files changed, 1815 insertions, 199 deletions
diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md b/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md new file mode 100644 index 0000000..c5d8389 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md @@ -0,0 +1,17 @@ +### Dividing a tone into its constituents +![GIF1](gifs/file1.gif) + +### Colors Analogy +![GIF2](gifs/file2a.gif) + +### Applying the same on Graphs +![GIF3](gifs/file2b.gif) + +### Fourier series for non-periodic functions +![GIF4](gifs/file3.gif) + +### Fourier Series of Square pulse +![GIF5](gifs/file4.gif) + +### Coins Analogy +![GIF6](gifs/file5.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file1.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file1.gif Binary files differnew file mode 100644 index 0000000..d4dc9d7 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file1.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2a.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2a.gif Binary files differnew file mode 100644 index 0000000..8f83bc4 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2a.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2b.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2b.gif Binary files differnew file mode 100644 index 0000000..d68c405 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2b.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif Binary files differnew file mode 100644 index 0000000..533368b --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file4.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file4.gif Binary files differnew file mode 100644 index 0000000..36cd61b --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file4.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file5.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file5.gif Binary files differnew file mode 100644 index 0000000..9757bd6 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file5.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py new file mode 100644 index 0000000..39db6d8 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py @@ -0,0 +1,90 @@ +from manimlib.imports import* +import numpy as np + +# def func(t,n): +# s=0 +# for i in range(1,n+1): +# s+=((-2/(i*np.pi))*((-1)**i)*np.sin(2*np.pi*i*t)) +# return s + + +class intro(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "x_axis_width": 6, + "y_min": -5, + "y_max": 5, + "graph_origin": 10.5*LEFT, + "axes_color": BLUE, + "exclude_zero_label": True, + "x_labeled_nums": range(-2, 3, 1), + } + def func(self,t,n1,n2): + s=0 + for i in range(n1,n2+1): + s+=((-2/(i*np.pi))*((-1)**i)*np.sin(2*np.pi*i*t)) + return s + + def construct(self): + image=ImageMobject('image.png').shift(5.5*LEFT+2.5*UP).scale(1.5) + self.play(ShowCreation(image)) + + self.setup_axes(scalee=1) + + mainGraphs=[ + self.get_graph(lambda x:self.func(x,2,7),x_max=2,x_min=-2).shift(9.3*RIGHT+3*UP).set_color([ORANGE,GREEN_B,RED_E,YELLOW_E,RED_D,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,3,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([GREEN_B,ORANGE,RED_D,YELLOW_E,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,4,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([GREEN_B,YELLOW_E,ORANGE,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,5,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([YELLOW_E,GREEN_B,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,6,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([YELLOW_D,GREEN_B]).scale(1.4), + self.get_graph(lambda x:self.func(x,7,7),x_max=2,x_min=-2,color=GREEN_B).shift(10.8*RIGHT+3*UP).scale(1.4), + ] + self.play(ApplyMethod(mainGraphs[0].shift,1.5*RIGHT)) + + graph1=self.get_graph(lambda x:self.func(x,2,2),x_max=2,x_min=-2,color=RED_E).shift(10.8*RIGHT+3*UP).scale(1.5) + graph2=self.get_graph(lambda x:self.func(x,3,3),x_max=2,x_min=-2,color=RED_D).shift(10.8*RIGHT+3*UP).scale(1.5) + graph3=self.get_graph(lambda x:self.func(x,4,4),x_max=2,x_min=-2,color=ORANGE).shift(10.8*RIGHT+3*UP).scale(1.5) + graph4=self.get_graph(lambda x:self.func(x,5,5),x_max=2,x_min=-2,color=YELLOW_E).shift(10.8*RIGHT+3*UP).scale(1.5) + graph5=self.get_graph(lambda x:self.func(x,6,6),x_max=2,x_min=-2,color=YELLOW_D).shift(10.8*RIGHT+3*UP).scale(1.5) + + coeff=[ + TextMobject("$\\frac { -1 }{ \pi } sin(4\pi t)$").scale(0.5).shift(DOWN+4.6*RIGHT+3*UP).set_color(RED_E), + TextMobject("$\\frac { 2 }{ 3\pi } sin(6\pi t)$").scale(0.5).shift(2*DOWN+4.6*RIGHT+3*UP).set_color(RED_D), + TextMobject("$\\frac { -1 }{ 2\pi } sin(8\pi t)$").scale(0.5).shift(3*DOWN+4.6*RIGHT+3*UP).set_color(ORANGE), + TextMobject("$\\frac { 2 }{ 5\pi } sin(10\pi t)$").scale(0.5).shift(4*DOWN+4.6*RIGHT+3*UP).set_color(YELLOW_E), + TextMobject("$\\frac { -1 }{ 3\pi } sin(12\pi t)$").scale(0.5).shift(5*DOWN+4.6*RIGHT+3*UP).set_color(YELLOW_D), + TextMobject("$\\frac { 2 }{ 7\pi } sin(14\pi t)$").scale(0.5).shift(6*DOWN+4.6*RIGHT+3*UP).set_color(GREEN_B) + ] + + self.wait(0.6) + self.play(ApplyMethod(graph1.shift,1*DOWN),ReplacementTransform(mainGraphs[0],mainGraphs[1])) + self.play(Write(coeff[0])) + self.play(ApplyMethod(graph2.shift,2*DOWN),ReplacementTransform(mainGraphs[1],mainGraphs[2])) + self.play(Write(coeff[1])) + self.play(ApplyMethod(graph3.shift,3*DOWN),ReplacementTransform(mainGraphs[2],mainGraphs[3])) + self.play(Write(coeff[2])) + self.play(ApplyMethod(graph4.shift,4*DOWN),ReplacementTransform(mainGraphs[3],mainGraphs[4])) + self.play(Write(coeff[3])) + self.play(ApplyMethod(graph5.shift,5*DOWN),ReplacementTransform(mainGraphs[4],mainGraphs[5])) + self.play(Write(coeff[4])) + self.play(ApplyMethod(mainGraphs[5].shift,6*DOWN)) + self.play(Write(coeff[5])) + + pluses=[TextMobject("+"),TextMobject("+"),TextMobject("+"),TextMobject("+"),TextMobject("+")] + for t in pluses: + t.scale(0.5).shift((2.2-1.5*pluses.index(t))*LEFT) + + finalGraph=self.get_graph(lambda x:self.func(x,2,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP) + finalGraph.set_color([GREEN_B,YELLOW_D,YELLOW_E,ORANGE,RED_D,RED_E]) + finalGroup=VGroup(graph1,graph2,graph3,graph4,graph5,mainGraphs[5]) + self.play(ReplacementTransform(finalGroup,finalGraph)) + self.play(ApplyMethod(coeff[0].scale,0.7),ApplyMethod(coeff[1].scale,0.7),ApplyMethod(coeff[2].scale,0.7),ApplyMethod(coeff[3].scale,0.7),ApplyMethod(coeff[4].scale,0.7),ApplyMethod(coeff[5].scale,0.7)) + #self.play(ApplyMethod(coeff[0].shift,7*LEFT+1.6*DOWN),ApplyMethod(coeff[1].shift,5.5*LEFT+0.8*DOWN),ApplyMethod(coeff[2].shift,4*LEFT),ApplyMethod(coeff[3].shift,2.5*LEFT+0.8*UP),ApplyMethod(coeff[4].shift,LEFT+1.6*UP),ApplyMethod(coeff[5].shift,0.5*RIGHT+2.4*DOWN)) + self.play(ApplyMethod(coeff[0].shift,7.6*LEFT+2*DOWN),ApplyMethod(coeff[1].shift,6.1*LEFT+DOWN),ApplyMethod(coeff[2].shift,4.6*LEFT),ApplyMethod(coeff[3].shift,3.1*LEFT+UP),ApplyMethod(coeff[4].shift,1.6*LEFT+2*UP),ApplyMethod(coeff[5].shift,0.1*LEFT+3*UP)) + equal=TextMobject("=").scale(1.5).shift(1.5*UP) + self.play(Write(equal)) + self.play(Write(pluses[0]),Write(pluses[1]),Write(pluses[2]),Write(pluses[3]),Write(pluses[4])) + group=VGroup(pluses[0],pluses[1],pluses[2],pluses[3],pluses[4],coeff[0],coeff[1],coeff[2],coeff[3],coeff[4],coeff[5]) + self.play(ApplyMethod(group.scale,1.5)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py new file mode 100644 index 0000000..8f3706b --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py @@ -0,0 +1,165 @@ +from manimlib.imports import* +import numpy as np + +def func(t,n1,n2): + s=0 + for i in range(n1,n2+1): + s+=((-2/(i*np.pi))*((-1)**i)*np.sin(2*np.pi*i*t)) + return s + +class divideColors(GraphScene): + CONFIG = { + "x_min": -2, + "x_max": 2, + "y_min": -1, + "y_max": 1, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "x_labeled_nums": range(-1, 2, 1), + "x_axis_width": 3, + "y_axis_height": 2 + } + def construct(self): + text1a=TextMobject("Consider dividing a","mixture of colors") + text1b=TextMobject("into its","components") + text1a.scale(0.8) + text1b.scale(0.8) + text1a.shift(UP) + text1b.shift(0.3*UP) + text1a.set_color_by_tex_to_color_map({"mixture of colors":[GREEN,RED,BLUE,YELLOW]}) + text1b.set_color_by_tex_to_color_map({"components":GREEN}) + self.play(Write(text1a)) + self.play(FadeIn(text1b)) + self.wait(0.8) + + self.play(FadeOut(text1a),FadeOut(text1b)) + + mainCircle=Circle(radius=1.4,color=BLACK,fill_color=[PURPLE_E,PURPLE_D,RED_B,ORANGE,YELLOW_B,YELLOW_D,GREEN_A,GREEN_C],fill_opacity=0.8) + self.play(ShowCreation(mainCircle)) + self.wait(1) + mainCirclea=Circle(radius=1.4,color=BLACK,fill_color=[RED_B,ORANGE,YELLOW_B,YELLOW_D,GREEN_A,GREEN_C],fill_opacity=0.8) + mainCircleb=Circle(radius=1.4,color=BLACK,fill_color=[YELLOW_B,YELLOW_D,GREEN_A,GREEN_C],fill_opacity=0.8) + mainCirclec=Circle(radius=1.4,color=BLACK,fill_color=[GREEN_A,GREEN_C],fill_opacity=0.8) + mainCircled=Circle(radius=1.4,color=BLACK,fill_color=[],fill_opacity=0.8) + + c1=Circle(radius=0.5,color=PURPLE_E,fill_color=PURPLE_E,fill_opacity=0.8) + c2=Circle(radius=0.5,color=PURPLE_D,fill_color=PURPLE_D,fill_opacity=0.8) + c3=Circle(radius=0.5,color=RED_D,fill_color=RED_B,fill_opacity=0.8) + c4=Circle(radius=0.5,color=ORANGE,fill_color=ORANGE,fill_opacity=0.8) + c5=Circle(radius=0.5,color=YELLOW_B,fill_color=YELLOW_B,fill_opacity=0.8) + c6=Circle(radius=0.5,color=YELLOW_D,fill_color=YELLOW_D,fill_opacity=0.8) + c7=Circle(radius=0.5,color=GREEN_A,fill_color=GREEN_A,fill_opacity=0.8) + c8=Circle(radius=0.5,color=GREEN_C,fill_color=GREEN_C,fill_opacity=0.8) + + self.play(ApplyMethod(c1.shift,3*UP+LEFT),ApplyMethod(c2.shift,3*UP+RIGHT),ReplacementTransform(mainCircle,mainCirclea)) + self.wait(0.8) + + self.play(ApplyMethod(c3.shift,UP+3*LEFT),ApplyMethod(c4.shift,DOWN+3*LEFT),ReplacementTransform(mainCirclea,mainCircleb)) + self.wait(0.8) + + self.play(ApplyMethod(c5.shift,3*DOWN+LEFT),ApplyMethod(c6.shift,3*DOWN+RIGHT),ReplacementTransform(mainCircleb,mainCirclec)) + self.wait(0.8) + + self.play(ApplyMethod(c7.shift,3*RIGHT+UP),ApplyMethod(c8.shift,3*RIGHT+DOWN),ReplacementTransform(mainCirclec,mainCircled)) + self.wait(1) + + text2=TextMobject("Similarly,").scale(0.8).shift(UP).set_color(RED) + + self.play(FadeOut(c1),FadeOut(c2),FadeOut(c3),FadeOut(c4),FadeOut(c5),FadeOut(c6),FadeOut(c7),FadeOut(c8)) + self.play(Write(text2)) + self.wait(0.8) + self.play(FadeOut(text2)) + + + coeff=[ + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=1 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { 2 }{ \pi } sin(2\pi t)$").scale(0.3).shift(RIGHT+UP+4*LEFT+UP), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=2 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { -1 }{ \pi } sin(4\pi t)$").scale(0.3).shift(RIGHT+UP+4*RIGHT+UP), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=3 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { 2 }{ 3\pi } sin(6\pi t)$").scale(0.3).shift(RIGHT+UP+4*LEFT+2*DOWN), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=4 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { -1 }{ 2\pi } sin(8\pi t)$").scale(0.3).shift(RIGHT+UP+4*RIGHT+2*DOWN), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=5 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { 2 }{ 5\pi } sin(10\pi t)$").scale(0.3).shift(RIGHT+UP+2.5*UP), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=6 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { -1 }{ 3\pi } sin(12\pi t)$").scale(0.3).shift(RIGHT+UP+2.5*DOWN), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=7 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + ] + + axes=[] + self.setup_axes(scalee=1) + axes.append(self.axes) + graphs=[self.get_graph(lambda x:func(x,1,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GREEN_E,GREEN_C,GOLD_E,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,2,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GREEN_C,GOLD_E,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,3,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GOLD_E,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,4,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,5,24),x_min=-1,x_max=1).set_color([DARK_BROWN,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,6,24),x_min=-1,x_max=1).set_color([DARK_BROWN,RED_C]), + self.get_graph(lambda x:func(x,7,24),x_min=-1,x_max=1).set_color(DARK_BROWN) + ] + #self.y_axis_label="$\\frac { 2 }{ \pi } sin(2\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph1=self.get_graph(lambda x:func(x,1,1),x_min=-1,x_max=1,color=GREEN_E) + #self.y_axis_label="$\\frac { -1 }{ \pi } sin(4\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph2=self.get_graph(lambda x:func(x,2,2),x_min=-1,x_max=1,color=GREEN_C) + #self.y_axis_label="$\\frac { 2 }{ 3\pi } sin(6\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph3=self.get_graph(lambda x:func(x,3,3),x_min=-1,x_max=1,color=GOLD_E) + #self.y_axis_label="$\\frac { -1 }{ 2\pi } sin(8\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph4=self.get_graph(lambda x:func(x,4,4),x_min=-1,x_max=1,color=GOLD_C) + #self.y_axis_label="$\\frac { 2 }{ 5\pi } sin(10\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph5=self.get_graph(lambda x:func(x,5,5),x_min=-1,x_max=1,color=ORANGE) + #self.y_axis_label="$\\frac { -1 }{ 3\pi } sin(12\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph6=self.get_graph(lambda x:func(x,6,6),x_min=-1,x_max=1,color=RED_C) + + groups=[VGroup(axes[1],graph1),VGroup(axes[2],graph2),VGroup(axes[3],graph3),VGroup(axes[4],graph4), + VGroup(axes[5],graph5),VGroup(axes[6],graph6)] + + self.play(ShowCreation(graphs[0])) + self.play(Write(coeff[0])) + self.wait(1) + # self.play(ApplyMethod(axes[0].scale,0.4),ApplyMethod(graphs[0].scale,0.4),ApplyMethod(axes[1].scale,0.4), + # ApplyMethod(axes[2].scale,0.4),ApplyMethod(axes[3].scale,0.4), + # ApplyMethod(axes[4].scale,0.4),ApplyMethod(axes[5].scale,0.4),ApplyMethod(axes[6].scale,0.4)) + self.play(ReplacementTransform(graphs[0],graphs[1]),ApplyMethod(groups[0].shift,4*LEFT+UP),ReplacementTransform(coeff[0],coeff[2]),FadeIn(coeff[1])) + self.play(ReplacementTransform(graphs[1],graphs[2]),ApplyMethod(groups[1].shift,4*RIGHT+UP),ReplacementTransform(coeff[2],coeff[4]),FadeIn(coeff[3])) + self.play(ReplacementTransform(graphs[2],graphs[3]),ApplyMethod(groups[2].shift,4*LEFT+2*DOWN),ReplacementTransform(coeff[4],coeff[6]),FadeIn(coeff[5])) + self.play(ReplacementTransform(graphs[3],graphs[4]),ApplyMethod(groups[3].shift,4*RIGHT+2*DOWN),ReplacementTransform(coeff[6],coeff[8]),FadeIn(coeff[7])) + self.play(ReplacementTransform(graphs[4],graphs[5]),ApplyMethod(groups[4].shift,2.5*UP),ReplacementTransform(coeff[8],coeff[10]),FadeIn(coeff[9])) + self.play(ReplacementTransform(graphs[5],graphs[6]),ApplyMethod(groups[5].shift,2.5*DOWN),ReplacementTransform(coeff[10],coeff[12]),FadeIn(coeff[11])) + + # self.play(ReplacementTransform(graphs[0],graphs[1]),ApplyMethod(groups[0].shift,3*LEFT)) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + + + + self.wait(2) + # self.play(ReplacementTransform(function,const)) + # self.play(ShowCreation(sinx),ShowCreation(cosx)) + # self.play(ShowCreation(sin2x),ShowCreation(cos2x)) + # self.play(ShowCreation(sin3x),ShowCreation(cos3x)) + # self.play(ShowCreation(sin4x),ShowCreation(cos4x)) + # sintext=TextMobject("Infinite","sines").shift(5*RIGHT).set_color_by_tex_to_color_map({"Infinite":[YELLOW,RED],"sines":BLUE}) + # costext=TextMobject("Infinite","cosines").shift(5*LEFT).set_color_by_tex_to_color_map({"Infinite":[YELLOW,RED],"cosines":BLUE}) + # sintext.scale(0.6) + # costext.scale(0.6) + # self.play(FadeIn(sintext),FadeIn(costext)) + # self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py new file mode 100644 index 0000000..f23e54f --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py @@ -0,0 +1,133 @@ +from manimlib.imports import * +import numpy as np + +class compare(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "x_axis_width": 6, + "y_min": -5, + "y_max": 5, + "y_axis_label":"$\\frac { { x }^{ 2 } }{ 2 } $", + "graph_origin": ORIGIN, + "axes_color": BLUE, + "exclude_zero_label": True, + "x_labeled_nums": range(-2, 3, 1), + } + def returnPairLines(self,left,right,y_each_unit): + lineLeft=DashedLine(start=(0,5*y_each_unit,0),end=(0,-5*y_each_unit,0)).shift(left) + lineRight=DashedLine(start=(0,5*y_each_unit,0),end=(0,-5*y_each_unit,0)).shift(right) + return lineLeft,lineRight + + def resultFunc(self,x,n,l): + s=(l**2)/6 + for n in range(1,n+1): + s+=(2*((-1)**n))*((l**2)*np.cos(n*np.pi*x/l))*(1/((np.pi**2)*(n**2))) + return s + + def returnPartFunction(self,left,right): + return self.get_graph(lambda x:(x**2)/2,x_min=left,x_max=right,color=RED) + + def returnPartResult(self,l,n): + return self.get_graph(lambda x:self.resultFunc(x,n,l),x_min=-3,x_max=3,color=RED) + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + axes=[] + self.setup_axes(animate=True,scalee=1) + axes.append(self.axes) + partFunction1=self.returnPartFunction(-1,1).shift(4*LEFT) + partFunction2=self.returnPartFunction(-2,2).shift(4*LEFT) + functionText=TextMobject("$\\frac { { x }^{ 2 } }{ 2 } $") + function=self.get_graph(lambda x:(x**2)/2,x_min=-3,x_max=3,color=GREEN) + text1=TextMobject("Non-Periodic function").scale(0.5).shift(3*DOWN+3*RIGHT).set_color(RED) + self.play(ShowCreation(function)) + self.play(FadeIn(text1)) + self.wait(1) + self.play(FadeOut(text1)) + self.play(ApplyMethod(axes[0].shift,4*LEFT),ApplyMethod(function.shift,4*LEFT)) + text2=TextMobject("For a","given","interval of $x$,").scale(0.5).shift(2.5*RIGHT+UP).set_color_by_tex_to_color_map({"given":YELLOW,"interval of $x$,":BLUE}) + text3=TextMobject("We can get the","Fourier Series","of that","particular part!").scale(0.4).shift(2.5*RIGHT+0.5*UP).set_color_by_tex_to_color_map({"particular part!":YELLOW,"Fourier Series":RED}) + self.play(Write(text2)) + left,right=self.returnPairLines((4+x_each_unit)*LEFT,(4-x_each_unit)*LEFT,y_each_unit) + self.play(ShowCreation(left),ShowCreation(right)) + self.play(Write(text3)) + self.wait(0.5) + self.play(FadeOut(text2),FadeOut(text3)) + self.graph_origin=3.5*RIGHT + self.y_axis_label="$\\frac { { l }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ \infty }{ \\frac { 2{ (-1) }^{ n }{ l }^{ 2 }cos(\\frac { n\pi x }{ l } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$" + self.setup_axes(animate=True,scalee=1) + axes.append(self.axes) + coeffResult=[ + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 1 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 3 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 5 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 7 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 9 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 11 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 13 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW) + ] + result1a=self.returnPartResult(1,1) + result1b=self.returnPartResult(1,3) + result1c=self.returnPartResult(1,5) + result1d=self.returnPartResult(1,7) + result1e=self.returnPartResult(1,9) + result1f=self.returnPartResult(1,11) + result1g=self.returnPartResult(1,13) + self.play(ApplyMethod(partFunction1.shift,0.2*UP)) + self.wait(0.5) + self.play(ReplacementTransform(partFunction1,result1a),Write(coeffResult[0])) + self.play(ReplacementTransform(result1a,result1b),ReplacementTransform(coeffResult[0],coeffResult[1])) + self.play(ReplacementTransform(result1b,result1c),ReplacementTransform(coeffResult[1],coeffResult[2])) + self.play(ReplacementTransform(result1c,result1d),ReplacementTransform(coeffResult[2],coeffResult[3])) + self.play(ReplacementTransform(result1d,result1e),ReplacementTransform(coeffResult[3],coeffResult[4])) + self.play(ReplacementTransform(result1e,result1f),ReplacementTransform(coeffResult[4],coeffResult[5])) + self.play(ReplacementTransform(result1f,result1g),ReplacementTransform(coeffResult[5],coeffResult[6])) + + text4=TextMobject("Here the","obtained function","will always be","periodic","with period equal to the chosen interval").scale(0.4).shift(3.3*DOWN).set_color_by_tex_to_color_map({"obtained function":YELLOW,"periodic":RED}) + self.play(Write(text4)) + + self.wait(0.8) + + self.play(FadeOut(text4)) + text5=TextMobject("As we","increase","the","interval of $x$,").scale(0.5).shift(3*DOWN).set_color_by_tex_to_color_map({"increase":RED,"interval of $x$,":YELLOW}) + text6=TextMobject("We get","approximation","for","higher intervals!").scale(0.5).shift(3.5*DOWN).set_color_by_tex_to_color_map({"approximation":GREEN,"higher intervals!":YELLOW}) + self.play(Write(text5)) + self.play(Write(text6)) + result2=self.returnPartResult(1.5,20) + result3=self.returnPartResult(2,20) + result4=self.returnPartResult(2.5,20) + result5=self.returnPartResult(3,20) + finalCoeff=coeffResult[6] + coeffResult=[ + TextMobject("$\\frac { { 1.5 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 1.5 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + TextMobject("$\\frac { { 2.5 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 2.5 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + TextMobject("$\\frac { { 3 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 3 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + ] + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result1g,result2),ReplacementTransform(finalCoeff,coeffResult[0])) + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result2,result3),ReplacementTransform(coeffResult[0],coeffResult[1])) + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result3,result4),ReplacementTransform(coeffResult[1],coeffResult[2])) + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result4,result5),ReplacementTransform(coeffResult[2],coeffResult[3])) + + + # coeffResult=[ + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 1 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 4 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 10 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # ] + # result2a=self.returnPartResult(2,1) + # result2b=self.returnPartResult(2,4) + # result2c=self.returnPartResult(2,10) + # result2d=self.returnPartResult(2,20) + + # self.play(ReplacementTransform(partFunction2,result2a),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.play(ReplacementTransform(result2a,result2b),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.play(ReplacementTransform(result2b,result2c),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.play(ReplacementTransform(result2c,result2d),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.wait(0.5) + + + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py new file mode 100644 index 0000000..5d33fbe --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py @@ -0,0 +1,92 @@ +from manimlib.imports import * +import numpy as np + +def returnSum(k,x): + summ=0 + for i in range(1,k+1,2): + summ+=((np.sin(2*np.pi*i*x))/i) + return summ + +def returnFunc(self,k): + graph=self.get_graph(lambda x:(4/np.pi)*returnSum(k,x),color=WHITE,x_max=1,x_min=-1) + return graph + +class fourierSeries(GraphScene,MovingCameraScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "x_axis_width": 13, + "y_min": -3, + "y_max": 3, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$x$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "x_labeled_nums": range(-2, 3, 1), + } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + equation=TextMobject("$f(x)=\\frac { 4 }{ \pi } \sum _{ k=1,3,5.. }^{ \infty }{ \\frac { 1 }{ k } \sin { 2\pi kx } }$").shift(5*RIGHT+3*UP).set_color(RED).scale(0.4) + self.add(equation) + self.setup_axes(animate=True) + line1=Line(start=(-x_each_unit,y_each_unit,0),end=(-(1/2)*x_each_unit,y_each_unit,0),color=RED) + line2=Line(start=(-(1/2)*x_each_unit,y_each_unit,0),end=(-(1/2)*x_each_unit,-y_each_unit,0),color=RED) + line3=Line(start=(-(1/2)*x_each_unit,-y_each_unit,0),end=(0,-y_each_unit,0),color=RED) + line4=Line(start=(0,-y_each_unit,0),end=(0,y_each_unit,0),color=RED) + line5=Line(start=(0,y_each_unit,0),end=((1/2)*x_each_unit,y_each_unit,0),color=RED) + line6=Line(start=((1/2)*x_each_unit,y_each_unit,0),end=((1/2)*x_each_unit,-y_each_unit,0),color=RED) + line7=Line(start=((1/2)*x_each_unit,-y_each_unit,0),end=(x_each_unit,-y_each_unit,0),color=RED) + self.play(ShowCreation(line1)) + self.play(ShowCreation(line2)) + self.play(ShowCreation(line3)) + self.play(ShowCreation(line4)) + self.play(ShowCreation(line5)) + self.play(ShowCreation(line6)) + self.play(ShowCreation(line7)) + self.wait(0.5) + + labels=[ + TextMobject("$f_{ k=1 }(x)$"), + TextMobject("$f_{ k=3 }(x)$"), + TextMobject("$f_{ k=5 }(x)$"), + TextMobject("$f_{ k=7 }(x)$"), + TextMobject("$f_{ k=9 }(x)$"), + TextMobject("$f_{ k=11 }(x)$"), + TextMobject("$f_{ k=13 }(x)$"), + TextMobject("$f_{ k=15 }(x)$"), + TextMobject("$f_{ k=17 }(x)$"), + TextMobject("$f_{ k=19 }(x)$"), + TextMobject("$f_{ k=85 }(x)$") + ] + p=0 + for i in range(1,20,2): + if(i==1): + graphInitial=returnFunc(self,1) + label=labels[p].scale(0.5).shift(y_each_unit*1.5*UP+RIGHT*x_each_unit*0.3) + self.play(ShowCreation(graphInitial),Write(labels[0])) + old=graphInitial + oldLabel=label + else: + graph=returnFunc(self,i) + graphLabel=labels[p].scale(0.5).shift(y_each_unit*1.5*UP+RIGHT*x_each_unit*0.3) + self.play(ReplacementTransform(old,graph),ReplacementTransform(oldLabel,graphLabel)) + old=graph + oldLabel=graphLabel + p+=1 + graphFinal=returnFunc(self,85) + labelFinal=labels[10].scale(0.5).shift(y_each_unit*1.5*UP+RIGHT*x_each_unit*0.3) + self.play(FadeOut(old),FadeOut(oldLabel)) + self.play(ShowCreation(graphFinal),Write(labelFinal)) + self.wait(1) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 2.25,self.camera_frame.move_to, y_each_unit*UP+RIGHT*x_each_unit*0.3) + self.wait(1) + self.play(self.camera_frame.set_width,14,self.camera_frame.move_to,0) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py new file mode 100644 index 0000000..10ee889 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py @@ -0,0 +1,225 @@ +from manimlib.imports import* +import math +import numpy as np + +class coinsAnalogy(Scene): + def construct(self): + text1=TextMobject("Consider we have","Rs 39").shift(2*UP).scale(0.75).set_color_by_tex_to_color_map({"Rs 39":[YELLOW,PURPLE]}) + text2=TextMobject("and we want to represent them only in terms of","Rs 2","and","Rs 5").shift(UP).scale(0.6).set_color_by_tex_to_color_map({"Rs 2":YELLOW,"Rs 5":PURPLE}) + text3=TextMobject("How many","Rs 2 coins","and","Rs 5 coins","do","we need?").scale(0.8).set_color_by_tex_to_color_map({"Rs 2 coins":YELLOW,"Rs 5 coins":PURPLE,"we need?":RED}) + text4=TextMobject("We","perform","the following!").scale(0.75).shift(DOWN).set_color_by_tex_to_color_map({"perform":GREEN}) + + self.play(FadeIn(text1)) + self.wait(0.6) + self.play(Write(text2)) + self.wait(0.5) + self.play(Write(text3)) + self.wait(0.7) + self.play(FadeIn(text4)) + self.wait(1) + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3),FadeOut(text4)) + + g1=self.group("Rs 39") + g1.shift(3*LEFT+0.75*UP) + l1=self.line() + l1.shift(4*LEFT) + f1=self.fiveGroup() + t1=self.twoGroup() + f1.shift(3.5*LEFT+0.7*DOWN) + andT=TextMobject("and").next_to(f1,buff=-0.1).scale(0.3) + t1.next_to(andT,buff=0.2) + equal1=TextMobject("$=$") + equal1.next_to(l1,buff=0.2) + + self.play(ShowCreation(g1)) + self.play(ShowCreation(l1)) + self.play(ShowCreation(f1),Write(andT),ShowCreation(t1)) + self.play(ShowCreation(equal1)) + self.wait(0.6) + + f2=self.fiveGroup().next_to(equal1,buff=0.4) + multiple1=TextMobject("$X7$","$\quad +$").next_to(f2,buff=0.2).set_color_by_tex_to_color_map({"$X7$":PURPLE}) + l2=self.line().next_to(multiple1,buff=0.4) + g2=self.group("Rs 4").shift(2.75*RIGHT+0.75*UP) + t2=self.twoGroup().shift(2.75*RIGHT+0.7*DOWN) + + self.play(ShowCreation(f2)) + self.play(ShowCreation(multiple1)) + self.play(ShowCreation(g2)) + self.play(ShowCreation(l2)) + self.play(ShowCreation(t2)) + self.wait(1) + + tempGrup=VGroup(g2,l2,t2) + + t3=self.twoGroup().next_to(multiple1,buff=0.4) + multiple2=TextMobject("$X2$").next_to(t3,buff=0.2).set_color_by_tex_to_color_map({"$X2$":YELLOW}) + + self.play(ReplacementTransform(tempGrup,t3)) + self.play(Write(multiple2)) + self.wait(2) + + def line(self): + l=Line(start=[0,0,0],end=[2,0,0]) + return l + + def twoGroup(self): + two=Circle(radius=0.25,color=BLACK,fill_color=YELLOW,fill_opacity=0.7) + twoText=TextMobject("Rs 2").scale(0.25).set_color(BLACK) + twoGrup=VGroup(two,twoText) + return twoGrup + + def fiveGroup(self): + five=Circle(radius=0.35,color=BLACK,fill_color=PURPLE,fill_opacity=0.7) + fiveText=TextMobject("Rs 5").scale(0.3).set_color(BLACK) + fiveGrup=VGroup(five,fiveText) + return fiveGrup + + def group(self,money): + coins=[ + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.75), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.8), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.7), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.75), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.8), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.7) + ] + coinsText=TextMobject(money).set_color(BLACK) + coinsText.scale(0.35) + + coins[1].shift(0.2*RIGHT+0.2*UP) + coins[2].shift(0.2*RIGHT+0.1*DOWN) + coins[3].shift(0.2*DOWN) + coins[4].shift(0.2*UP+0.2*LEFT) + coins[5].shift(0.2*LEFT+0.1*LEFT) + + coinsGrup=VGroup(coins[0],coins[1],coins[2],coins[3],coins[4],coins[5],coinsText) + return coinsGrup + +class divideFunction(GraphScene): + CONFIG = { + "x_min": -6, + "x_max": 6, + "y_min": -300, + "y_max": 300, + "x_tick_frequency": 2, + "y_tick_frequency": 300, + "graph_origin": 3*LEFT+1.5*UP+6*LEFT, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "x_labeled_nums": [-6,0,6], + "y_labeled_nums": [-300,0,300], + "x_axis_width": 1.5, + "y_axis_height": 1 + } + def line(self): + l=Line(start=[0,0,0],end=[2,0,0]) + return l + def construct(self): + text1=TextMobject("Similarly,").scale(0.8).shift(UP).set_color(RED) + text2=TextMobject("To find the amount of","each frequency","present in","$f(x)$").scale(0.6).set_color_by_tex_to_color_map({"each frequency":[YELLOW,RED],"$f(x)$":RED}) + text3=TextMobject("We","perform","the following!").scale(0.7).shift(DOWN).set_color_by_tex_to_color_map({"perform":GREEN}) + + self.play(FadeIn(text1)) + self.wait(0.6) + self.play(Write(text2)) + self.wait(0.7) + self.play(FadeIn(text3)) + + self.wait(1) + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3)) + + boxUP=Square(side_length=1.7,fill_color=BLUE_C,fill_opacity=0.5,color=BLACK).shift(3*LEFT+UP) + boxDOWN=Square(side_length=1.7,fill_color=BLUE_C,fill_opacity=0.5,color=BLACK).shift(3*LEFT+DOWN) + + axes=[] + self.graph_origin=10*LEFT+1.5*UP + self.setup_axes(scalee=1) + axes.append(self.axes) + fx=self.get_graph(lambda x:math.pow(x,3)-math.pow(x,2)+x-2,x_min=-2*math.pi,x_max=2*math.pi,color=RED).shift(7*RIGHT+0.5*DOWN) + + l=self.line().shift(4*LEFT) + + self.graph_origin=10*LEFT+1.5*DOWN + self.y_min=-2 + self.y_max=1 + self.y_tick_frequency=1 + self.y_labeled_nums=[-1,0,1] + self.setup_axes(scalee=1) + axes.append(self.axes) + sinx=self.get_graph(lambda x:np.sin(x),x_min=-2*math.pi,x_max=2*math.pi,color=PURPLE_C).shift(7*RIGHT+0.5*UP) + + equal=TextMobject("$=$").next_to(l,buff=0.3) + result1=TextMobject("Amount of").scale(0.6).next_to(equal,buff=0.3) + boxRIGHT=Square(side_length=1.7,fill_color=GOLD_B,fill_opacity=0.5,color=BLACK).next_to(result1,buff=0.2) + self.graph_origin=10*LEFT + sinxResult=self.get_graph(lambda x:np.sin(x),color=PURPLE_C).next_to(result1,buff=0.3) + axes.append(self.axes) + result2=TextMobject("in","$f(x)$").scale(0.6).next_to(sinxResult,buff=0.2).set_color_by_tex_to_color_map({"$f(x)$":RED}) + + self.play(FadeIn(boxUP)) + self.play(ShowCreation(fx)) + self.play(ShowCreation(l)) + self.play(FadeIn(boxDOWN)) + self.play(ShowCreation(sinx)) + self.wait(0.4) + self.play(Write(equal)) + self.play(Write(result1)) + self.play(FadeIn(boxRIGHT)) + self.play(ShowCreation(sinxResult)) + self.play(Write(result2)) + aText1=TextMobject("and").scale(0.65).shift(4*RIGHT+2*DOWN).set_color(GREEN) + self.play(Write(aText1)) + self.wait(0.7) + + self.graph_origin=10*LEFT + cos4x=self.get_graph(lambda x:np.cos(4*x),color=PURPLE_A).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + cos4xResult=self.get_graph(lambda x:np.cos(4*x),color=PURPLE_A).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(sinx,cos4x),ReplacementTransform(sinxResult,cos4xResult)) + self.wait(0.7) + + soText=TextMobject("And so on..!").scale(0.65).shift(4*RIGHT+2*DOWN).set_color(GREEN) + self.play(ReplacementTransform(aText1,soText)) + + self.graph_origin=10*LEFT + cosx=self.get_graph(lambda x:np.cos(x),color=GREEN_E).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + cosxResult=self.get_graph(lambda x:np.cos(x),color=GREEN_E).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(cos4x,cosx),ReplacementTransform(cos4xResult,cosxResult)) + + self.graph_origin=10*LEFT + cos3x=self.get_graph(lambda x:np.cos(3*x),color=GREEN_C).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + cos3xResult=self.get_graph(lambda x:np.cos(3*x),color=GREEN_C).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(cosx,cos3x),ReplacementTransform(cosxResult,cos3xResult)) + + self.graph_origin=10*LEFT + const=self.get_graph(lambda x:1,color=YELLOW_B).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + constResult=self.get_graph(lambda x:1,color=YELLOW_B).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(cos3x,const),ReplacementTransform(cos3xResult,constResult)) + + self.wait(1) + + self.play(FadeOut(soText),FadeOut(const),FadeOut(constResult),FadeOut(l),FadeOut(equal),FadeOut(result1),FadeOut(result2),FadeOut(fx),FadeOut(boxRIGHT),FadeOut(boxUP),FadeOut(boxDOWN)) + + finalFormula1=TexMobject(r"Therefore,",r"F(s)",r"=",r"\int _{ -\infty }^{ \infty }",r"{f(t)",r"\over",r"sines",r"\enspace and \enspace",r"cosines}",r"dt }").scale(0.7).set_color_by_tex_to_color_map({"F(s)":RED,"sines":BLUE,"cosines}":YELLOW,"{f(t)":GREEN}) + finalFormula2=TexMobject(r"F(s)",r"=",r"\int _{ -\infty }^{ \infty }",r"{f(t)",r"\over",r"{ e }^",r"{ i\theta }}",r"dt }").set_color_by_tex_to_color_map({"F(s)":RED,"{f(t)":GREEN}) + subFinalFormula=TextMobject("where","$\\theta =2\pi st$").scale(0.5).shift(DOWN+2*RIGHT).set_color_by_tex_to_color_map({"$\\theta =2\pi st$":RED}) + + self.play(Write(finalFormula1)) + self.wait(1) + self.play(ReplacementTransform(finalFormula1,finalFormula2)) + self.play(Write(subFinalFormula)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/README.md b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/README.md new file mode 100644 index 0000000..d4cd8bc --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/README.md @@ -0,0 +1,21 @@ +### Basic Intuition +![GIF1](gifs/basicIntuition.gif) + +### Solving D.E.intuition +![GIF2](gifs/solvingDEintuition.gif) + +### Unit Step Function +#### Part1 +![GIF3](gifs/unitStepFunction.gif) +#### Part2 +![GIF4](gifs/UnitStepFunctionExample.gif) +#### Part3 +![GIF5](gifs/LtransformUnitStepFunction.gif) + +### Dirac Delta Function +#### Part1 +![GIF6](gifs/DiracFunction.gif) +#### Part2 +![GIF7](gifs/DiracFunctionFormation.gif) +#### Part3 +![GIF8](gifs/LtransformDiracFunction.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file1_laplaceTransformBasic.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file1_laplaceTransformBasic.py new file mode 100644 index 0000000..7a37ae8 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file1_laplaceTransformBasic.py @@ -0,0 +1,67 @@ +from manimlib.imports import * +import pylatex + +class depict(Scene): + def construct(self): + square=Square(side_length=2,fill_color=GREEN,fill_opacity=0.7) + inputText=TextMobject("$t$") + squareText=TextMobject("$f$") + outputText=TextMobject("$f($","$t$","$)$") + + inputText.scale(0.8) + outputText.scale(0.8) + inputText.shift(2.1*LEFT) + outputText.shift(1.5*RIGHT) + squareText.scale(1.2) + + outputText.set_color_by_tex_to_color_map({"$t$":RED}) + + self.play(ShowCreation(square)) + self.play(FadeIn(squareText)) + self.add(inputText) + self.wait(0.5) + self.play(ApplyMethod(inputText.shift,0.9*RIGHT)) + self.play(FadeOut(inputText),FadeIn(outputText)) + self.play(ApplyMethod(outputText.shift,1.5*RIGHT)) + self.wait(1) + + fOutGroup=VGroup(outputText,square,squareText) + self.play(ApplyMethod(fOutGroup.scale,0.6)) + self.play(ApplyMethod(fOutGroup.shift,5*LEFT)) + self.wait(0.8) + laplaceSquare=Square(side_length=3,fill_color=BLUE,fill_opacity=0.6) + laplaceText=TextMobject("$\mathscr{L}$") + outText=TextMobject("$F($","$s$","$)$") + outText.scale(0.8) + outText.set_color_by_tex_to_color_map({"$s$":RED}) + laplaceText.scale(1.5) + outText.shift(2*RIGHT) + self.play(ShowCreation(laplaceSquare)) + self.play(FadeIn(laplaceText)) + self.wait(0.5) + self.play(ApplyMethod(outputText.shift,RIGHT)) + self.play(FadeOut(outputText),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,2*RIGHT)) + self.wait(1) + + updatedOutputText=TextMobject("$f($","$t$","$)$") + updatedOutputText.shift(2.5*LEFT) + updatedOutputText.set_color_by_tex_to_color_map({"$t$":RED}) + updatedInputText=TextMobject("$t$") + updatedInputText.shift(6*LEFT) + updatedInputText.scale(0.7) + updatedOutputText.scale(0.7) + + self.play(FadeIn(updatedInputText),FadeIn(updatedOutputText)) + self.wait(0.5) + + timeText=TextMobject("Time Domain") + frequencyText=TextMobject("Frequency Domain") + timeText.set_color(RED) + frequencyText.set_color(RED) + timeText.scale(0.35) + frequencyText.scale(0.35) + timeText.shift(2.5*LEFT+0.5*DOWN) + frequencyText.shift(4*RIGHT+0.5*DOWN) + self.play(Write(frequencyText),Write(timeText)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file2_differentialEqSimplification.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file2_differentialEqSimplification.py new file mode 100644 index 0000000..33e9173 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file2_differentialEqSimplification.py @@ -0,0 +1,78 @@ +from manimlib.imports import * +import pylatex + +class scene(Scene): + def construct(self): + normalSq=Square(side_length=2,fill_color=BLUE,fill_opacity=0.6) + normalSqText=TextMobject("$\mathscr{L}$") + inputText=TextMobject("$f($","$y'(t)$","$)$") + outputText=TextMobject("$F($","$s$","$)$") + + inputText.scale(0.7) + outputText.scale(0.7) + inputText.shift(2.5*LEFT) + outputText.shift(1.7*RIGHT) + normalSq.scale(1.2) + + inputText.set_color_by_tex_to_color_map({"$y'(t)$":RED}) + outputText.set_color_by_tex_to_color_map({"$s$":RED}) + + self.play(ShowCreation(normalSq)) + self.play(FadeIn(normalSqText)) + self.add(inputText) + self.wait(0.5) + self.play(ApplyMethod(inputText.shift,0.7*RIGHT)) + self.play(FadeOut(inputText),FadeIn(outputText)) + self.play(ApplyMethod(outputText.shift,RIGHT)) + self.wait(1) + + group1=VGroup(outputText,normalSq,normalSqText) + self.play(ApplyMethod(group1.scale,0.6)) + self.play(ApplyMethod(group1.shift,4.7*LEFT)) + self.wait(0.6) + + inverseSq=Square(side_length=3,fill_color=GREEN,fill_opacity=0.6) + inverseSqText=TextMobject("$\mathscr{L}^{ -1 }$") + outText=TextMobject("$f($","$y(t)$","$)$") + inverseSqText.scale(0.7) + outText.scale(0.7) + outText.set_color_by_tex_to_color_map({"$y(t)$":RED}) + self.play(ShowCreation(inverseSq)) + self.play(FadeIn(inverseSqText)) + self.wait(0.5) + outText.shift(2*RIGHT) + self.play(ApplyMethod(outputText.shift,RIGHT)) + self.play(FadeOut(outputText),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,2*RIGHT)) + self.wait(1) + + updatedOutputText=TextMobject("$F($","$s$","$)$") + updatedOutputText.shift(2.5*LEFT) + updatedInputText=TextMobject("$f($","$y'(t)$","$)$") + updatedInputText.shift(6*LEFT) + updatedInputText.scale(0.7) + updatedOutputText.scale(0.7) + updatedOutputText.set_color_by_tex_to_color_map({"$s$":RED}) + updatedInputText.set_color_by_tex_to_color_map({"$y'(t)$":RED}) + + self.play(FadeIn(updatedInputText),FadeIn(updatedOutputText)) + self.wait(0.5) + + deText=TextMobject("Differential Equation") + deinterTexta=TextMobject("Transformed D.E") + deinterTextb=TextMobject("(Easy to simplify)!") + deOutText=TextMobject("Solution of D.E") + deText.set_color(RED) + deinterTexta.set_color(RED) + deOutText.set_color(RED) + deinterTextb.set_color(PURPLE_C) + deText.scale(0.35) + deinterTexta.scale(0.35) + deinterTextb.scale(0.35) + deOutText.scale(0.35) + deText.shift(6*LEFT+0.5*DOWN) + deinterTexta.shift(2.6*LEFT+0.5*DOWN) + deinterTextb.shift(2.6*LEFT+0.8*DOWN) + deOutText.shift(4*RIGHT+0.5*DOWN) + self.play(Write(deText),Write(deinterTexta),Write(deinterTextb),Write(deOutText)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file3_unitStepFunction.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file3_unitStepFunction.py new file mode 100644 index 0000000..53c5f14 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file3_unitStepFunction.py @@ -0,0 +1,168 @@ +from manimlib.imports import * +import math +import pylatex + +class intro(GraphScene,Scene): + CONFIG = { + "x_min": -8, + "x_max": 8, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN+DOWN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$t$", + "y_axis_label": "$\mu_{c}(t)$", + "exclude_zero_label": True, + "y_axis_height":4, + "x_axis_width":7 + } + def setup(self): + GraphScene.setup(self) + Scene.setup(self) + def construct(self): + introText=TextMobject("Unit","Step","Function") + introText.set_color_by_tex_to_color_map({"Unit":BLUE,"Step":YELLOW}) + introText.scale(0.8) + self.play(Write(introText)) + self.wait(0.5) + self.play(ApplyMethod(introText.shift,3*UP)) + formulaa=TextMobject("$\mu _{ c }(t)=0\quad$","$t<c$") + formulab=TextMobject("$\mu _{ c }(t)=1\quad$","$t\ge c$") + formulaa.set_color_by_tex_to_color_map({"$t<c$":RED}) + formulab.set_color_by_tex_to_color_map({"$t\ge c$":RED}) + formulaa.scale(0.8) + formulab.scale(0.8) + formulab.shift(0.5*DOWN) + self.play(FadeIn(formulaa),FadeIn(formulab)) + self.wait(1) + + self.play(FadeOut(formulaa),FadeOut(formulab)) + + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + self.setup_axes(animate=True) + self.wait(0.8) + + c=TextMobject("c") + c.scale(0.5) + c.set_color(RED) + c.shift(self.graph_origin+3*x_each_unit*RIGHT+y_each_unit*0.4*DOWN) + self.play(Write(c)) + smallCircle=Circle(radius=0.03,fill_color=WHITE,color=WHITE) + smallCircle.shift(self.graph_origin+3*x_each_unit*RIGHT) + downLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*3*x_each_unit,color=BLUE) + upLine=Line(start=self.graph_origin+3*x_each_unit*RIGHT+y_each_unit*UP,end=self.graph_origin+8*x_each_unit*RIGHT+y_each_unit*UP,color=BLUE) + + self.play(Write(downLine)) + self.play(Write(smallCircle)) + self.play(Write(upLine)) + self.wait(1.5) + self.play(FadeOut(self.axes),FadeOut(smallCircle),FadeOut(c),FadeOut(upLine),FadeOut(downLine),FadeOut(introText)) + self.wait(0.5) + + +class example(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 8, + "y_min": -4, + "y_max": 5, + "graph_origin": ORIGIN+LEFT+DOWN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "y_axis_height":4, + "x_axis_width":6 + } + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + text1=TextMobject("Consider the","formation","of","following graph!"," (a part of $f(t))$") + text1.set_color_by_tex_to_color_map({"following graph!":BLUE,"formation":YELLOW}) + text1.scale(0.6) + ft=TextMobject("$f(t)$") + ftminusc=TextMobject("$f(t-c)$") + final=TextMobject("$\mu_{c}(t)f(t-c)$") + ft.set_color(PURPLE_C) + ftminusc.set_color(PURPLE_C) + final.set_color(PURPLE_C) + c=TextMobject("c") + c.scale(0.5) + c.set_color(RED) + c.shift(self.graph_origin+RIGHT*x_each_unit*3+DOWN*y_each_unit*0.5) + ft.scale(0.5) + ftminusc.scale(0.5) + final.scale(0.5) + + self.play(Write(text1)) + self.play(ApplyMethod(text1.shift,3*UP)) + + self.setup_axes(animate=True) + y=self.get_graph(lambda x:(math.pow((x-3),3)/3)-math.pow((x-3),2)-(x-3)+3,x_min=3,x_max=7,color=RED) + f=self.get_graph(lambda x:(math.pow(x,3)/3)-math.pow(x,2)-x+3,x_min=-2,x_max=4,color=RED) + yFull=self.get_graph(lambda x:(math.pow((x-3),3)/3)-math.pow((x-3),2)-(x-3)+3,x_min=1,x_max=7,color=RED) + + self.play(Write(c)) + self.play(ShowCreation(y)) + self.wait(1) + self.play(FadeOut(self.axes),FadeOut(y),FadeOut(c)) + + belowText1=TextMobject("Consider its","normal form",", $f(t)$") + belowText1.set_color_by_tex_to_color_map({"normal form":BLUE}) + belowText2=TextMobject("Shift it to","x=c") + belowText2.set_color_by_tex_to_color_map({"x=c":RED}) + belowText3a=TextMobject("Now to remove the","left part","of","$c$,") + belowText3a.set_color_by_tex_to_color_map({"left part":YELLOW,"$c$,":YELLOW}) + belowText3b=TextMobject("multiply it with the","unit step function",", $\mu_{c}(t)$") + belowText3b.set_color_by_tex_to_color_map({"unit step function":BLUE}) + belowText1.scale(0.4) + belowText2.scale(0.4) + belowText3a.scale(0.4) + belowText3b.scale(0.4) + belowText1.shift(2.7*DOWN+4*RIGHT) + belowText2.shift(2.7*DOWN+4*RIGHT) + belowText3a.shift(2.7*DOWN+4*RIGHT) + belowText3b.shift(3.1*DOWN+4*RIGHT) + self.setup_axes(animate=True) + self.play(Write(belowText1)) + self.play(ShowCreation(f)) + ft.shift(1.5*RIGHT+UP*0.8) + self.play(FadeIn(ft)) + self.play(ReplacementTransform(belowText1,belowText2)) + ftminusc.shift(3.5*RIGHT+UP*0.8) + self.play(ReplacementTransform(f,yFull),ReplacementTransform(ft,ftminusc),Write(c)) + self.wait(1) + + self.play(ReplacementTransform(belowText2,belowText3a)) + self.play(Write(belowText3b)) + final.shift(3.7*RIGHT+UP*0.8) + self.play(ReplacementTransform(ftminusc,final),ReplacementTransform(yFull,y)) + + finalText=TextMobject("We got our required Graph!") + finalText.scale(0.55) + finalText.shift(2.7*DOWN+4*RIGHT) + self.play(FadeOut(belowText3b),ReplacementTransform(belowText3a,finalText)) + self.wait(1.5) + + self.play(FadeOut(finalText),FadeOut(text1)) + + graphGrup=VGroup(self.axes,c,final,y) + self.play(ApplyMethod(graphGrup.scale,0.45)) + box=Square(side_length=2,fill_color=BLUE,fill_opacity=0.7) + boxtext=TextMobject("$\mathscr{L}$") + boxtext.scale(0.8) + self.play(ApplyMethod(graphGrup.shift,5.5*LEFT+UP)) + self.play(ShowCreation(box),Write(boxtext)) + outText=TextMobject("${ e }^{ -cs }F(s)$") + outText.set_color(GREEN) + outText.scale(0.65) + outText.shift(2*RIGHT) + self.play(ApplyMethod(graphGrup.shift,2*RIGHT)) + self.play(FadeOut(graphGrup),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,RIGHT)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py new file mode 100644 index 0000000..0c7f8e4 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py @@ -0,0 +1,61 @@ +from manimlib.imports import * +import math +import pylatex + +class intro(GraphScene,Scene): + CONFIG = { + "x_min": -9, + "x_max": 9, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN+DOWN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$x$", + "y_axis_label": "$\delta (x)$", + "y_axis_height":4, + "x_axis_width":7 + } + def setup(self): + GraphScene.setup(self) + Scene.setup(self) + def construct(self): + introText=TextMobject("Dirac","Delta","Function") + introText.set_color_by_tex_to_color_map({"Dirac":BLUE,"Delta":YELLOW}) + introText.scale(0.8) + self.play(Write(introText)) + self.wait(0.5) + self.play(ApplyMethod(introText.shift,3*UP)) + formulaa=TextMobject("$\delta (x)=\infty$","$x=0$") + formulab=TextMobject("$\delta (x)=0$","$x\\neq 0$") + formulaa.set_color_by_tex_to_color_map({"$x=0$":RED}) + formulab.set_color_by_tex_to_color_map({"$x\\neq 0$":RED}) + formulaa.scale(0.8) + formulab.scale(0.8) + formulab.shift(0.5*DOWN) + self.play(FadeIn(formulaa),FadeIn(formulab)) + self.wait(1) + + self.play(FadeOut(formulaa),FadeOut(formulab)) + + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + self.setup_axes(animate=True) + self.wait(0.8) + + functionUpLine=Line(start=self.graph_origin,end=self.graph_origin+UP*y_each_unit*5,color=RED) + functionDownLine=Line(start=self.graph_origin+UP*y_each_unit*5,end=self.graph_origin,color=RED) + functinLeftLine=Line(start=self.graph_origin+LEFT*x_each_unit*9,end=self.graph_origin,color=RED) + functionRightLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*x_each_unit*9,color=RED) + functionUpLine.shift(0.02*LEFT) + functionRightLine.shift(0.02*RIGHT) + + self.play(ShowCreation(functinLeftLine)) + self.play(ShowCreation(functionUpLine)) + self.play(ShowCreation(functionDownLine)) + self.play(ShowCreation(functionRightLine)) + self.wait(1.5) + + self.play(FadeOut(self.axes),FadeOut(introText),FadeOut(functinLeftLine),FadeOut(functionRightLine),FadeOut(functionUpLine),FadeOut(functionDownLine)) + self.wait(0.5) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file5_formationDiracDeltaFunction.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file5_formationDiracDeltaFunction.py new file mode 100644 index 0000000..565a7cb --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file5_formationDiracDeltaFunction.py @@ -0,0 +1,142 @@ +from manimlib.imports import * +import math +import pylatex + +def func(x,t): + if(x>-t and x<t): + return 1/(2*t) + else: + return 0 + + +class formation(GraphScene): + CONFIG = { + "x_min": -7, + "x_max": 7, + "y_min": -2, + "y_max": 2, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "y_labeled_nums":range(-2,3), + "y_axis_height":4, + "x_axis_width":7 + } + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + text1=TextMobject("Consider the","following function's graph!") + text1.set_color_by_tex_to_color_map({"following function's graph!":BLUE}) + text1.scale(0.6) + + equation1=TextMobject("$\delta _{ \\tau }(t)=\\frac { 1 }{ 2\\tau } \quad$","$-\\tau <t<\\tau$") + equation2=TextMobject("$\delta _{ \\tau }(t)=0\quad \quad$","$t\in (-\infty ,-\\tau ]\cup [\\tau ,\infty )$") + equation1.scale(0.7) + equation2.scale(0.7) + equation1.shift(0.2*UP) + equation2.shift(0.4*DOWN+RIGHT*0.8) + equation1.set_color_by_tex_to_color_map({"$-\\tau <t<\\tau$":RED}) + equation2.set_color_by_tex_to_color_map({"$t\in (-\infty ,-\\tau ]\cup [\\tau ,\infty )$":RED}) + + self.play(Write(text1)) + self.play(ApplyMethod(text1.shift,3*UP)) + self.play(Write(equation1)) + self.play(Write(equation2)) + self.wait(1) + + self.play(FadeOut(equation1),FadeOut(equation2)) + self.wait(0.5) + + pointes1=TextMobject("$-\\tau$") + pointes2=TextMobject("$\\tau$") + pointes1.set_color(RED) + pointes2.set_color(RED) + pointes1.scale(0.65) + pointes2.scale(0.65) + + bottomText1=TextMobject("Here","$\int _{ -\infty }^{ \infty }{ \delta _{ \\tau }(t)dt }$","=","$1$") + bottomText2=TextMobject("Now as","$\\tau \\rightarrow 0$") + bottomText3=TextMobject("We get our","Dirac Function!") + bottomText4=TextMobject("i.e.","$\lim _{ \\tau \\rightarrow 0 }{ \delta _{ \\tau }(t)}$","$=$","$\delta (t)$") + textFinal=TextMobject("Area=1") + bottomText1.set_color_by_tex_to_color_map({"$\int _{ -\infty }^{ \infty }{ \delta _{ \\tau }(t)dt }$":BLUE,"$1$":YELLOW}) + textFinal.set_color(PURPLE_B) + bottomText2.set_color_by_tex_to_color_map({"$\\tau \\rightarrow 0$":YELLOW}) + bottomText3.set_color_by_tex_to_color_map({"Dirac Function!":RED}) + bottomText4.set_color_by_tex_to_color_map({"$\lim _{ \\tau \\rightarrow 0 }{ \delta _{ \\tau }(t)}$":BLUE,"$\delta (t)$":YELLOW}) + + bottomText1.scale(0.6) + bottomText2.scale(0.6) + bottomText3.scale(0.6) + bottomText4.scale(0.6) + textFinal.scale(0.9) + + bottomText1.shift(4*RIGHT+3*DOWN) + bottomText2.shift(4*RIGHT+3*DOWN) + bottomText3.shift(4*RIGHT+3*DOWN) + bottomText4.shift(4*RIGHT+3*DOWN) + textFinal.shift(5*RIGHT+2*UP) + + self.setup_axes(animate=True) + + graphs=[ + self.get_graph(lambda x:func(x,3),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,2),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,1),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.5),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.3),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.15),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.05),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.01),x_min=-7,x_max=7,color=RED) + ] + pointes1.shift(self.graph_origin+3*LEFT*x_each_unit+0.4*DOWN*y_each_unit) + pointes2.shift(self.graph_origin+3*RIGHT*x_each_unit+0.4*DOWN*y_each_unit) + + functionUpLine=Line(start=self.graph_origin,end=self.graph_origin+UP*y_each_unit*2,color=RED) + functionDownLine=Line(start=self.graph_origin+UP*y_each_unit*2,end=self.graph_origin,color=RED) + functinLeftLine=Line(start=self.graph_origin+LEFT*x_each_unit*7,end=self.graph_origin,color=RED) + functionRightLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*x_each_unit*7,color=RED) + functionUpLine.shift(0.02*LEFT) + functionRightLine.shift(0.02*RIGHT) + + self.play(Write(pointes1),Write(pointes2),ShowCreation(graphs[0])) + self.play(Write(bottomText1)) + self.wait(0.7) + + self.play(ReplacementTransform(bottomText1,bottomText2),Write(textFinal)) + self.wait(0.5) + self.play(ReplacementTransform(graphs[0],graphs[1]),ApplyMethod(pointes2.shift,LEFT*x_each_unit),ApplyMethod(pointes1.shift,RIGHT*x_each_unit)) + self.play(ReplacementTransform(graphs[1],graphs[2]),ApplyMethod(pointes2.shift,LEFT*x_each_unit),ApplyMethod(pointes1.shift,RIGHT*x_each_unit)) + self.wait(0.5) + self.play(ReplacementTransform(graphs[2],graphs[3]),FadeOut(pointes1),FadeOut(pointes2)) + self.play(ReplacementTransform(graphs[3],graphs[4])) + self.wait(1) + self.play(ReplacementTransform(bottomText2,bottomText3)) + self.wait(1) + self.play(FadeOut(graphs[4]),ReplacementTransform(bottomText3,bottomText4)) + self.wait(0.5) + self.play(ShowCreation(functinLeftLine)) + self.play(ShowCreation(functionUpLine)) + self.play(ShowCreation(functionDownLine)) + self.play(ShowCreation(functionRightLine)) + self.wait(2) + + self.play(FadeOut(bottomText4),FadeOut(textFinal)) + graphGrup=VGroup(self.axes,functinLeftLine,functionDownLine,functionRightLine,functionUpLine) + self.play(ApplyMethod(graphGrup.scale,0.5)) + box=Square(side_length=2,fill_color=BLUE,fill_opacity=0.6) + boxtext=TextMobject("$\mathscr{L}$") + boxtext.scale(0.8) + self.play(ApplyMethod(graphGrup.shift,4.9*LEFT)) + self.play(ShowCreation(box),Write(boxtext)) + outText=TextMobject("$f(0)$") + outText.set_color(GREEN) + outText.scale(0.65) + outText.shift(1.5*RIGHT) + self.play(ApplyMethod(graphGrup.shift,2*RIGHT)) + self.play(FadeOut(graphGrup),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,RIGHT)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunction.gif Binary files differnew file mode 100644 index 0000000..cb62ed2 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunctionFormation.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunctionFormation.gif Binary files differnew file mode 100644 index 0000000..23acbe9 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunctionFormation.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformDiracFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformDiracFunction.gif Binary files differnew file mode 100644 index 0000000..b1d50b5 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformDiracFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformUnitStepFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformUnitStepFunction.gif Binary files differnew file mode 100644 index 0000000..ccbd791 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformUnitStepFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/UnitStepFunctionExample.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/UnitStepFunctionExample.gif Binary files differnew file mode 100644 index 0000000..2b1c38f --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/UnitStepFunctionExample.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/basicIntuition.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/basicIntuition.gif Binary files differnew file mode 100644 index 0000000..3b974bb --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/basicIntuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/solvingDEintuition.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/solvingDEintuition.gif Binary files differnew file mode 100644 index 0000000..9883a8c --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/solvingDEintuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/unitStepFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/unitStepFunction.gif Binary files differnew file mode 100644 index 0000000..16757e1 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/unitStepFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf b/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf Binary files differindex 04ed6d5..9fc409b 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf +++ b/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/README.md b/FSF-2020/calculus/series-and-transformations/Power Series/README.md new file mode 100644 index 0000000..6885837 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/README.md @@ -0,0 +1,14 @@ +#### Convergence Intuition +![GIF1a](gifs/file1_convergence_Intuition.gif) + +#### Convergence Intuition +![GIF1b](gifs/file1a_convergence_Intuition.gif) + +#### Convergence of a function +![GIF2](gifs/file2_convergence_of_a_function.gif) + +#### Radius and IntervalOfConvergence +![GIF3](gifs/file3_radius_and_intervalOfConvergence.gif) + +#### Uniform Convergence +![GIF4](gifs/file4_UniformConvergence.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1_convergence_Intuition.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1_convergence_Intuition.gif Binary files differnew file mode 100644 index 0000000..292d19d --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1_convergence_Intuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1a_convergence_Intuition.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1a_convergence_Intuition.gif Binary files differnew file mode 100644 index 0000000..287cbd1 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1a_convergence_Intuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file2_convergence_of_a_function.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file2_convergence_of_a_function.gif Binary files differnew file mode 100644 index 0000000..78d6014 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file2_convergence_of_a_function.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file3_radius_and_intervalOfConvergence.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file3_radius_and_intervalOfConvergence.gif Binary files differnew file mode 100644 index 0000000..a45c75e --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file3_radius_and_intervalOfConvergence.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4_UniformConvergence.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4_UniformConvergence.gif Binary files differnew file mode 100644 index 0000000..7b635d7 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4_UniformConvergence.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script1.py b/FSF-2020/calculus/series-and-transformations/Power Series/script1.py deleted file mode 100644 index 28eb07c..0000000 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script1.py +++ /dev/null @@ -1,128 +0,0 @@ -from manimlib.imports import * - - -def formFormula(coeff_list,variable_list): - coeff_list=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] - variable_list=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] - coeff_list[0].shift(2.2*UP+1.6*LEFT) - for i in range(0,3): - coeff_list[i].set_color(GOLD_A) - variable_list[i].next_to(coeff_list[i],buff=0.1) - if i!=2: - coeff_list[i+1].next_to(variable_list[i],buff=0.1) - dots=TextMobject("...") - dots.next_to(variable_list[2]) - expansion=VGroup(coeff_list[0],coeff_list[1],coeff_list[2],variable_list[0],variable_list[1],variable_list[2],dots) - expansion.scale(0.7) - return expansion - -class pieChart(Scene): - def construct(self): - circle1=Circle(radius=3,color=BLUE) - powerText=TextMobject("Power Series") - powerText.scale(0.8) - self.play(FadeIn(powerText)) - self.play(ShowCreation(circle1)) - self.wait(1) - - powerGroup=VGroup(circle1,powerText) - - self.play(ApplyMethod(powerGroup.scale,0.5)) - self.play(ApplyMethod(powerGroup.move_to,2.2*UP)) - self.wait(0.5) - expansion_power_coeff=[] - variables_power=[] - expansion_power=formFormula(expansion_power_coeff,variables_power) - self.play(ReplacementTransform(powerText,expansion_power)) - self.wait(1) - - circle2=Circle(radius=1.5) - circle2.shift(2.2*UP) - expansion_geo_coeff=[0]*3 - variables_geo=[0]*3 - arrow1_2=Line(start=0.7*UP,end=2.5*LEFT) - expansion_geo_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] - for i in range(0,3): - expansion_geo_coeff[i].set_color(GOLD_A) - variables_geo=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] - expansion_geo_coeff[0].shift(2.2*UP+1.6*LEFT) - for i in range(0,3): - variables_geo[i].next_to(expansion_geo_coeff[i],buff=0.1) - if i!=2: - expansion_geo_coeff[i+1].next_to(variables_geo[i],buff=0.1) - dots=TextMobject("...") - dots.next_to(variables_geo[2]) - expansion_geo=VGroup(expansion_geo_coeff[0],expansion_geo_coeff[1],expansion_geo_coeff[2],variables_geo[0],variables_geo[1],variables_geo[2],dots) - expansion_geo.scale(0.7) - - self.play(ApplyMethod(circle2.shift,4*LEFT+2.5*DOWN),ApplyMethod(expansion_geo.shift,4*LEFT+2.5*DOWN)) - self.add(arrow1_2) - self.wait(1) - - ones=[TextMobject("1"),TextMobject("1"),TextMobject("1")] - for i in range(0,3): - ones[i].set_color(GOLD_A) - ones[0].shift(0.3*DOWN,5*LEFT) - ones[1].next_to(ones[0],buff=0.5) - ones[2].next_to(ones[1],buff=0.7) - self.play(ReplacementTransform(expansion_geo_coeff[0],ones[0]),ReplacementTransform(expansion_geo_coeff[1],ones[1]),ReplacementTransform(expansion_geo_coeff[2],ones[2])) - self.wait(1) - expansion_geo=VGroup(ones[0],ones[1],ones[2],variables_geo[0],variables_geo[1],variables_geo[2],dots) - - expansion_geo_final=TextMobject("$1+x+{ x }^{ 2 }..$") - expansion_geo_final.scale(0.8) - expansion_geo_final.shift(0.3*DOWN+4*LEFT) - self.play(ReplacementTransform(expansion_geo,expansion_geo_final)) - self.wait(1) - - circle3=Circle(radius=1.5,color=GREEN) - circle3.shift(2.2*UP) - expansion_taylor_coeff=[0]*3 - variables_taylor=[0]*3 - arrow1_3=Line(start=0.7*UP,end=DOWN*0.3) - expansion_taylor_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] - for i in range(0,3): - expansion_taylor_coeff[i].set_color(GOLD_A) - variables_taylor=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] - expansion_taylor_coeff[0].shift(2.2*UP+1.6*LEFT) - for i in range(0,3): - variables_taylor[i].next_to(expansion_taylor_coeff[i],buff=0.1) - if i!=2: - expansion_taylor_coeff[i+1].next_to(variables_taylor[i],buff=0.1) - dots=TextMobject("...") - dots.next_to(variables_taylor[2]) - expansion_taylor=VGroup(expansion_taylor_coeff[0],expansion_taylor_coeff[1],expansion_taylor_coeff[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots) - expansion_taylor.scale(0.7) - - self.play(ApplyMethod(circle3.shift,4*DOWN),ApplyMethod(expansion_taylor.shift,4*DOWN)) - self.add(arrow1_3) - self.wait(1) - - differentials=[TextMobject("$f(0)$"),TextMobject("${ f'\left( 0 \\right) }$"),TextMobject("$\\frac { f''\left( 0 \\right) }{ 2! }$")] - for i in range(0,3): - differentials[i].set_color(GOLD_A) - differentials[0].shift(1.8*DOWN+1.15*LEFT) - differentials[1].shift(1.8*DOWN+0.45*LEFT) - differentials[2].shift(1.8*DOWN+0.45*RIGHT) - differentials[0].scale(0.35) - differentials[1].scale(0.35) - differentials[2].scale(0.35) - self.play(ReplacementTransform(expansion_taylor_coeff[0],differentials[0]),ReplacementTransform(expansion_taylor_coeff[1],differentials[1]),ReplacementTransform(expansion_taylor_coeff[2],differentials[2])) - self.wait(2) - expansion_taylor_final=VGroup(differentials[0],differentials[1],differentials[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots) - - self.play(FadeOut(expansion_geo_final),FadeOut(expansion_taylor_final)) - geoText=TextMobject("Geometric Series") - geoText.scale(0.7) - geoText.shift(4*LEFT+0.3*DOWN) - taylorText=TextMobject("Taylor Series") - taylorText.scale(0.7) - taylorText.shift(1.8*DOWN) - self.play(FadeIn(geoText),FadeIn(taylorText)) - self.wait(1) - - soOntext=TextMobject("So on..!") - soOntext.shift(4*RIGHT) - soOntext.scale(0.8) - self.play(FadeIn(soOntext)) - self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script2.py b/FSF-2020/calculus/series-and-transformations/Power Series/video1_convergence_Intuition.py index 72356c6..66f48f9 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script2.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video1_convergence_Intuition.py @@ -11,23 +11,36 @@ class convergence(Scene): self.play(ApplyMethod(originalFormula.shift,2.7*UP)) self.wait(1) - terms=["$a_{ 0 }$","$a_{ 1 }x$","$a_{ 2 }x^{ 2 }$","$a_{ 3 }x^{ 3 }$","$a_{ 4 }x^{ 4 }$","$a_{ 5 }x^{ 5 }$","$a_{ 6 }x^{ 6 }$","$a_{ 7 }x^{ 7 }$","$a_{ 8 }x^{ 8 }$","$a_{ 9 }x^{ 9 }$","$a_{ 10 }x^{ 10 }$","$a_{ 11 }x^{ 11 }$"] + colors=[PURPLE_E,PURPLE_D,MAROON_D,RED_E,RED_D,RED_C,ORANGE,YELLOW_E,YELLOW_D,YELLOW_B] + terms=["$a_{ 0 }$","$a_{ 1 }x$","$a_{ 2 }x^{ 2 }$","$a_{ 3 }x^{ 3 }$","$a_{ 4 }x^{ 4 }$","$a_{ 5 }x^{ 5 }$","$a_{ 6 }x^{ 6 }$","$a_{ 7 }x^{ 7 }$","$a_{ 8 }x^{ 8 }$","$a_{ 9 }x^{ 9 }$"] termsTogetherString="+".join(terms) - termsTogether=TextMobject(termsTogetherString+"...") + #termsTogether=TextMobject(termsTogetherString+"...") + termsTogether=TextMobject("$a_{ 0 }$","+","$a_{ 1 }x$","+","$a_{ 2 }x^{ 2 }$","+","$a_{ 3 }x^{ 3 }$","+","$a_{ 4 }x^{ 4 }$","+","$a_{ 5 }x^{ 5 }$","+","$a_{ 6 }x^{ 6 }$","+","$a_{ 7 }x^{ 7 }$","+","$a_{ 8 }x^{ 8 }$","+","$a_{ 9 }x^{ 9 }$","+..") + termsTogether.set_color_by_tex_to_color_map({"$a_{ 0 }$":colors[0], + "$a_{ 1 }x$":colors[1], + "$a_{ 2 }x^{ 2 }$":colors[2], + "$a_{ 3 }x^{ 3 }$":colors[3], + "$a_{ 4 }x^{ 4 }$":colors[4], + "$a_{ 5 }x^{ 5 }$":colors[5], + "$a_{ 6 }x^{ 6 }$":colors[6], + "$a_{ 7 }x^{ 7 }$":colors[7], + "$a_{ 8 }x^{ 8 }$":colors[8], + "$a_{ 9 }x^{ 9 }$":colors[9]}) termsTogether.scale(0.8) termsTogether.shift(2.7*UP) self.play(ReplacementTransform(originalFormula,termsTogether)) self.wait(1) - termMobjectRect=[0]*12 - termMobject=TextMobject(terms[0]) + termMobjectRect=[0]*10 + termMobject=TextMobject(terms[0]).set_color(colors[0]) termMobject.shift(2.7*UP+6.2*LEFT) - for i in range(1,13): + for i in range(1,11): termMobjectOld=termMobject termMobjectOld.scale(0.8) - if(i<12): + if(i<10): termMobject=TextMobject(terms[i]) - termMobject.next_to(termMobjectOld) + termMobject.set_color(colors[i]) + termMobject.next_to(termMobjectOld,buff=0.5) if(i==1): rectDefine=TextMobject("Here","each rectangle","represents the","value of the term") rectDefine.set_color_by_tex_to_color_map({"each rectangle":BLUE,"value of the term":YELLOW}) @@ -50,7 +63,7 @@ class convergence(Scene): self.play(ReplacementTransform(ratio,inequality)) self.wait(1) #self.play(ApplyMethod(termMobjectOld.move_to,(2-0.3*i)*DOWN+RIGHT*0.2*i)) - termMobjectRect[i-1]=Rectangle(height=0.1,width=(5-0.4*i)) + termMobjectRect[i-1]=Rectangle(height=0.1,width=(4.2-0.4*i),color=colors[i-1]) termMobjectRect[i-1].move_to((2-0.2*i)*DOWN+RIGHT*0.2*i) #rectangles[p] = termMobjectRect #p+=1 @@ -58,8 +71,8 @@ class convergence(Scene): uparrow=TextMobject("$\\uparrow$") uparrow.set_color(GREEN) - uparrow.scale(6) - uparrow.shift(4*RIGHT+0.5*DOWN) + uparrow.scale(5) + uparrow.shift(4*RIGHT+0.7*DOWN) self.play(ShowCreation(uparrow)) self.wait(1) @@ -72,9 +85,9 @@ class convergence(Scene): self.play(FadeOut(converges),FadeOut(uparrow),FadeOut(inequality)) self.wait(0.5) - rect=VGroup(termMobjectRect[0],termMobjectRect[1],termMobjectRect[2],termMobjectRect[3],termMobjectRect[4],termMobjectRect[5],termMobjectRect[6],termMobjectRect[7],termMobjectRect[8],termMobjectRect[9],termMobjectRect[10],termMobjectRect[11]) + rect=VGroup(termMobjectRect[0],termMobjectRect[1],termMobjectRect[2],termMobjectRect[3],termMobjectRect[4],termMobjectRect[5],termMobjectRect[6],termMobjectRect[7],termMobjectRect[8],termMobjectRect[9]) self.play(ApplyMethod(rect.scale,0.2)) - for i in range(0,12): + for i in range(0,10): self.play(ApplyMethod(termMobjectRect[i].shift,i*0.04*DOWN+(11-(3-0.11*i)*i)*LEFT*0.3)) func=TextMobject("$\\approx$","$f(x)$") func.set_color_by_tex_to_color_map({"$f(x)$":RED}) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script3.py b/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_of_a_function.py index f710f42..19b8b8b 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script3.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_of_a_function.py @@ -69,10 +69,10 @@ class graphScene(GraphScene): eqText[i].scale(0.6) eqText[i].set_color(BLUE) eqText[i].shift(ORIGIN+UP*2*y_each_unit+RIGHT*3.3*x_each_unit) - eqTextTerm=TextMobject("And so on..!") - eqTextTerm.set_color(BLUE) - eqTextTerm.scale(0.6) - eqTextTerm.shift(ORIGIN+UP*2*y_each_unit+3*RIGHT*x_each_unit) + # eqTextTerm=TextMobject("And so on..!") + # eqTextTerm.set_color(BLUE) + # eqTextTerm.scale(0.6) + # eqTextTerm.shift(ORIGIN+UP*2*y_each_unit+3*RIGHT*x_each_unit) equation1 = self.get_graph(lambda x : 1,color = RED,x_min = -8,x_max=8) equation2 = self.get_graph(lambda x : 1-math.pow(x,2),color = RED,x_min = -1.7,x_max=1.7) equation3 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4),color = RED,x_min = -1.6,x_max=1.6) @@ -106,7 +106,7 @@ class graphScene(GraphScene): self.play(ReplacementTransform(equation3,equation4),ReplacementTransform(eqText[2],eqText[3])) self.wait(0.3) self.play(FadeOut(eqText[3])) - self.play(FadeIn(eqTextTerm)) + #self.play(FadeIn(eqTextTerm)) self.play(Write(textBtwAnim1),Write(textBtwAnim2)) self.play(FadeIn(textBtwAnim3)) self.play(ReplacementTransform(equation4,equation5)) @@ -122,7 +122,7 @@ class graphScene(GraphScene): self.play(ReplacementTransform(equation9,equation10)) self.wait(1) - self.play(FadeOut(textBtwAnim1),FadeOut(textBtwAnim2),FadeOut(textBtwAnim3),FadeOut(equation10),FadeOut(eqTextTerm)) + self.play(FadeOut(textBtwAnim1),FadeOut(textBtwAnim2),FadeOut(textBtwAnim3),FadeOut(equation10)) self.wait(1) convergeLine=Line(start=ORIGIN+x_each_unit*LEFT,end=ORIGIN+x_each_unit*RIGHT,color=WHITE) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script4.py b/FSF-2020/calculus/series-and-transformations/Power Series/video3_radius_and_intervalOfConvergence.py index 412d20c..f35fea8 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script4.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video3_radius_and_intervalOfConvergence.py @@ -3,7 +3,7 @@ import math class intro(Scene): def construct(self): - introText1=TextMobject("Consider the","above","example..") + introText1=TextMobject("Consider the example","above",) introText1.scale(0.8) introText1.set_color_by_tex_to_color_map({"above":YELLOW}) self.play(Write(introText1)) @@ -24,12 +24,13 @@ class graphScene(GraphScene,MovingCameraScene): "x_labeled_nums": range(-1, 2, 1), "y_labeled_nums": range(0,2,1), "y_axis_height":7, - "x_axis_width":7 + "x_axis_width":7, } def setup(self): GraphScene.setup(self) MovingCameraScene.setup(self) + def construct(self): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) @@ -74,15 +75,14 @@ class graphScene(GraphScene,MovingCameraScene): radiusText=TextMobject("Radius of convergence") radiusText.scale(0.14) radiusText.shift(ORIGIN+RIGHT*x_each_unit*0.45+DOWN*y_each_unit*0.2) - + #self.activate_zooming(animate=True) self.play(Write(radiusText)) self.wait(0.6) self.camera_frame.save_state() - self.camera_frame.set_width(5.5) - self.play(self.camera_frame.move_to, ORIGIN) + self.play(self.camera_frame.set_width,5.5) self.wait(1) - self.camera_frame.set_width(14) + self.play(self.camera_frame.set_width,14) self.wait(1.3) self.play(FadeOut(radiusText),FadeOut(circle),FadeOut(movingPoint)) @@ -101,8 +101,13 @@ class graphScene(GraphScene,MovingCameraScene): self.wait(0.6) self.camera_frame.save_state() - self.camera_frame.set_width(5.5) - self.play(self.camera_frame.move_to, ORIGIN) + self.play(self.camera_frame.set_width,5.5) self.wait(1) - self.camera_frame.set_width(14) - self.wait(1.5) + self.play(self.camera_frame.set_width,14) + self.wait(1.3) + # self.camera_frame.save_state() + # self.camera_frame.set_width(5.5) + # self.play(self.camera_frame.move_to, ORIGIN) + # self.wait(1) + # self.camera_frame.set_width(14) + # self.wait(1.5) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script5.py b/FSF-2020/calculus/series-and-transformations/Power Series/video4_UniformConvergence.py index e9681aa..1f3e26c 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script5.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video4_UniformConvergence.py @@ -3,19 +3,19 @@ import math class uniformlyConvergent(Scene): def construct(self): - introText1=TextMobject("Again consider the","above","example") + #introText1=TextMobject("Again consider the","above","example") introText2=TextMobject("Let","$g(x)=\\frac { 1 }{ 1+{ x }^{ 2 } }$","and","x=0.5 $\in$(-1,1)") introText3=TextMobject("Lets analyse..","!") - introText1.scale(0.8) + #introText1.scale(0.8) introText2.scale(0.7) introText3.scale(0.9) introText3.shift(DOWN) - introText1.set_color_by_tex_to_color_map({"above":YELLOW}) + #introText1.set_color_by_tex_to_color_map({"above":YELLOW}) introText2.set_color_by_tex_to_color_map({"$g(x)=\\frac { 1 }{ 1+{ x }^{ 2 } }$":BLUE,"x=0.5 $\in$(-1,1)":YELLOW}) introText3.set_color_by_tex_to_color_map({"!":GREEN}) - self.play(Write(introText1)) - self.wait(0.5) - self.play(FadeOut(introText1)) + #self.play(Write(introText1)) + #self.wait(0.5) + #self.play(FadeOut(introText1)) self.play(Write(introText2)) self.play(FadeIn(introText3)) self.wait(2) @@ -45,7 +45,7 @@ def makeLines(x,numPoints,x_each_unit,y_each_unit): lines[i]=Line(start=ORIGIN+RIGHT*x_each_unit*i+UP*y_each_unit*y,end=ORIGIN+RIGHT*x_each_unit*(i+1)+UP*y_each_unit*y_next,color=RED) return lines -class graphScene(GraphScene,MovingCameraScene): +class graphScene(GraphScene,ZoomedScene): CONFIG = { "x_min": -6, "x_max": 6, @@ -58,12 +58,15 @@ class graphScene(GraphScene,MovingCameraScene): "y_axis_label": "$f(\\frac{1}{2})_k$", "exclude_zero_label": True, "x_axis_width":7, - "y_axis_height":7 + "y_axis_height":7, + "zoomed_camera_frame_starting_position": 0.5*UP+0.5*RIGHT, + "zoom_factor": 0.4, } def setup(self): GraphScene.setup(self) - MovingCameraScene.setup(self) + #MovingCameraScene.setup(self) + ZoomedScene.setup(self) def construct(self): @@ -87,6 +90,14 @@ class graphScene(GraphScene,MovingCameraScene): makeSeries(0.5,points,x_each_unit,y_each_unit) lines=makeLines(0.5,6,x_each_unit,y_each_unit) + func1=TextMobject("$g(x)=\\frac { 1 }{ 1+{ x }^{ 2 } }$") + func2=TextMobject("x=0.5 $\in$(-1,1)") + func1.scale(0.4) + func2.scale(0.4) + func1.shift(5.3*LEFT+3.3*UP) + func2.shift(5.3*LEFT+2.9*UP) + self.add(func1) + self.add(func2) self.add(sequence) self.add(formula) @@ -95,22 +106,26 @@ class graphScene(GraphScene,MovingCameraScene): self.add(fLineText) for p in points: self.add(p) + self.setup() + self.activate_zooming(animate=True) for p in range(0,5): self.play(Write(lines[p])) - self.wait(0.5) - self.camera_frame.save_state() - self.camera_frame.set_width(0.6) - self.play(self.camera_frame.move_to, points[0]) - self.wait(0.4) - self.play(self.camera_frame.move_to, points[1]) - self.wait(0.4) - self.play(self.camera_frame.move_to, points[2]) - self.wait(0.3) - self.play(self.camera_frame.move_to, points[3]) - self.wait(1) - self.play(self.camera_frame.move_to,ORIGIN) - self.camera_frame.set_width(14) + # self.wait(0.5) + # self.camera_frame.save_state() + # self.camera_frame.set_width(0.6) + # self.play(self.camera_frame.move_to, points[0]) + # self.wait(0.4) + # self.play(self.camera_frame.move_to, points[1]) + # self.wait(0.4) + # self.play(self.camera_frame.move_to, points[2]) + # self.wait(0.3) + # self.play(self.camera_frame.move_to, points[3]) + # self.wait(1) + # self.play(self.camera_frame.move_to,ORIGIN) + # self.camera_frame.set_width(14) + self.wait(1) + self.get_zoomed_display_pop_out_animation() explanation1=TextMobject("Since the series","converges","to") explanation1.set_color_by_tex_to_color_map({"converges":YELLOW}) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/README.md b/FSF-2020/calculus/series-and-transformations/Taylor Series/README.md new file mode 100644 index 0000000..ce3b088 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/README.md @@ -0,0 +1,11 @@ +#### Example of Taylors expansion +![GIF1](gifs/file1_Example_TaylorExpansion.gif) + +#### Taylor Series GeneralForm +![GIF2](gifs/file2_TaylorExpansionGeneralForm.gif) + +#### Radius Of Convergence +![GIF3](gifs/file3_radiusOfConvergence.gif) + +#### Divergence of a Remainder +![GIF4](gifs/file4_DivergentRemainder.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf b/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf Binary files differindex 2096f52..46d46e1 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file1_Example_TaylorExpansion.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file1_Example_TaylorExpansion.gif Binary files differnew file mode 100644 index 0000000..4272d84 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file1_Example_TaylorExpansion.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2_TaylorExpansionGeneralForm.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2_TaylorExpansionGeneralForm.gif Binary files differnew file mode 100644 index 0000000..e6d9171 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2_TaylorExpansionGeneralForm.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file3_radiusOfConvergence.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file3_radiusOfConvergence.gif Binary files differnew file mode 100644 index 0000000..9e53cfb --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file3_radiusOfConvergence.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file4_DivergentRemainder.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file4_DivergentRemainder.gif Binary files differnew file mode 100644 index 0000000..0bc8b65 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file4_DivergentRemainder.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script1.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video1_Example_TaylorExpansion.py index e83eff8..b132811 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script1.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video1_Example_TaylorExpansion.py @@ -31,7 +31,7 @@ class intro(Scene): self.wait(0.7) self.play(FadeOut(equation),FadeOut(text)) -class graphScene(GraphScene): +class graphScene(GraphScene,MovingCameraScene): CONFIG = { "x_min": -8, "x_max": 8, @@ -45,10 +45,25 @@ class graphScene(GraphScene): "exclude_zero_label": True, "x_labeled_nums": range(-8, 8, 1), } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) def construct(self): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") + equation.scale(0.55) + equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) + text=TextMobject("$a=0$") + text.scale(0.55) + + equation.shift(3.39*UP+5*LEFT) + text.shift(2.9*UP+5*LEFT) + + self.add(equation) + self.add(text) + generalized_eq_coeff=[] variables_eq=[] eq,generalized_eq_coeff=formFormula(generalized_eq_coeff,variables_eq) @@ -58,7 +73,7 @@ class graphScene(GraphScene): trTextGrup.scale(0.5) trTextGrup.to_corner(UP+RIGHT) self.play(Write(trTextGrup)) - self.setup_axes(animate=True) + self.setup_axes(animate=True,scalee=1) fx=TextMobject("${ e }^{ -x^{ 2 } }$") fx.scale(0.5) @@ -66,18 +81,21 @@ class graphScene(GraphScene): mainfunction=self.get_graph(lambda x:math.exp(-1*pow(x,2)),color=RED,x_min=-8,x_max=8) self.play(ShowCreation(mainfunction)) self.play(FadeIn(fx)) - self.wait(1.4) + self.wait(1) coeff=[TextMobject("$1$"),TextMobject("$f'(x)$"),TextMobject("$\\frac { f''(x) }{ 2! } $")] coeff[0].shift(3.39*UP+4.88*RIGHT) coeff[0].scale(0.5) - coeff[1].shift(3.39*UP+5.3*RIGHT) + coeff[1].shift(3.39*UP+5.4*RIGHT) coeff[1].scale(0.275) - coeff[2].shift(3.39*UP+5.98*RIGHT) + coeff[2].shift(3.39*UP+6*RIGHT) coeff[2].scale(0.28) for obj in coeff: obj.set_color(GOLD_A) + group=VGroup(coeff[0],coeff[1],coeff[2]) + + #group.shift(2*LEFT+2*DOWN) firstApprox=[self.get_graph(lambda x:1,color=BLUE)] secondApprox=[self.get_graph(lambda x:1,color=BLUE), @@ -124,16 +142,44 @@ class graphScene(GraphScene): bottomText8.scale(0.5) bottomText1.shift(4.5*RIGHT+2.5*DOWN) - bottomText2.shift(4.5*RIGHT+2.5*DOWN) - bottomText3.shift(4.5*RIGHT+2.5*DOWN) - bottomText4.shift(4.5*RIGHT+2.5*DOWN) - bottomText5.shift(4.5*RIGHT+2.5*DOWN) - bottomText6.shift(4.5*RIGHT+2.5*DOWN) - bottomText7.shift(4.5*RIGHT+2.5*DOWN) - bottomText8.shift(4.5*RIGHT+2.5*DOWN) + # bottomText2.shift(4.5*RIGHT+2.5*DOWN) + # bottomText3.shift(4.5*RIGHT+2.5*DOWN) + # bottomText4.shift(4.5*RIGHT+2.5*DOWN) + # bottomText5.shift(4.5*RIGHT+2.5*DOWN) + # bottomText6.shift(4.5*RIGHT+2.5*DOWN) + # bottomText7.shift(4.5*RIGHT+2.5*DOWN) + # bottomText8.shift(4.5*RIGHT+2.5*DOWN) + bottomText2.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText3.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText4.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText5.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText6.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText7.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText8.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + + bottomText2.scale(0.7) + bottomText3.scale(0.7) + bottomText4.scale(0.7) + bottomText5.scale(0.7) + bottomText6.scale(0.7) + bottomText7.scale(0.7) + bottomText8.scale(0.7) self.play(Write(bottomText1)) - self.wait(1) + self.wait(0.8) + #self.activate_zooming(animate=True) + self.camera_frame.save_state() + group.move_to(4*y_each_unit*UP+4.6*RIGHT*x_each_unit).scale(0.7) + self.play(self.camera_frame.set_width, 8, + self.camera_frame.move_to, x_each_unit*UP, + ApplyMethod(trTextGrup.move_to,4*y_each_unit*UP+4.1*RIGHT*x_each_unit), + ApplyMethod(bottomText1.move_to,3.4*RIGHT*x_each_unit+2.5*DOWN*y_each_unit), + ApplyMethod(equation.shift,1.39*DOWN+2*RIGHT), + ApplyMethod(text.shift,1.39*DOWN+2*RIGHT),) + self.play(ApplyMethod(text.scale,0.5),ApplyMethod(equation.scale,0.5),ApplyMethod(bottomText1.scale,0.6),ApplyMethod(trTextGrup.scale,0.7)) + self.play(ApplyMethod(text.shift,0.3*UP)) + self.wait(0.6) + self.play(ShowCreation(firstApprox[0]),ReplacementTransform(bottomText1,bottomText2)) #change coeff in tn(x) self.play(ReplacementTransform(generalized_eq_coeff[0],coeff[0])) @@ -170,10 +216,12 @@ class graphScene(GraphScene): self.wait(2) textFinal=TextMobject("And so on..!") - textFinal.scale(0.7) - textFinal.shift(4.5*RIGHT+2.5*DOWN) + textFinal.scale(0.35) + textFinal.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) self.play(ReplacementTransform(bottomText8,textFinal)) - self.wait(2.5) + self.wait(1) + self.play(FadeOut(equation),FadeOut(text)) + self.play(self.camera_frame.set_width, 15) finalFormula=TextMobject("Hence","$T_{ n }(x)$","=","$f(0)+f'(0)x+\\frac { f''(0) }{ 2! }x^2+..+\\frac { { f }^{ n }(0) }{ n! } { x }^{ n }$") finalFormula.scale(0.8) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script2.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video2_TaylorExpansionGeneralForm.py index b5d0a53..c177ab4 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script2.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video2_TaylorExpansionGeneralForm.py @@ -59,6 +59,18 @@ class graphScene(GraphScene): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") + equation.scale(0.55) + equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) + text=TextMobject("$a=1$") + text.scale(0.55) + equation.shift(3.39*UP+5*LEFT) + text.shift(3*UP+5*LEFT) + + self.add(equation) + self.add(text) + + generalized_eq_coeff=[] variables_eq=[] eq,generalized_eq_coeff=formFormula(generalized_eq_coeff,variables_eq) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script3.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video3_radiusOfConvergence.py index a2870d4..52f07bb 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script3.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video3_radiusOfConvergence.py @@ -2,7 +2,7 @@ from manimlib.imports import* import math -class graphScene(GraphScene): +class graphScene(GraphScene,MovingCameraScene): CONFIG = { "x_min": -8, "x_max": 8, @@ -16,12 +16,15 @@ class graphScene(GraphScene): "exclude_zero_label": True, "x_labeled_nums": range(-8, 8, 1), } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) def construct(self): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) y_each_unit = self.y_axis_height / (self.y_max - self.y_min) - self.setup_axes(animate=True) + self.setup_axes(animate=True,scalee=1) lnx=self.get_graph(lambda x:math.log2(x),color=RED,x_min=0.01,x_max=8) @@ -98,14 +101,23 @@ class graphScene(GraphScene): circle=Circle(radius=ORIGIN+x_each_unit*2,color=PURPLE_E) circle.shift(ORIGIN+RIGHT*x_each_unit*2) - radiusLine=Line(start=ORIGIN+x_each_unit*RIGHT*2,end=ORIGIN+x_each_unit*4*RIGHT,color=PURPLE_E) + radiusLine=Line(start=ORIGIN+x_each_unit*RIGHT*2,end=ORIGIN+x_each_unit*2*RIGHT+y_each_unit*3*UP,color=PURPLE_E) radius=TextMobject("$R$") radius.set_color(RED) radius.scale(0.5) - radius.shift(ORIGIN+RIGHT*x_each_unit*2.45+DOWN*y_each_unit*0.6) + radius.shift(ORIGIN+RIGHT*x_each_unit*2.45+UP*y_each_unit*2.2) + rText=TextMobject("R",":","Radius of Convergence").scale(0.3).shift(x_each_unit*RIGHT*2+UP*y_each_unit*3.3).set_color_by_tex_to_color_map({"R":RED,"Radius of Convergence":YELLOW}) self.play(FadeOut(equations[6]),Write(circle)) self.wait(0.6) self.play(Write(radiusLine)) self.play(FadeIn(radius)) - self.wait(2)
\ No newline at end of file + self.wait(0.7) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 8, + self.camera_frame.move_to, y_each_unit*UP+x_each_unit*2*RIGHT) + self.play(Write(rText)) + self.wait(1) + self.play(self.camera_frame.set_width, 15, + self.camera_frame.move_to,0) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script4.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video4_DivergentRemainder.py index 1f41c97..1f41c97 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script4.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video4_DivergentRemainder.py diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/README.md b/FSF-2020/calculus/series-and-transformations/Z-Transform/README.md new file mode 100644 index 0000000..c626bdf --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/README.md @@ -0,0 +1,9 @@ +#### Sampling +![GIF1](gifs/file1.gif) + +#### Z Transform of a delta function +![GIF2](gifs/file2.gif) + +#### Region of convergence +![GIF3](gifs/file3.gif) + diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file1.gif b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file1.gif Binary files differnew file mode 100644 index 0000000..d21aa59 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file1.gif diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file2.gif b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file2.gif Binary files differnew file mode 100644 index 0000000..203be8d --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file2.gif diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file3.gif b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file3.gif Binary files differnew file mode 100644 index 0000000..0f100f1 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file3.gif diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/video1_Sampling.py b/FSF-2020/calculus/series-and-transformations/Z-Transform/video1_Sampling.py new file mode 100644 index 0000000..47615e3 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/video1_Sampling.py @@ -0,0 +1,81 @@ +from manimlib.imports import * +import math + +def func(x): + return math.pow(x,3)-2*math.pow(x,2)-x+3 + +class graphScene(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "y_min": -4, + "y_max": 4, + "x_tick_frequency": 0.2, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$f(t)$", + "exclude_zero_label": True, + "x_labeled_nums": range(-3, 4, 1), + "y_axis_height": 5, + "x_axis_width": 9, + } + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + fx=TextMobject("$f(t) = { t }^{ 3 }{ -2t }^{ 2 }-t+3$").set_color(RED).to_corner(UP+RIGHT).scale(0.4) + self.setup_axes(animate=True,scalee=1) + function=self.get_graph(lambda x:math.pow(x,3)-2*math.pow(x,2)-x+3,color=RED,x_min=-1,x_max=2) + functionArea=self.get_riemann_rectangles(function,x_min=-1,x_max=2,dx=0.01,start_color=GREEN,end_color=YELLOW,stroke_color=GREEN,fill_opacity=0.8) + functionDot=Dot(point=self.graph_origin,radius=0.065,color=WHITE) + aboveText1=TextMobject("Continuous","Time Function").shift(4*RIGHT+2*UP).scale(0.4).set_color_by_tex_to_color_map({"Continuous":YELLOW,"Time Function":BLUE}) + aboveText2=TextMobject("Discrete","Time Function").shift(4*RIGHT+2*UP).scale(0.4).set_color_by_tex_to_color_map({"Time Function":BLUE,"Discrete":YELLOW}) + + bottomText1=TextMobject("Instead of considering the","function","over the","entire $t$,").shift(4.5*RIGHT+3*DOWN).scale(0.4).set_color_by_tex_to_color_map({"entire $t$,":RED,"function":YELLOW}) + bottomText2=TextMobject("We consider only at","certain $t$").shift(4.5*RIGHT+3*DOWN).scale(0.4).set_color_by_tex_to_color_map({"certain $t$":RED}) + + self.play(ShowCreation(function),Write(fx),FadeIn(aboveText1)) + self.wait(0.7) + self.play(Write(bottomText1)) + self.play(ShowCreation(functionArea),MoveAlongPath(functionDot,function)) + self.wait(0.7) + self.play(FadeOut(bottomText1)) + self.play(Write(bottomText2),FadeOut(aboveText1)) + + dots=[Dot(radius=0.05) for i in range(10)] + dotShifts=[-1,-0.7,-0.4,0,0.3,0.6,1,1.3,1.6,2] + lines=[] + for x in dotShifts: + lines.append(Line(start=(x*x_each_unit,func(x)*y_each_unit,0),end=(x*x_each_unit,0,0),color=GREEN)) + for i in range(10): + dots[i].shift(ORIGIN+RIGHT*x_each_unit*dotShifts[i]+y_each_unit*UP*func(dotShifts[i])) + updatedGraph=VGroup(dots[0], + dots[1], + dots[2], + dots[3], + dots[4], + dots[5], + dots[6], + dots[7], + dots[8], + dots[9]) + updatedGraph1=VGroup( + lines[0], + lines[1], + lines[2], + lines[3], + lines[4], + lines[5], + lines[6], + lines[7], + lines[8], + lines[9]) + + self.play(FadeOut(functionDot)) + self.play(FadeOut(function),FadeIn(updatedGraph)) + self.play(FadeOut(functionArea),FadeIn(updatedGraph1)) + self.play(FadeOut(bottomText2),FadeIn(aboveText2)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/video2_ZTransformOfDelta.py b/FSF-2020/calculus/series-and-transformations/Z-Transform/video2_ZTransformOfDelta.py new file mode 100644 index 0000000..3063aa6 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/video2_ZTransformOfDelta.py @@ -0,0 +1,121 @@ +from manimlib.imports import * +import numpy as np +import math + +class deltaTransformation(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$f(t)$", + "x_labeled_nums": range(-3, 4, 1), + # "y_axis_height": 4, + # "x_axis_width": 6, + } + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + self.setup_axes(animate=True,scalee=0.8) + function=TextMobject("$f(t) = 2{ \delta }_{ 0 }(t)+3{ \delta }_{ 1 }(t)+4{ \delta }_{ 2 }(t)$").scale(0.4).shift(5*RIGHT+3*UP).set_color(RED) + self.play(FadeIn(function)) + twoDGraph=[ + Line(start=(0,0,0),end=(0,2*y_each_unit,0),color=GREEN), + Line(start=(1*x_each_unit,0,0),end=(x_each_unit,3*y_each_unit,0),color=GREEN), + Line(start=(2*x_each_unit,0,0),end=(2*x_each_unit,4*y_each_unit,0),color=GREEN) + ] + groupGraph=VGroup(twoDGraph[1],twoDGraph[2],self.axes,twoDGraph[0]) + self.play(Write(twoDGraph[0]),ShowCreation(twoDGraph[1]),ShowCreation(twoDGraph[2])) + self.wait(1.2) + self.play(ApplyMethod(groupGraph.scale,0.7)) + self.play(ApplyMethod(groupGraph.shift,5*LEFT),ApplyMethod(function.move_to,5*LEFT+3*UP)) + self.graph_origin=2*RIGHT+2.5*DOWN + self.x_axis_width=6 + self.x_axis_label="$|z|$" + self.y_axis_label="$|F(t)|$" + self.x_min=-3 + self.x_max=6 + self.y_min=-1 + self.y_max=7 + self.x_labeled_nums=range(-3,7,1) + self.setup_axes(animate=True,scalee=0.6) + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + rightSideGraphs=[ + self.get_graph(lambda x:2,x_min=0,x_max=6,color=GREEN), + self.get_graph(lambda x:2+3/x,x_min=0.6,x_max=6,color=GREEN), + self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=1.24,x_max=6,color=GREEN) + ] + graphCoeff=[ + TextMobject("$2$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit*2+DOWN*y_each_unit*0.5).set_color(RED), + TextMobject("$2+\\frac { 3 }{ |z| }$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*3+UP*y_each_unit*2).set_color(RED), + TextMobject("$2+\\frac { 3 }{ |z| } +\\frac { 4 }{ { |z| }^{ 2 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*3.5+UP*y_each_unit*2).set_color(RED) + ] + self.play(ReplacementTransform(twoDGraph[0],rightSideGraphs[0]),FadeIn(graphCoeff[0])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[0]),ReplacementTransform(twoDGraph[1],rightSideGraphs[1]),ReplacementTransform(graphCoeff[0],graphCoeff[1])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[1]),ReplacementTransform(twoDGraph[2],rightSideGraphs[2]),ReplacementTransform(graphCoeff[1],graphCoeff[2])) + + self.wait(2) + + +class graphCont(GraphScene,MovingCameraScene): + CONFIG = { + "x_min": -3, + "x_max": 6, + "y_min": -1, + "y_max": 7, + "graph_origin": 2*RIGHT+2.5*DOWN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$|z|$", + "y_axis_label": "$|F(t)|$", + "exclude_zero_label": True, + "x_labeled_nums": range(-3, 7, 1), + "x_axis_width": 6, + } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + coeff=TextMobject("$2+\\frac { 3 }{ |z| } +\\frac { 4 }{ { |z| }^{ 2 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*3.5+UP*y_each_unit*2).set_color(RED) + self.setup_axes(scalee=0.6) + graph=self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=1.24,x_max=6,color=GREEN) + xAxis=self.get_graph(lambda x:0,x_min=1.24,x_max=6).shift(3*LEFT) + self.add(graph) + self.add(coeff) + self.play(ApplyMethod((self.axes).shift,3*LEFT),ApplyMethod(coeff.shift,3*LEFT),ApplyMethod(graph.shift,3*LEFT)) + topText=TextMobject("Here we get","output","for","any value of $|z|$").scale(0.4).shift(3*UP+3*RIGHT).set_color_by_tex_to_color_map({"output":YELLOW,"any value of $|z|$":BLUE}) + topText1=TextMobject("Except for $|z|=0$").scale(0.7).shift(2.5*UP+3*RIGHT).set_color(RED) + dot1=Dot(color=WHITE,radius=0.06) + dot2=Dot(color=WHITE,radius=0.06) + self.play(Write(topText)) + self.play(MoveAlongPath(dot1,graph),MoveAlongPath(dot2,xAxis),run_time=2) + self.play(Write(topText1)) + self.play(FadeOut(dot1),FadeOut(dot2)) + self.wait(0.5) + path=self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=1.24,x_max=0.8) + path1=self.get_graph(lambda x:0,x_min=1.24,x_max=0.8) + graphUpdated=self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=0.8,x_max=6,color=GREEN) + self.camera_frame.save_state() + self.play(FadeOut(graph),Write(graphUpdated)) + self.play(self.camera_frame.set_width, 30, + MoveAlongPath(dot1,path),MoveAlongPath(dot2,path1),run_time=2) + self.wait(1) + + self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(graphUpdated),FadeIn(graph),self.camera_frame.set_width,15) + self.wait(1) + + + + + diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/video3_RegionOfConvergence.py b/FSF-2020/calculus/series-and-transformations/Z-Transform/video3_RegionOfConvergence.py new file mode 100644 index 0000000..bdfd8b3 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/video3_RegionOfConvergence.py @@ -0,0 +1,144 @@ +from manimlib.imports import * +import numpy as np +import math + +class graph1(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 5, + "y_min": -1, + "y_max": 1, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$n$", + "y_axis_label": "$x(n)$", + "x_labeled_nums": range(-3, 6, 1), + "y_axis_height": 7, + "y_tick_frequency": 0.1, + } + def func(self,x,n): + summ=0 + for i in range(n+1): + summ+=(1/(math.pow(x,i))) + return summ + + def finalFunc(self,x): + if(x!=0): + return 1/(1-(1/(2*x))) + + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + self.setup_axes(animate=True,scalee=0.8) + function=TextMobject("$X(t)=\sum _{ n=0 }^{ \infty }{ { (0.5) }^{ n }{ z }^{ -n } }$").scale(0.4).shift(5*RIGHT+3*UP).set_color(RED) + self.play(FadeIn(function)) + twoDGraph=[] + for i in range(5): + twoDGraph.append(Line(start=(i*x_each_unit,0,0),end=(i*x_each_unit,math.pow(0.5,i)*y_each_unit,0),color=GREEN)) + + groupGraph=VGroup(self.axes,twoDGraph[0],twoDGraph[1],twoDGraph[2],twoDGraph[3],twoDGraph[4]) + self.play(Write(twoDGraph[0]),ShowCreation(twoDGraph[1]),ShowCreation(twoDGraph[2]),ShowCreation(twoDGraph[3]),ShowCreation(twoDGraph[4])) + self.wait(1.2) + + self.play(ApplyMethod(groupGraph.scale,0.7)) + self.play(ApplyMethod(groupGraph.shift,6*LEFT),ApplyMethod(function.move_to,5*LEFT+3*UP)) + + someText1=TextMobject("Since it is a","summation","of","infinite terms",", it might").shift(2*RIGHT+2*UP).scale(0.5).set_color_by_tex_to_color_map({"summation":YELLOW,"infinite terms":BLUE}) + someText2=TextMobject("Converge","or","Diverge").shift(2*RIGHT+0.5*DOWN+2*UP).scale(0.7).set_color_by_tex_to_color_map({"Converge":GREEN,"Diverge":RED}) + someText3=TextMobject("depending upon","$|z|$").shift(2*RIGHT+UP).scale(0.5).set_color_by_tex_to_color_map({"$|z|$":YELLOW}) + self.play(Write(someText1)) + self.play(FadeIn(someText2)) + self.play(Write(someText3)) + self.wait(1) + self.play(FadeOut(someText1),FadeOut(someText2),FadeOut(someText3)) + + self.graph_origin=2*RIGHT+DOWN + self.x_axis_width=6 + self.y_axis_height=5 + self.y_tick_frequency=1 + self.x_axis_label="$|z|$" + self.y_axis_label="$|X(n)|$" + self.x_min=-3 + self.x_max=5 + self.y_min=-1 + self.y_max=5 + self.x_labeled_nums=range(-3,6,1) + self.setup_axes(animate=True,scalee=0.6) + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + rightSideGraphs=[] + xmins=[0,0.25,0.65,0.9,1] + for i in range(5): + rightSideGraphs.append(self.get_graph(lambda x:self.func(x,i),x_min=xmins[i],x_max=5,color=GREEN)) + rightSideGraphs.append(self.get_graph(lambda x:1/(1-(1/(2*x))),x_min=0.63,x_max=5,color=GREEN)) + + graphCoeff=[ + TextMobject("$1$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+0.65*UP*y_each_unit*2+DOWN*y_each_unit*0.5).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| }$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| } +\\frac { 1 }{ { 2|z| }^{ 2 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| } +\\frac { 1 }{ { (2|z|) }^{ 2 } } +\\frac { 1 }{ { (2|z|) }^{ 3 } }$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| } +\\frac { 1 }{ { (2|z|) }^{ 2 } } +\\frac { 1 }{ { (2|z|) }^{ 3 } } +\\frac { 1 }{ (2|z|)^{ 4 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$\\frac { 1 }{ (1-\\frac { 1 }{ 2z } ) } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED) + ] + + self.play(ReplacementTransform(twoDGraph[0],rightSideGraphs[0]),FadeIn(graphCoeff[0])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[0]),ReplacementTransform(twoDGraph[1],rightSideGraphs[1]),ReplacementTransform(graphCoeff[0],graphCoeff[1])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[1]),ReplacementTransform(twoDGraph[2],rightSideGraphs[2]),ReplacementTransform(graphCoeff[1],graphCoeff[2])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[2]),ReplacementTransform(twoDGraph[3],rightSideGraphs[3]),ReplacementTransform(graphCoeff[2],graphCoeff[3])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[3]),ReplacementTransform(twoDGraph[4],rightSideGraphs[4]),ReplacementTransform(graphCoeff[3],graphCoeff[4])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[4]),ShowCreation(rightSideGraphs[5]),ReplacementTransform(graphCoeff[4],graphCoeff[5])) + + self.wait(2) + # #self.play(FadeOut(self.axes),FadeOut(function),FadeOut(twoDGraph[0]),FadeOut(twoDGraph[1]),FadeOut(twoDGraph[2])) + + +class graphCont(GraphScene,MovingCameraScene): + CONFIG = { + "x_min": -3, + "x_max": 5, + "y_min": -1, + "y_max": 5, + "graph_origin": 2*RIGHT+DOWN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$|z|$", + "y_axis_label": "$|X(n)|$", + "x_labeled_nums": range(-3, 6, 1), + "x_axis_width": 6, + "y_axis_height": 5 + } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + coeff=TextMobject("$\\frac { 1 }{ (1-\\frac { 1 }{ 2z } ) } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED) + self.setup_axes(scalee=0.6) + graph=self.get_graph(lambda x:1/(1-(1/(2*x))),x_min=0.63,x_max=5,color=GREEN) + + self.add(graph) + self.add(coeff) + + self.play(ApplyMethod((self.axes).shift,3*LEFT),ApplyMethod(coeff.shift,3*LEFT),ApplyMethod(graph.shift,3*LEFT)) + self.wait(1) + + dashLine=DashedLine(start=self.graph_origin+3*LEFT+0.5*x_each_unit*RIGHT,end=self.graph_origin+3*LEFT+0.5*x_each_unit*RIGHT+y_each_unit*UP*5,color=YELLOW) + pt=TextMobject("0.5").scale(0.3).shift(self.graph_origin+3*LEFT+0.5*x_each_unit*RIGHT+DOWN*y_each_unit*0.3) + self.play(Write(dashLine)) + self.play(Write(pt)) + self.wait(0.6) + rectRegion=Rectangle(height=y_each_unit*5,width=x_each_unit*5,fill_color=WHITE,fill_opacity=0.3,opacity=0.3,color=BLACK).shift(1.6*RIGHT*x_each_unit+0.5*DOWN*y_each_unit+1.5*UP) + self.play(ShowCreation(rectRegion)) + text=TextMobject("Region Of Convergence!").scale(0.4).shift(4.6*RIGHT+1.5*UP).set_color(GREEN) + self.play(FadeIn(text)) + self.wait(2) |