diff options
Diffstat (limited to 'FSF-2020/calculus/series-and-transformations/Fourier Transform')
8 files changed, 42 insertions, 64 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 index c5d8389..2fa4e04 100644 --- a/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md @@ -7,9 +7,12 @@ ### Applying the same on Graphs  -### Fourier series for non-periodic functions +### Fourier series for non-periodic functions-a  +### Fourier series for non-periodic functions-b + + ### Fourier Series of Square pulse  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 differindex 533368b..de94810 100644 --- a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file6.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file6.gif Binary files differnew file mode 100644 index 0000000..de94810 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file6.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file7.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file7.gif Binary files differnew file mode 100644 index 0000000..ab4eed8 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file7.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 index 39db6d8..fdb8719 100644 --- a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py @@ -1,13 +1,6 @@ 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, 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 index 8f3706b..c87e58e 100644 --- a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py @@ -101,27 +101,27 @@ class divideColors(GraphScene): 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) @@ -132,9 +132,7 @@ class divideColors(GraphScene): 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])) @@ -142,24 +140,7 @@ class divideColors(GraphScene): 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 index f23e54f..d35f8bf 100644 --- a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py @@ -1,7 +1,7 @@ from manimlib.imports import * import numpy as np -class compare(GraphScene): +class compare(GraphScene,MovingCameraScene): CONFIG = { "x_min": -3, "x_max": 3, @@ -14,6 +14,9 @@ class compare(GraphScene): "exclude_zero_label": True, "x_labeled_nums": range(-2, 3, 1), } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) 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) @@ -58,7 +61,7 @@ class compare(GraphScene): 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) + 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), @@ -77,7 +80,13 @@ class compare(GraphScene): 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(FadeOut(axes[0]),FadeOut(left),FadeOut(right),FadeOut(function)) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 5,self.camera_frame.move_to, 3.5*RIGHT) + + 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])) @@ -85,6 +94,9 @@ class compare(GraphScene): self.play(ReplacementTransform(result1e,result1f),ReplacementTransform(coeffResult[4],coeffResult[5])) self.play(ReplacementTransform(result1f,result1g),ReplacementTransform(coeffResult[5],coeffResult[6])) + self.wait(0.5) + self.play(self.camera_frame.set_width, 14,self.camera_frame.move_to, 0) + 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)) @@ -93,6 +105,7 @@ class compare(GraphScene): 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(FadeIn(axes[0]),FadeIn(left),FadeIn(right),FadeIn(function)) self.play(Write(text5)) self.play(Write(text6)) result2=self.returnPartResult(1.5,20) @@ -101,10 +114,10 @@ class compare(GraphScene): 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), + 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.4).shift(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.4).shift(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.4).shift(5*RIGHT+2.2*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.4).shift(5*RIGHT+2.2*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])) @@ -112,22 +125,5 @@ class compare(GraphScene): 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 + self.wait(2) 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 index 5d33fbe..fdf4bb3 100644 --- a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py @@ -33,9 +33,9 @@ class fourierSeries(GraphScene,MovingCameraScene): 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) + 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.5) self.add(equation) - self.setup_axes(animate=True) + self.setup_axes(animate=True,scalee=1) 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) @@ -87,6 +87,11 @@ class fourierSeries(GraphScene,MovingCameraScene): 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) + circleMark=Circle(radius=0.1,color=GREEN).shift(x_each_unit*RIGHT*0.47+UP*y_each_unit*1.1) + text=TextMobject("Gibbs","phenomenon").set_color_by_tex_to_color_map({"Gibbs":BLUE,"phenomenon":YELLOW}).scale(0.1).shift(RIGHT*x_each_unit*0.65+UP*y_each_unit*1.1) + self.wait(0.7) + self.play(ShowCreation(circleMark)) + self.play(Write(text)) + self.wait(0.5) + self.play(self.camera_frame.set_width,14,self.camera_frame.move_to,0,FadeOut(circleMark),FadeOut(text)) self.wait(2) |