summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py
diff options
context:
space:
mode:
authorG Sri Harsha2020-05-26 14:33:30 +0530
committerGitHub2020-05-26 14:33:30 +0530
commit6e570da33384e47c5c6533f50f06342be29e4e4d (patch)
tree35fb0ddf4d598210e21825032a5a61c5d415653f /FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py
parent3a3da8845f29e8bf3b1f6ea9d2938eadd80cb1f6 (diff)
downloadFSF-mathematics-python-code-archive-6e570da33384e47c5c6533f50f06342be29e4e4d.tar.gz
FSF-mathematics-python-code-archive-6e570da33384e47c5c6533f50f06342be29e4e4d.tar.bz2
FSF-mathematics-python-code-archive-6e570da33384e47c5c6533f50f06342be29e4e4d.zip
Add files via upload
Diffstat (limited to 'FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py')
-rw-r--r--FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py94
1 files changed, 94 insertions, 0 deletions
diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py b/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py
new file mode 100644
index 0000000..72356c6
--- /dev/null
+++ b/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py
@@ -0,0 +1,94 @@
+from manimlib.imports import *
+import numpy as np
+
+
+class convergence(Scene):
+ def construct(self):
+ originalFormula=TextMobject("$\sum _{ n=0 }^{ \infty }{ { a }_{ n }{ x }^{ n } }$")
+ originalFormula.set_color(RED)
+ self.play(Write(originalFormula))
+ self.wait(1)
+ 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 }$"]
+ termsTogetherString="+".join(terms)
+ termsTogether=TextMobject(termsTogetherString+"...")
+ termsTogether.scale(0.8)
+ termsTogether.shift(2.7*UP)
+ self.play(ReplacementTransform(originalFormula,termsTogether))
+ self.wait(1)
+
+ termMobjectRect=[0]*12
+ termMobject=TextMobject(terms[0])
+ termMobject.shift(2.7*UP+6.2*LEFT)
+ for i in range(1,13):
+ termMobjectOld=termMobject
+ termMobjectOld.scale(0.8)
+ if(i<12):
+ termMobject=TextMobject(terms[i])
+ termMobject.next_to(termMobjectOld)
+ 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})
+ rectDefine.scale(0.7)
+ rectDefine.shift(3.2*DOWN)
+ self.play(Write(rectDefine))
+ self.wait(1)
+ if(i==2):
+ ratio=TextMobject("If $\\frac { a_{ n+1 } }{ { a }_{ n } } < 1$")
+ ratio.set_color(RED)
+ ratio.scale(0.7)
+ ratio.move_to(3.2*DOWN)
+ inequality=TextMobject("$a_{ n+1 } < a_{ n }$")
+ inequality.set_color(RED)
+ inequality.scale(0.7)
+ inequality.move_to(3.2*DOWN)
+ self.play(FadeOut(rectDefine))
+ self.play(Write(ratio))
+ self.wait(1)
+ 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].move_to((2-0.2*i)*DOWN+RIGHT*0.2*i)
+ #rectangles[p] = termMobjectRect
+ #p+=1
+ self.play(ReplacementTransform(termMobjectOld,termMobjectRect[i-1]))
+
+ uparrow=TextMobject("$\\uparrow$")
+ uparrow.set_color(GREEN)
+ uparrow.scale(6)
+ uparrow.shift(4*RIGHT+0.5*DOWN)
+ self.play(ShowCreation(uparrow))
+ self.wait(1)
+
+ converges=TextMobject("Converges!")
+ converges.set_color(RED)
+ converges.scale(0.6)
+ converges.next_to(uparrow)
+ self.play(FadeIn(converges))
+ self.wait(2)
+
+ 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])
+ self.play(ApplyMethod(rect.scale,0.2))
+ for i in range(0,12):
+ 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})
+ func.scale(0.8)
+ func.shift(DOWN+4.5*RIGHT+0.1*UP)
+ self.play(FadeIn(func))
+
+ rightarrow=TextMobject("$\\rightarrow$")
+ rightarrow.set_color(GREEN)
+ rightarrow.scale(4)
+ rightarrow.shift(2*DOWN)
+ converges=TextMobject("Hence even the","sum converges!")
+ converges.set_color_by_tex_to_color_map({"sum converges!":RED})
+ converges.move_to(3*DOWN)
+ converges.scale(0.7)
+ self.play(Write(rightarrow),FadeIn(converges))
+ self.wait(2)