diff options
-rw-r--r-- | FSF-2020/calculus/series-and-transformations/Power Series/video1_pieChart.py | 128 | ||||
-rw-r--r-- | FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_Intuition.py | 94 |
2 files changed, 222 insertions, 0 deletions
diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/video1_pieChart.py b/FSF-2020/calculus/series-and-transformations/Power Series/video1_pieChart.py new file mode 100644 index 0000000..28eb07c --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video1_pieChart.py @@ -0,0 +1,128 @@ +from manimlib.imports import * + + +def formFormula(coeff_list,variable_list): + coeff_list=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] + variable_list=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] + coeff_list[0].shift(2.2*UP+1.6*LEFT) + for i in range(0,3): + coeff_list[i].set_color(GOLD_A) + variable_list[i].next_to(coeff_list[i],buff=0.1) + if i!=2: + coeff_list[i+1].next_to(variable_list[i],buff=0.1) + dots=TextMobject("...") + dots.next_to(variable_list[2]) + expansion=VGroup(coeff_list[0],coeff_list[1],coeff_list[2],variable_list[0],variable_list[1],variable_list[2],dots) + expansion.scale(0.7) + return expansion + +class pieChart(Scene): + def construct(self): + circle1=Circle(radius=3,color=BLUE) + powerText=TextMobject("Power Series") + powerText.scale(0.8) + self.play(FadeIn(powerText)) + self.play(ShowCreation(circle1)) + self.wait(1) + + powerGroup=VGroup(circle1,powerText) + + self.play(ApplyMethod(powerGroup.scale,0.5)) + self.play(ApplyMethod(powerGroup.move_to,2.2*UP)) + self.wait(0.5) + expansion_power_coeff=[] + variables_power=[] + expansion_power=formFormula(expansion_power_coeff,variables_power) + self.play(ReplacementTransform(powerText,expansion_power)) + self.wait(1) + + circle2=Circle(radius=1.5) + circle2.shift(2.2*UP) + expansion_geo_coeff=[0]*3 + variables_geo=[0]*3 + arrow1_2=Line(start=0.7*UP,end=2.5*LEFT) + expansion_geo_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] + for i in range(0,3): + expansion_geo_coeff[i].set_color(GOLD_A) + variables_geo=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] + expansion_geo_coeff[0].shift(2.2*UP+1.6*LEFT) + for i in range(0,3): + variables_geo[i].next_to(expansion_geo_coeff[i],buff=0.1) + if i!=2: + expansion_geo_coeff[i+1].next_to(variables_geo[i],buff=0.1) + dots=TextMobject("...") + dots.next_to(variables_geo[2]) + expansion_geo=VGroup(expansion_geo_coeff[0],expansion_geo_coeff[1],expansion_geo_coeff[2],variables_geo[0],variables_geo[1],variables_geo[2],dots) + expansion_geo.scale(0.7) + + self.play(ApplyMethod(circle2.shift,4*LEFT+2.5*DOWN),ApplyMethod(expansion_geo.shift,4*LEFT+2.5*DOWN)) + self.add(arrow1_2) + self.wait(1) + + ones=[TextMobject("1"),TextMobject("1"),TextMobject("1")] + for i in range(0,3): + ones[i].set_color(GOLD_A) + ones[0].shift(0.3*DOWN,5*LEFT) + ones[1].next_to(ones[0],buff=0.5) + ones[2].next_to(ones[1],buff=0.7) + self.play(ReplacementTransform(expansion_geo_coeff[0],ones[0]),ReplacementTransform(expansion_geo_coeff[1],ones[1]),ReplacementTransform(expansion_geo_coeff[2],ones[2])) + self.wait(1) + expansion_geo=VGroup(ones[0],ones[1],ones[2],variables_geo[0],variables_geo[1],variables_geo[2],dots) + + expansion_geo_final=TextMobject("$1+x+{ x }^{ 2 }..$") + expansion_geo_final.scale(0.8) + expansion_geo_final.shift(0.3*DOWN+4*LEFT) + self.play(ReplacementTransform(expansion_geo,expansion_geo_final)) + self.wait(1) + + circle3=Circle(radius=1.5,color=GREEN) + circle3.shift(2.2*UP) + expansion_taylor_coeff=[0]*3 + variables_taylor=[0]*3 + arrow1_3=Line(start=0.7*UP,end=DOWN*0.3) + expansion_taylor_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] + for i in range(0,3): + expansion_taylor_coeff[i].set_color(GOLD_A) + variables_taylor=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] + expansion_taylor_coeff[0].shift(2.2*UP+1.6*LEFT) + for i in range(0,3): + variables_taylor[i].next_to(expansion_taylor_coeff[i],buff=0.1) + if i!=2: + expansion_taylor_coeff[i+1].next_to(variables_taylor[i],buff=0.1) + dots=TextMobject("...") + dots.next_to(variables_taylor[2]) + expansion_taylor=VGroup(expansion_taylor_coeff[0],expansion_taylor_coeff[1],expansion_taylor_coeff[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots) + expansion_taylor.scale(0.7) + + self.play(ApplyMethod(circle3.shift,4*DOWN),ApplyMethod(expansion_taylor.shift,4*DOWN)) + self.add(arrow1_3) + self.wait(1) + + differentials=[TextMobject("$f(0)$"),TextMobject("${ f'\left( 0 \\right) }$"),TextMobject("$\\frac { f''\left( 0 \\right) }{ 2! }$")] + for i in range(0,3): + differentials[i].set_color(GOLD_A) + differentials[0].shift(1.8*DOWN+1.15*LEFT) + differentials[1].shift(1.8*DOWN+0.45*LEFT) + differentials[2].shift(1.8*DOWN+0.45*RIGHT) + differentials[0].scale(0.35) + differentials[1].scale(0.35) + differentials[2].scale(0.35) + self.play(ReplacementTransform(expansion_taylor_coeff[0],differentials[0]),ReplacementTransform(expansion_taylor_coeff[1],differentials[1]),ReplacementTransform(expansion_taylor_coeff[2],differentials[2])) + self.wait(2) + expansion_taylor_final=VGroup(differentials[0],differentials[1],differentials[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots) + + self.play(FadeOut(expansion_geo_final),FadeOut(expansion_taylor_final)) + geoText=TextMobject("Geometric Series") + geoText.scale(0.7) + geoText.shift(4*LEFT+0.3*DOWN) + taylorText=TextMobject("Taylor Series") + taylorText.scale(0.7) + taylorText.shift(1.8*DOWN) + self.play(FadeIn(geoText),FadeIn(taylorText)) + self.wait(1) + + soOntext=TextMobject("So on..!") + soOntext.shift(4*RIGHT) + soOntext.scale(0.8) + self.play(FadeIn(soOntext)) + self.wait(2) 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) |