diff options
6 files changed, 309 insertions, 4 deletions
diff --git a/FSF-2020/calculus/intro-to-calculus/fundamental-theorem-of-calculus/fundamental1.py b/FSF-2020/calculus/intro-to-calculus/fundamental-theorem-of-calculus/fundamental1.py new file mode 100644 index 0000000..fd40347 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/fundamental-theorem-of-calculus/fundamental1.py @@ -0,0 +1,72 @@ +from manimlib.imports import * + +class funda1(GraphScene, MovingCameraScene): + def setup(self): + MovingCameraScene.setup(self) + GraphScene.setup(self) + CONFIG = { + "y_max": 5, + "x_max": 8, + "x_min": 0, + "y_min": 0, + "x_axis_width": 10, + "y_axis_height": 5, + "init_dx":0.5, + "x_axis_label":"$t$", + "y_axis_label":"$F(x)$", + "graph_origin": ORIGIN+2*DOWN+6*LEFT, + } + def construct(self): + self.setup_axes() + def func(x): + return 0.1*(x)*(x-3)*(x-7)+3 + + graph1 = self.get_graph(func, x_min = 0, x_max = 7) + graph2 = self.get_graph(func, x_min = 5, x_max = 6) + sqr = Square(side_length = 15.0).move_to(np.array([0.5,-1.5,0])) + line1 = self.get_vertical_line_to_graph(1,graph1,DashedLine, color = PINK) + line2 = self.get_vertical_line_to_graph(5,graph1,DashedLine, color = PINK) + line3 = self.get_vertical_line_to_graph(6,graph1,DashedLine, color = PINK) + line4 = self.get_vertical_line_to_graph(5.01,graph1,DashedLine, color = PINK) + t1 = TextMobject("a").next_to(line1, DOWN) + t2 = TextMobject("x").next_to(line2, DOWN) + t3 = TextMobject("x+h").next_to(line3, DOWN) + text1 = TexMobject(r"\int _{ a }^{ x+h }{ f(t)dt }").move_to(np.array([3,2,0])).scale(0.7) + text2 = TexMobject(r"\int _{ a }^{ x }{ f(t)dt }").move_to(np.array([1,2,0])).scale(0.7) + text3 = TexMobject(r"= \int _{ x }^{ x+h }{ f(t)dt }").move_to(np.array([3,2,0])).scale(0.7) + text4 = TexMobject(r"h \rightarrow 0").move_to(np.array([1,-1.5,0])).scale(0.8) + text5 = TexMobject(r"F^{ ' }\left( x \right)=\lim _{ h\rightarrow 0 }{ \frac { f(x).h }{ h } }").move_to(np.array([1,-1.5,0])).scale(0.2) + text6 = TexMobject(r"F^{ ' }\left( x \right)=f(x)").move_to(np.array([1,-1.5,0])).scale(0.2) + minus = TextMobject("-").move_to(np.array([0.2,2,0])) + group = VGroup(line1, line2, line3, t1, t2, t3) + brace1 = Brace(line2, LEFT).scale(0.35) + br1text = brace1.get_text(r"$f(x)$").next_to(brace1, 1.001*LEFT+1*RIGHT).scale(0.1) + brgrp = VGroup(brace1, br1text) + flat_rectangles1 = self.get_riemann_rectangles(self.get_graph(lambda x : 0),dx=self.init_dx,start_color=invert_color(PURPLE),end_color=invert_color(ORANGE)) + riemann_rectangles_list3 = self.get_riemann_rectangles_list(graph1, 8, max_dx=self.init_dx, power_base=2, start_color = GREEN, end_color=GREEN, x_min =1, x_max = 6) + riemann_rectangles_list1 = self.get_riemann_rectangles_list(graph1,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=BLUE_A,x_min = 1, x_max = 5) + riemann_rectangles_list2 = self.get_riemann_rectangles_list(graph1,8,max_dx=self.init_dx,power_base=2,start_color=RED,end_color=RED,x_min = 5, x_max = 6) + riemann_rectangles_list4 = self.get_riemann_rectangles_list(graph1,8,max_dx=self.init_dx,power_base=2,start_color=RED,end_color=RED,x_min = 5, x_max = 5.01) + + self.add(graph1) + self.play(ReplacementTransform(flat_rectangles1,riemann_rectangles_list3[7]), ShowCreation(text1)) + self.wait(3) + self.play(ShowCreation(group)) + self.wait(1) + self.play(ReplacementTransform(flat_rectangles1,riemann_rectangles_list2[7]), ReplacementTransform(flat_rectangles1,riemann_rectangles_list1[7])) + self.play(FadeOut(riemann_rectangles_list3[7])) + self.wait(2) + self.play(ApplyMethod(text1.shift, 4*LEFT), ShowCreation(minus), ShowCreation(text2), ShowCreation(text3)) + self.play(FadeOut(riemann_rectangles_list1[7])) + self.wait(3) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width,2.25,self.camera_frame.move_to,sqr,run_time = 2) + self.wait(2) + self.play(ReplacementTransform(riemann_rectangles_list2[7], riemann_rectangles_list4[7]), FadeOut(riemann_rectangles_list2[7]), ReplacementTransform(line3, line4), FadeOut(line3), ShowCreation(text4)) + self.wait(2) + self.play(ShowCreation(brgrp)) + self.wait(2) + self.play(ReplacementTransform(text4, text5)) + self.wait(2) + self.play(ReplacementTransform(text5, text6)) + self.wait(5)
\ No newline at end of file diff --git a/FSF-2020/calculus/intro-to-calculus/gabriels-horn/gabriel1.py b/FSF-2020/calculus/intro-to-calculus/gabriels-horn/gabriel1.py index 3596c88..16aeba9 100644 --- a/FSF-2020/calculus/intro-to-calculus/gabriels-horn/gabriel1.py +++ b/FSF-2020/calculus/intro-to-calculus/gabriels-horn/gabriel1.py @@ -52,8 +52,6 @@ class sphere(GraphScene, ThreeDScene): self.add_fixed_in_frame_mobjects(text7) self.wait(2) self.move_camera(phi = 60*DEGREES, theta= -45*DEGREES, distance = 200, run_time=5) - #self.play(FadeOut(text6)) - #self.add_fixed_in_frame_mobjects(text7) k=0 while k<9: disc1 = ParametricSurface(lambda u, v : np.array([0, (1/(1+k))*v*np.sin(TAU*u), (1/(1+k))*v*np.cos(TAU*u)]), fill_opacity = 0.5, fill_color = PINK).shift((1+k)*RIGHT) 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 diff --git a/FSF-2020/calculus/intro-to-calculus/riemann-integrals/README.md b/FSF-2020/calculus/intro-to-calculus/riemann-integrals/README.md index a9ad0bb..de6df0f 100644 --- a/FSF-2020/calculus/intro-to-calculus/riemann-integrals/README.md +++ b/FSF-2020/calculus/intro-to-calculus/riemann-integrals/README.md @@ -10,8 +10,8 @@ rierect3.gif ![rierect3](https://user-images.githubusercontent.com/61246381/87141949-6e1b9700-c2c1-11ea-9433-4f6be752aa55.gif) -RiemannRectanglesAnimation. -![RiemannRectanglesAnimation](https://user-images.githubusercontent.com/61246381/87142531-4a0c8580-c2c2-11ea-8f5e-9e854eae6eec.gif) +RiemannRectanglesAnimation.gif +![RiemannRectanglesAnimation](https://user-images.githubusercontent.com/61246381/87952202-2c5fcd00-cac7-11ea-8b14-a0c522886714.gif) mimi.gif |