summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus
diff options
context:
space:
mode:
authorG Sri Harsha2020-07-01 02:44:55 +0530
committerGitHub2020-07-01 02:44:55 +0530
commit5617550395af03f54449795a362d8f61e74793d2 (patch)
tree568ee87a11ca2d9ae909445551c432000dd6ab80 /FSF-2020/calculus
parente0b742fc387a95936a14e66c7b95be5154f20429 (diff)
downloadFSF-mathematics-python-code-archive-5617550395af03f54449795a362d8f61e74793d2.tar.gz
FSF-mathematics-python-code-archive-5617550395af03f54449795a362d8f61e74793d2.tar.bz2
FSF-mathematics-python-code-archive-5617550395af03f54449795a362d8f61e74793d2.zip
added codes
Diffstat (limited to 'FSF-2020/calculus')
-rw-r--r--FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py90
-rw-r--r--FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py165
-rw-r--r--FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py133
-rw-r--r--FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py92
-rw-r--r--FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py225
5 files changed, 705 insertions, 0 deletions
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)