summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series
diff options
context:
space:
mode:
Diffstat (limited to 'FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series')
-rw-r--r--FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/README.md8
-rw-r--r--FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/convergence.py57
-rw-r--r--FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/divergence.py111
-rw-r--r--FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/taylorseries.py67
4 files changed, 243 insertions, 0 deletions
diff --git a/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/README.md b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/README.md
new file mode 100644
index 0000000..1a735f9
--- /dev/null
+++ b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/README.md
@@ -0,0 +1,8 @@
+convergence
+![convergence](https://user-images.githubusercontent.com/61246381/87969916-9cc71800-cae0-11ea-8792-fd44b5823279.gif)
+
+divergence
+![divergence](https://user-images.githubusercontent.com/61246381/87970033-cbdd8980-cae0-11ea-9ba6-47f48898dab2.gif)
+
+taylor series
+![taylor](https://user-images.githubusercontent.com/61246381/87970112-e9125800-cae0-11ea-9a19-edcaaf91d7b6.gif)
diff --git a/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/convergence.py b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/convergence.py
new file mode 100644
index 0000000..fcbcfb4
--- /dev/null
+++ b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/convergence.py
@@ -0,0 +1,57 @@
+from manimlib.imports import *
+def GetCenters(width,center,n):
+ d = width / 4
+ list = [center + [0,d,0]]
+ if n > 1:
+ list.append(center + [-d,-d,0])
+ if n > 2:
+ list.extend(GetCenters(width / 2, center + [d,-d,0],n-2))
+ return list
+END_CENTERS = [ORIGIN]
+END_CENTERS.extend(GetCenters(3, 3 * RIGHT, 24))
+color_list = ['#00931F','#A93226','#D68910','#17A589','#2471A3','#884EA0','#E74C3C','#D4AC0D']
+COLORS = [color_list[i % len(color_list)] for i in range(50)]
+class RectangleFromSequence(Rectangle):
+ CONFIG = {
+ "sequence_number": 0,
+ "center": ORIGIN
+ }
+ def __init__(self, **kwargs):
+ digest_config(self, kwargs)
+ Rectangle.__init__(self,height = 3 * (1/2) ** ((self.sequence_number + 1) // 2),width = 3 * (1/2) ** ((self.sequence_number) // 2),**kwargs)
+ if self.sequence_number < 6:
+ if self.sequence_number == 0:
+ label = TexMobject("1")
+ else:
+ label = TexMobject("1/",str(2 ** self.sequence_number))
+ label.scale(0.8 ** self.sequence_number)
+ self.add(label)
+ self.label = label
+ self.set_fill(COLORS[self.sequence_number],1)
+ self.set_stroke(width = 1)
+ self.move_to(self.center)
+equation = TexMobject("\\sum_{n=0}^\\infty \\frac{1}{2^n} =","1","+","\\frac{1}{2}","+","\\frac{1}{4}","+","\\frac{1}{8}","+","\\frac{1}{16}","+ \\ldots","= 2")
+class Proof1(Scene):
+ def construct(self):
+ equation.to_edge(UL)
+ self.play(Write(equation[0:-1]))
+ rects = VGroup(*[RectangleFromSequence(sequence_number = i)for i in range(25)])
+ rects.arrange(RIGHT, buff=0.5)
+ left_center = 5*LEFT
+ rects.shift(left_center-rects[0].get_center())
+ for rect in rects:
+ rect.shift(DOWN*rect.get_top()+UP*3 / 2)
+ for i in range(25):
+ rects[i].generate_target()
+ rects[i].target.move_to(left_center+END_CENTERS[i])
+ self.wait()
+ for i in range(5):
+ self.play(GrowFromPoint(rects[i] , equation[2*i+1].get_center()))
+ self.play(*[GrowFromPoint(rects[i] , equation[-2].get_center())for i in range(5,25)])
+ self.wait()
+ for i in range(1,8):
+ self.play(MoveToTarget(rects[i]))
+ self.play(*[MoveToTarget(rects[i]) for i in range(8,25)])
+ self.wait(0.5)
+ self.play(Write(equation[-1]))
+ self.wait(3) \ No newline at end of file
diff --git a/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/divergence.py b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/divergence.py
new file mode 100644
index 0000000..4f4bf7c
--- /dev/null
+++ b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/divergence.py
@@ -0,0 +1,111 @@
+from manimlib.imports import *
+class divergence(GraphScene):
+ CONFIG = {
+ "y_max" : 2,
+ "y_min" : -2,
+ "x_max" : 20,
+ "x_min" : 0,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "axes_color" : WHITE,
+ "num_graph_anchor_points": 3000,
+ "graph_origin" : ORIGIN+6*LEFT,
+ "x_labeled_nums": None,
+ "y_labeled_nums": [-2,-1,1,2],
+ "x_axis_label":r"${(-1)}^{n}$",
+ "y_axis_label":"$Sum$",
+ "x_axis_width": 10,
+ "y_axis_height": 4,
+ }
+ def construct(self):
+ XTD = self.x_axis_width/(self.x_max - self.x_min)
+ YTD = self.y_axis_height/(self.y_max - self.y_min)
+ text1 = TextMobject("Consider the series 1-1+1-1+1-1+1-......")
+ self.add(text1)
+ self.wait(3)
+ self.play(FadeOut(text1))
+ self.setup_axes()
+ rangeo = (20)//self.x_axis_width
+ for i in range(0,2):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+0.5*RIGHT)
+ self.add(texta)
+ for i in range(2,4):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+0.65*RIGHT)
+ self.add(texta)
+ for i in range(4,6):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+0.8*RIGHT)
+ self.add(texta)
+ for i in range(6,8):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+0.95*RIGHT)
+ self.add(texta)
+ for i in range(8,10):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+1.1*RIGHT)
+ self.add(texta)
+ for i in range(10,12):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+1.35*RIGHT)
+ self.add(texta)
+ for i in range(12,14):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+1.5*RIGHT)
+ self.add(texta)
+ for i in range(14,16):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+1.65*RIGHT)
+ self.add(texta)
+ for i in range(16,18):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+1.8*RIGHT)
+ self.add(texta)
+ for i in range(18,20):
+ texta = TextMobject(str((-1)**i)).move_to(self.graph_origin+0.2*(rangeo*i)*RIGHT+0.5*DOWN+1.95*RIGHT)
+ self.add(texta)
+
+ text2 = TextMobject("Number of purple lines denotes the number of terms added").move_to(1*UP).scale(0.8)
+ self.play(ShowCreation(text2))
+ self.wait(4)
+ self.play(FadeOut(text2))
+ for i in range(0,2):
+ horline = Line(np.array([-5.5+i,1,0]), np.array([-5+i,1,0]), color = PINK)
+ verline = DashedVMobject(Line(np.array([-5+i,1,0]), np.array([-5+i,0,0])))
+ botline = Line(np.array([-6+i,0,0]), np.array([-5.5+i,0,0]), color = PINK)
+ upline = DashedVMobject(Line(np.array([-5.5+i,0,0]), np.array([-5.5+i,1,0])))
+ self.play(ShowCreation(botline), run_time = 0.2)
+ self.play(ShowCreation(upline), run_time = 0.2)
+ self.play(ShowCreation(horline), run_time = 0.2)
+ self.play(ShowCreation(verline), run_time = 0.2)
+
+ text3 = TextMobject("For even number of terms, sum is 0").move_to(1*UP).scale(0.8)
+ self.play(FadeIn(text3))
+ self.wait(4)
+ self.play(FadeOut(text3))
+ for i in range(2,4):
+ horline = Line(np.array([-5.5+i,1,0]), np.array([-5+i,1,0]), color = PINK)
+ verline = DashedVMobject(Line(np.array([-5+i,1,0]), np.array([-5+i,0,0])))
+ botline = Line(np.array([-6+i,0,0]), np.array([-5.5+i,0,0]), color = PINK)
+ upline = DashedVMobject(Line(np.array([-5.5+i,0,0]), np.array([-5.5+i,1,0])))
+ self.play(ShowCreation(botline), run_time = 0.2)
+ self.play(ShowCreation(upline), run_time = 0.2)
+ self.play(ShowCreation(horline), run_time = 0.2)
+ self.play(ShowCreation(verline), run_time = 0.2)
+ botline = Line(np.array([-6+4,0,0]), np.array([-5.5+4,0,0]), color = PINK)
+ upline = DashedVMobject(Line(np.array([-5.5+4,0,0]), np.array([-5.5+4,1,0])))
+ self.play(ShowCreation(botline))
+ self.play(ShowCreation(upline))
+ text4 = TextMobject("For odd number of terms, sum is 1").move_to(1.5*UP).scale(0.8)
+ self.play(FadeIn(text4))
+ self.wait(3)
+ for i in range(4,10):
+ horline = Line(np.array([-5.5+i,1,0]), np.array([-5+i,1,0]), color = PINK)
+ verline = DashedVMobject(Line(np.array([-5+i,1,0]), np.array([-5+i,0,0])))
+ botline = Line(np.array([-6+i,0,0]), np.array([-5.5+i,0,0]), color = PINK)
+ upline = DashedVMobject(Line(np.array([-5.5+i,0,0]), np.array([-5.5+i,1,0])))
+ self.play(ShowCreation(botline), run_time = 0.2)
+ self.play(ShowCreation(upline), run_time = 0.2)
+ self.play(ShowCreation(horline), run_time = 0.2)
+ self.play(ShowCreation(verline), run_time = 0.2)
+ text5 = TextMobject("The sum is oscillating between 1 and 0").move_to(1.5*UP).scale(0.8)
+ self.play(ReplacementTransform(text4, text5))
+ self.wait(4)
+ text6 = TextMobject("It does not coerce to a particular finite value").move_to(1.5*UP).scale(0.8)
+ self.play(ReplacementTransform(text5, text6))
+ self.wait(4)
+ text7 = TextMobject("Hence it diverges").move_to(1.5*UP).scale(0.8)
+ self.play(ReplacementTransform(text6, text7))
+ self.wait(3) \ No newline at end of file
diff --git a/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/taylorseries.py b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/taylorseries.py
new file mode 100644
index 0000000..2e9d423
--- /dev/null
+++ b/FSF-2020/calculus/intro-to-calculus/infinite-seq-and-series/taylorseries.py
@@ -0,0 +1,67 @@
+from manimlib.imports import *
+class conv(GraphScene):
+ CONFIG = {
+ "y_max" : 10,
+ "y_min" : 0,
+ "x_max" : 5,
+ "x_min" : -1,
+ "y_tick_frequency" : 5,
+ "x_tick_frequency" : 1,
+ "axes_color" : WHITE,
+ "num_graph_anchor_points": 3000,
+ "graph_origin" : ORIGIN+2*DOWN+6*LEFT,
+ "x_labeled_nums": list(range(0,6)),
+ "y_labeled_nums": list(range(0,11))[::1],
+ "x_axis_label":"x",
+ "y_axis_label":"$f(x)$",
+ "x_axis_width": 9,
+ "y_axis_height": 5,
+ }
+ def construct(self):
+ XTD = self.x_axis_width/(self.x_max - self.x_min)
+ YTD = self.y_axis_height/(self.y_max - self.y_min)
+ texta = TexMobject(r"\text{Expressing }", r"{e}^{x}", r"\text{ as its Taylor series}")
+ self.play(FadeIn(texta))
+ self.wait(3)
+ self.play(FadeOut(texta))
+ self.setup_axes()
+ graph1 = self.get_graph(lambda x : (np.e)**x, x_min = -1, x_max = 5, color = PINK)
+ graph2 = self.get_graph(lambda x : 1+x, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ graph3 = self.get_graph(lambda x : 1+(x)+(x**2)/2, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ graph4 = self.get_graph(lambda x : 1+(x)+(x**2)/2+(x**3)/6, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ graph5 = self.get_graph(lambda x : 1+(x)+(x**2)/2+(x**3)/6+(x**4)/24, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ graph6 = self.get_graph(lambda x : 1+(x)+(x**2)/2+(x**3)/6+(x**4)/24+(x**5)/120, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ graph7 = self.get_graph(lambda x : 1+(x)+(x**2)/2+(x**3)/6+(x**4)/24+(x**5)/120+(x**6)/720, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ graph8 = self.get_graph(lambda x : 1+(x)+(x**2)/2+(x**3)/6+(x**4)/24+(x**5)/120+(x**6)/720+(x**7)/5040, x_min = -1, x_max = 5, color = GREEN_SCREEN)
+ texta = TexMobject(r"{e}^{x}").move_to(self.graph_origin+ 1*RIGHT+2*UP)
+ textb = TexMobject(r"\therefore {e}^{x}=").move_to(3.5*LEFT+0.5*DOWN)
+ text1 = TexMobject(r"1+x").move_to(4*RIGHT)
+ text2 = TexMobject(r"+\frac{{x}^{2}}{2!}").move_to(4*RIGHT)
+ text3 = TexMobject(r"+\frac{{x}^{3}}{3!}").move_to(4*RIGHT)
+ text4 = TexMobject(r"+\frac{{x}^{4}}{4!}").move_to(4*RIGHT)
+ text5 = TexMobject(r"+\frac{{x}^{5}}{5!}").move_to(4*RIGHT)
+ text6 = TexMobject(r"+\frac{{x}^{6}}{6!}").move_to(4*RIGHT)
+ text7 = TexMobject(r"+\frac{{x}^{7}}{7!}+...").move_to(4.5*RIGHT)
+
+ self.play(ShowCreation(texta))
+ self.play(ShowCreation(graph1))
+ self.wait(3)
+ self.play(FadeOut(texta))
+ self.play(ShowCreation(graph2))
+ self.play(ShowCreation(text1))
+ self.wait(3)
+ self.play(ReplacementTransform(graph2, graph3), ApplyMethod(text1.shift, 1*LEFT), ShowCreation(text2))
+ self.wait(3)
+ self.play(ReplacementTransform(graph3, graph4), ApplyMethod(text1.shift, 1*LEFT), ApplyMethod(text2.shift, 1*LEFT), ShowCreation(text3))
+ self.wait(3)
+ self.play(ReplacementTransform(graph4, graph5), ApplyMethod(text1.shift, 1*LEFT), ApplyMethod(text2.shift, 1*LEFT), ApplyMethod(text3.shift, 1*LEFT), ShowCreation(text4))
+ self.wait(3)
+ self.play(ReplacementTransform(graph5, graph6), ApplyMethod(text1.shift, 1*LEFT), ApplyMethod(text2.shift, 1*LEFT), ApplyMethod(text3.shift, 1*LEFT), ApplyMethod(text4.shift, 1*LEFT), ShowCreation(text5))
+ self.wait(3)
+ self.play(ReplacementTransform(graph6, graph7), ApplyMethod(text1.shift, 1*LEFT), ApplyMethod(text2.shift, 1*LEFT), ApplyMethod(text3.shift, 1*LEFT), ApplyMethod(text4.shift, 1*LEFT), ApplyMethod(text5.shift, 1*LEFT), ShowCreation(text6))
+ self.wait(3)
+ self.play(ReplacementTransform(graph7, graph8),ApplyMethod(text1.shift, 1*LEFT), ApplyMethod(text2.shift, 1*LEFT), ApplyMethod(text3.shift, 1*LEFT), ApplyMethod(text4.shift, 1*LEFT), ApplyMethod(text5.shift, 1*LEFT), ApplyMethod(text6.shift, 1*LEFT), ShowCreation(text7))
+ self.wait(3)
+ grp = VGroup(text1, text2, text3, text4, text5, text6, text7)
+ self.play(ApplyMethod(grp.shift, 0.5*DOWN), FadeIn(textb))
+ self.wait(5) \ No newline at end of file