diff options
Diffstat (limited to 'FSF-2020')
4 files changed, 586 insertions, 0 deletions
diff --git a/FSF-2020/series-and-transformations/Taylor Series/script1.py b/FSF-2020/series-and-transformations/Taylor Series/script1.py new file mode 100644 index 0000000..e83eff8 --- /dev/null +++ b/FSF-2020/series-and-transformations/Taylor Series/script1.py @@ -0,0 +1,198 @@ +from manimlib.imports import* +import math + +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,coeff_list + +class intro(Scene): + def construct(self): + equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") + equation.scale(2) + equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) + text=TextMobject("let $a=0$") + text.scale(0.7) + text.shift(DOWN) + + self.play(Write(equation)) + self.wait(0.5) + self.play(FadeIn(text)) + self.wait(0.7) + self.play(FadeOut(equation),FadeOut(text)) + +class graphScene(GraphScene): + CONFIG = { + "x_min": -8, + "x_max": 8, + "y_min": -8, + "y_max": 8, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$x$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "x_labeled_nums": range(-8, 8, 1), + } + def construct(self): + 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) + + generalized_eq_coeff=[] + variables_eq=[] + eq,generalized_eq_coeff=formFormula(generalized_eq_coeff,variables_eq) + trText1=TextMobject("let $T_{ n }(x)$:=") + eq.next_to(trText1) + trTextGrup=VGroup(trText1,eq) + trTextGrup.scale(0.5) + trTextGrup.to_corner(UP+RIGHT) + self.play(Write(trTextGrup)) + self.setup_axes(animate=True) + + fx=TextMobject("${ e }^{ -x^{ 2 } }$") + fx.scale(0.5) + fx.shift(ORIGIN+x_each_unit*7.5*RIGHT+y_each_unit*0.5*UP) + mainfunction=self.get_graph(lambda x:math.exp(-1*pow(x,2)),color=RED,x_min=-8,x_max=8) + self.play(ShowCreation(mainfunction)) + self.play(FadeIn(fx)) + self.wait(1.4) + + coeff=[TextMobject("$1$"),TextMobject("$f'(x)$"),TextMobject("$\\frac { f''(x) }{ 2! } $")] + coeff[0].shift(3.39*UP+4.88*RIGHT) + coeff[0].scale(0.5) + coeff[1].shift(3.39*UP+5.3*RIGHT) + coeff[1].scale(0.275) + coeff[2].shift(3.39*UP+5.98*RIGHT) + coeff[2].scale(0.28) + + for obj in coeff: + obj.set_color(GOLD_A) + + firstApprox=[self.get_graph(lambda x:1,color=BLUE)] + secondApprox=[self.get_graph(lambda x:1,color=BLUE), + self.get_graph(lambda x:x+1,color=BLUE), + self.get_graph(lambda x:-x+1,color=BLUE)] + thirdApprox=[self.get_graph(lambda x:1-2*math.pow(x,2),color=BLUE), + self.get_graph(lambda x:1-0.1*math.pow(x,2),color=BLUE), + self.get_graph(lambda x:1,color=BLUE), + self.get_graph(lambda x:1+0.1*math.pow(x,2),color=BLUE), + self.get_graph(lambda x:1+math.pow(x,2),color=BLUE)] + + firstGraph=self.get_graph(lambda x:1,color=BLUE) + secondGraph=self.get_graph(lambda x:1-math.pow(x,2),color=BLUE) + + bottomText1=TextMobject("The polynomial should","satisfy","the function at $x=0$") + bottomText2=TextMobject("This gives","$a_{ 0 }=1$") + bottomText3=TextMobject("Now it could be of","any slope!") + #show graphs of second approx + bottomText4=TextMobject("Hence the","slopes","should","even match") + #final graph + bottomText5=TextMobject("This gives","$a_{ 1 }=0$") + bottomText6=TextMobject("Since the rate of change of this slope","could vary") + #show third approx graphs + bottomText7=TextMobject("Hence the","rate of change of these slopes","should also be","same!") + #final graph + bottomText8=TextMobject("This gives","$a_{ 2 }=-1$") + + bottomText1.set_color_by_tex_to_color_map({"satisfy":YELLOW}) + bottomText2.set_color_by_tex_to_color_map({"$a_{ 0 }=1$":BLUE}) + bottomText3.set_color_by_tex_to_color_map({"any slope!":YELLOW}) + bottomText4.set_color_by_tex_to_color_map({"slopes":BLUE,"even match":YELLOW}) + bottomText5.set_color_by_tex_to_color_map({"$a_{ 1 }=0$":BLUE}) + bottomText6.set_color_by_tex_to_color_map({"could vary":YELLOW}) + bottomText7.set_color_by_tex_to_color_map({"rate of change of these slopes":BLUE,"same!":YELLOW}) + bottomText8.set_color_by_tex_to_color_map({"$a_{ 2 }=-1$":BLUE}) + + bottomText1.scale(0.4) + bottomText2.scale(0.5) + bottomText3.scale(0.4) + bottomText4.scale(0.4) + bottomText5.scale(0.5) + bottomText6.scale(0.4) + bottomText7.scale(0.4) + bottomText8.scale(0.5) + + bottomText1.shift(4.5*RIGHT+2.5*DOWN) + bottomText2.shift(4.5*RIGHT+2.5*DOWN) + bottomText3.shift(4.5*RIGHT+2.5*DOWN) + bottomText4.shift(4.5*RIGHT+2.5*DOWN) + bottomText5.shift(4.5*RIGHT+2.5*DOWN) + bottomText6.shift(4.5*RIGHT+2.5*DOWN) + bottomText7.shift(4.5*RIGHT+2.5*DOWN) + bottomText8.shift(4.5*RIGHT+2.5*DOWN) + + self.play(Write(bottomText1)) + self.wait(1) + self.play(ShowCreation(firstApprox[0]),ReplacementTransform(bottomText1,bottomText2)) + #change coeff in tn(x) + self.play(ReplacementTransform(generalized_eq_coeff[0],coeff[0])) + self.wait(1.5) + self.play(ReplacementTransform(bottomText2,bottomText3)) + self.wait(0.5) + self.play(ReplacementTransform(firstApprox[0],secondApprox[1])) + self.wait(0.5) + self.play(ReplacementTransform(secondApprox[1],secondApprox[0])) + self.wait(0.5) + self.play(ReplacementTransform(secondApprox[0],secondApprox[2])) + self.wait(1) + self.play(ReplacementTransform(bottomText3,bottomText4),FadeOut(secondApprox[2])) + self.wait(1) + self.play(Write(firstGraph),ReplacementTransform(bottomText4,bottomText5)) + #change a1 coeff + self.play(ReplacementTransform(generalized_eq_coeff[1],coeff[1])) + self.wait(1.5) + self.play(ReplacementTransform(bottomText5,bottomText6)) + self.play(ReplacementTransform(firstGraph,thirdApprox[0])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[0],thirdApprox[1])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[1],thirdApprox[2])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[2],thirdApprox[3])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[3],thirdApprox[4])) + self.wait(1.5) + self.play(ReplacementTransform(bottomText6,bottomText7)) + self.wait(1.5) + self.play(ReplacementTransform(bottomText7,bottomText8),ReplacementTransform(thirdApprox[4],secondGraph)) + self.play(ReplacementTransform(generalized_eq_coeff[2],coeff[2])) + self.wait(2) + + textFinal=TextMobject("And so on..!") + textFinal.scale(0.7) + textFinal.shift(4.5*RIGHT+2.5*DOWN) + self.play(ReplacementTransform(bottomText8,textFinal)) + self.wait(2.5) + + finalFormula=TextMobject("Hence","$T_{ n }(x)$","=","$f(0)+f'(0)x+\\frac { f''(0) }{ 2! }x^2+..+\\frac { { f }^{ n }(0) }{ n! } { x }^{ n }$") + finalFormula.scale(0.8) + finalFormula.set_color_by_tex_to_color_map({"$T_{ n }(x)$":GREEN,"$f(0)+f'(0)x+\\frac { f''(0) }{ 2! }x^2+..+\\frac { { f }^{ n }(0) }{ n! } { x }^{ n }$":RED}) + + self.play(FadeOut(self.axes),FadeOut(textFinal),FadeOut(secondGraph),FadeOut(trTextGrup),FadeOut(mainfunction),FadeOut(fx),FadeOut(coeff[0]),FadeOut(coeff[1]),FadeOut(coeff[2])) + self.play(Write(finalFormula)) + self.wait(2) + # self.play(ReplacementTransform(secondApprox[2],secondApprox[3])) + # self.wait(0.5) + # self.play(ReplacementTransform(secondApprox[3],secondApprox[4])) + # self.wait(0.5) + # self.play(ReplacementTransform(secondApprox[4],secondApprox[5])) + # self.wait(0.5) + # self.play(ReplacementTransform(secondApprox[0],secondApprox[0])) + # self.wait(0.5) + # self.play(ReplacementTransform(secondApprox[0],secondApprox[0])) + # self.wait(0.5) + + + + diff --git a/FSF-2020/series-and-transformations/Taylor Series/script2.py b/FSF-2020/series-and-transformations/Taylor Series/script2.py new file mode 100644 index 0000000..b5d0a53 --- /dev/null +++ b/FSF-2020/series-and-transformations/Taylor Series/script2.py @@ -0,0 +1,195 @@ +from manimlib.imports import* +import math + + +class intro(Scene): + def construct(self): + equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") + equation.scale(2) + equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) + text=TextMobject("at $a=1$") + text.scale(0.7) + text.shift(DOWN) + + shiftText=TextMobject("(Here we shift the origin to the point $x=1$)") + shiftText.scale(0.6) + shiftText.shift(2.4*DOWN) + + + self.play(Write(equation)) + self.wait(0.5) + self.play(FadeIn(text)) + self.wait(0.7) + self.play(Write(shiftText)) + self.wait(0.7) + self.play(FadeOut(equation),FadeOut(text),FadeOut(shiftText)) + + +def formFormula(coeff_list,variable_list): + coeff_list=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] + variable_list=[TextMobject("+"),TextMobject("${ (x-1) }$+"),TextMobject("${ (x-1) }^{ 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,coeff_list + + +class graphScene(GraphScene): + CONFIG = { + "x_min": -8, + "x_max": 8, + "y_min": -8, + "y_max": 8, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$x$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "x_labeled_nums": range(-8, 8, 1), + } + def construct(self): + 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) + + generalized_eq_coeff=[] + variables_eq=[] + eq,generalized_eq_coeff=formFormula(generalized_eq_coeff,variables_eq) + trText1=TextMobject("let $T_{ n }(x)$:=") + eq.next_to(trText1) + trTextGrup=VGroup(trText1,eq) + trTextGrup.scale(0.5) + trTextGrup.to_corner(UP+RIGHT) + self.play(Write(trTextGrup)) + self.setup_axes(animate=True) + + fx=TextMobject("${ e }^{ -x^{ 2 } }$") + fx.scale(0.5) + fx.shift(ORIGIN+x_each_unit*7.5*RIGHT+y_each_unit*0.5*UP) + mainfunction=self.get_graph(lambda x:math.exp(-1*pow(x,2)),color=RED,x_min=-8,x_max=8) + self.play(ShowCreation(mainfunction)) + self.play(FadeIn(fx)) + self.wait(1.4) + + coeff=[TextMobject("$e^{-1}$"),TextMobject("$f'(x)$"),TextMobject("$\\frac { f''(x) }{ 2! } $")] + coeff[0].shift(3.33*UP+3.65*RIGHT) + coeff[0].scale(0.45) + coeff[1].shift(3.33*UP+4.13*RIGHT) + coeff[1].scale(0.275) + coeff[2].shift(3.33*UP+5.36*RIGHT) + coeff[2].scale(0.28) + + for obj in coeff: + obj.set_color(GOLD_A) + + firstApprox=[self.get_graph(lambda x:math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5)] + secondApprox=[self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5), + self.get_graph(lambda x:math.exp(-1)+3*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5), + self.get_graph(lambda x:math.exp(-1)-4*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5)] + thirdApprox=[self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)-2*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)-0.1*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_max=5.5,x_min=-5.5), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+0.5*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+2*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5)] + + firstGraph=self.get_graph(lambda x:math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5) + secondGraph=self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5) + thirdGraph=self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5) + + bottomText1=TextMobject("Apply","$f(1)=T_{n}(1)$") + bottomText2=TextMobject("This gives","$a_{ 0 }=e^{-1}$") + bottomText3=TextMobject("Now it could be of","any slope!") + #show graphs of second approx + bottomText4=TextMobject("Hence","apply","$f'(1)=T_{n}'(1)$") + #final graph + bottomText5=TextMobject("This gives","$a_{ 1 }=-2e^{-1}$") + bottomText6=TextMobject("Since the rate of change of this slope","could vary") + #show third approx graphs + bottomText7=TextMobject("Hence also","apply","$f''(1)=T_{ n }''(1)$") + #final graph + bottomText8=TextMobject("This gives","$a_{ 2 }=e^{-1}$") + + bottomText1.set_color_by_tex_to_color_map({"Apply":YELLOW}) + bottomText2.set_color_by_tex_to_color_map({"$a_{ 0 }=e^{-1}$":BLUE}) + bottomText3.set_color_by_tex_to_color_map({"any slope!":YELLOW}) + bottomText4.set_color_by_tex_to_color_map({"apply":YELLOW}) + bottomText5.set_color_by_tex_to_color_map({"$a_{ 1 }=-2e^{-1}$":BLUE}) + bottomText6.set_color_by_tex_to_color_map({"could vary":YELLOW}) + bottomText7.set_color_by_tex_to_color_map({"apply":YELLOW}) + bottomText8.set_color_by_tex_to_color_map({"$a_{ 2 }=e^{-1}$":BLUE}) + + bottomText1.scale(0.4) + bottomText2.scale(0.5) + bottomText3.scale(0.4) + bottomText4.scale(0.4) + bottomText5.scale(0.5) + bottomText6.scale(0.4) + bottomText7.scale(0.4) + bottomText8.scale(0.5) + + bottomText1.shift(4.5*RIGHT+2.5*DOWN) + bottomText2.shift(4.5*RIGHT+2.5*DOWN) + bottomText3.shift(4.5*RIGHT+2.5*DOWN) + bottomText4.shift(4.5*RIGHT+2.5*DOWN) + bottomText5.shift(4.5*RIGHT+2.5*DOWN) + bottomText6.shift(4.5*RIGHT+2.5*DOWN) + bottomText7.shift(4.5*RIGHT+2.5*DOWN) + bottomText8.shift(4.5*RIGHT+2.5*DOWN) + + self.play(Write(bottomText1)) + self.wait(1) + self.play(ShowCreation(firstApprox[0]),ReplacementTransform(bottomText1,bottomText2)) + #change coeff in tn(x) + self.play(ReplacementTransform(generalized_eq_coeff[0],coeff[0])) + self.wait(1.5) + self.play(ReplacementTransform(bottomText2,bottomText3)) + self.wait(0.5) + self.play(ReplacementTransform(firstApprox[0],secondApprox[1])) + self.wait(0.5) + self.play(ReplacementTransform(secondApprox[1],secondApprox[2])) + # self.wait(0.5) + # self.play(ReplacementTransform(secondApprox[2],secondApprox[0])) + self.wait(1) + self.play(ReplacementTransform(bottomText3,bottomText4),FadeOut(secondApprox[2])) + self.wait(1) + self.play(Write(secondGraph),ReplacementTransform(bottomText4,bottomText5)) + #change a1 coeff + self.play(ReplacementTransform(generalized_eq_coeff[1],coeff[1])) + self.wait(1.5) + self.play(ReplacementTransform(bottomText5,bottomText6)) + self.play(ReplacementTransform(secondGraph,thirdApprox[0])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[0],thirdApprox[1])) + # self.wait(0.6) + # self.play(ReplacementTransform(thirdApprox[1],thirdApprox[2])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[1],thirdApprox[3])) + self.wait(0.6) + self.play(ReplacementTransform(thirdApprox[3],thirdApprox[4])) + self.wait(1.5) + self.play(ReplacementTransform(bottomText6,bottomText7)) + self.wait(1.5) + self.play(ReplacementTransform(bottomText7,bottomText8),ReplacementTransform(thirdApprox[4],thirdGraph)) + self.play(ReplacementTransform(generalized_eq_coeff[2],coeff[2])) + self.wait(2) + + textFinal=TextMobject("And so on..!") + textFinal.scale(0.7) + textFinal.shift(4.5*RIGHT+2.5*DOWN) + self.play(ReplacementTransform(bottomText8,textFinal)) + self.wait(2.5) + + finalFormula=TextMobject("Hence","$T_{ n }(x)$","=","$f(1)+f'(1)(x-1)+\\frac { f''(1) }{ 2! }(x-1)^2+..+\\frac { { f }^{ n }(1) }{ n! } { (x-1) }^{ n }$") + finalFormula.scale(0.8) + finalFormula.set_color_by_tex_to_color_map({"$T_{ n }(x)$":GREEN,"$f(1)+f'(1)(x-1)+\\frac { f''(1) }{ 2! }(x-1)^2+..+\\frac { { f }^{ n }(1) }{ n! } { (x-1) }^{ n }$":RED}) + + self.play(FadeOut(self.axes),FadeOut(textFinal),FadeOut(thirdGraph),FadeOut(trTextGrup),FadeOut(mainfunction),FadeOut(fx),FadeOut(coeff[0]),FadeOut(coeff[1]),FadeOut(coeff[2])) + self.play(Write(finalFormula)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/series-and-transformations/Taylor Series/script3.py b/FSF-2020/series-and-transformations/Taylor Series/script3.py new file mode 100644 index 0000000..a2870d4 --- /dev/null +++ b/FSF-2020/series-and-transformations/Taylor Series/script3.py @@ -0,0 +1,111 @@ +from manimlib.imports import* +import math + + +class graphScene(GraphScene): + CONFIG = { + "x_min": -8, + "x_max": 8, + "y_min": -8, + "y_max": 8, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$x$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "x_labeled_nums": range(-8, 8, 1), + } + def construct(self): + + 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) + + self.setup_axes(animate=True) + + lnx=self.get_graph(lambda x:math.log2(x),color=RED,x_min=0.01,x_max=8) + + bottomText1=TextMobject("Apply $f(x)=T_{n}(x)$") + bottomText2=TextMobject("Then apply $f'(x)=T_{n}'(x)$") + bottomText3=TextMobject("Then apply $f''(x)=T_{n}''(x)$") + bottomText4=TextMobject("and so on..") + + bottomText1.scale(0.5) + bottomText2.scale(0.5) + bottomText3.scale(0.5) + bottomText4.scale(0.5) + + bottomText1.shift(3*RIGHT+2*DOWN) + bottomText2.shift(3*RIGHT+2*DOWN) + bottomText3.shift(3*RIGHT+2*DOWN) + bottomText4.shift(3*RIGHT+2*DOWN) + + equations=[self.get_graph(lambda x:math.log2(2),color=BLUE), + self.get_graph(lambda x:math.log2(2)+(x-2)/2,color=BLUE), + self.get_graph(lambda x:math.log2(2)+(x-2)/2-((x-2)**2)/8,color=BLUE), + self.get_graph(lambda x:math.log2(2)+(x-2)/2-((x-2)**2)/8+((x-2)**3)/24,color=BLUE), + self.get_graph(lambda x:math.log2(2)+(x-2)/2-((x-2)**2)/8+((x-2)**3)/24-((x-2)**4)/64,color=BLUE), + self.get_graph(lambda x:math.log2(2)+(x-2)/2-((x-2)**2)/8+((x-2)**3)/24-((x-2)**4)/64+((x-2)**5)/160,color=BLUE), + self.get_graph(lambda x:math.log2(2)+(x-2)/2-((x-2)**2)/8+((x-2)**3)/24-((x-2)**4)/64+((x-2)**5)/160-((x-2)**6)/384,color=BLUE)] + + terms=[TextMobject("$T_{n}:=$"),TextMobject("$ln(2)$"),TextMobject("$+\\frac { x-2 }{ 2 } $"),TextMobject("$-\\frac { (x-2)^{2} }{ 8 }$"),TextMobject("+..")] + for obj in terms: + obj.scale(0.5) + + terms[0].shift(3*UP+3*RIGHT) + terms[1].next_to(terms[0],buff=0.1) + terms[2].next_to(terms[1],buff=0.1) + terms[3].next_to(terms[2],buff=0.1) + terms[4].next_to(terms[3],buff=0.1) + + self.play(ShowCreation(lnx)) + self.wait(1) + self.play(Write(bottomText1)) + self.wait(0.5) + self.play(ShowCreation(equations[0]),Write(terms[0]),Write(terms[1])) + self.wait(1) + self.play(ReplacementTransform(bottomText1,bottomText2)) + self.wait(0.5) + self.play(ReplacementTransform(equations[0],equations[1]),Write(terms[2])) + self.wait(1) + self.play(ReplacementTransform(bottomText2,bottomText3)) + self.wait(0.5) + self.play(ReplacementTransform(equations[1],equations[2]),Write(terms[3])) + self.wait(1) + self.play(ReplacementTransform(bottomText3,bottomText4),Write(terms[4])) + self.wait(1.5) + + self.play(FadeOut(terms[0]),FadeOut(terms[1]),FadeOut(terms[2]),FadeOut(terms[3]),FadeOut(terms[4]),FadeOut(bottomText4)) + + dline=DashedLine(start=ORIGIN+8*y_each_unit*UP,end=ORIGIN+8*y_each_unit*DOWN) + dline.shift(ORIGIN+x_each_unit*4*RIGHT) + + bottomText5=TextMobject("Here","after $x=4$",", the graph","continuously diverges away","from $ln(x)$") + bottomText5.scale(0.3) + bottomText5.shift(4.5*RIGHT+2*DOWN) + bottomText5.set_color_by_tex_to_color_map({"after $x=4$":YELLOW,"continuously diverges away":BLUE}) + + self.play(Write(bottomText5),Write(dline)) + self.wait(1) + self.play(ReplacementTransform(equations[2],equations[3])) + self.wait(0.3) + self.play(ReplacementTransform(equations[3],equations[4])) + self.wait(0.3) + self.play(ReplacementTransform(equations[4],equations[5])) + self.wait(0.3) + self.play(ReplacementTransform(equations[5],equations[6]),FadeOut(bottomText5)) + self.wait(1) + + circle=Circle(radius=ORIGIN+x_each_unit*2,color=PURPLE_E) + circle.shift(ORIGIN+RIGHT*x_each_unit*2) + radiusLine=Line(start=ORIGIN+x_each_unit*RIGHT*2,end=ORIGIN+x_each_unit*4*RIGHT,color=PURPLE_E) + radius=TextMobject("$R$") + radius.set_color(RED) + radius.scale(0.5) + radius.shift(ORIGIN+RIGHT*x_each_unit*2.45+DOWN*y_each_unit*0.6) + + self.play(FadeOut(equations[6]),Write(circle)) + self.wait(0.6) + self.play(Write(radiusLine)) + self.play(FadeIn(radius)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/series-and-transformations/Taylor Series/script4.py b/FSF-2020/series-and-transformations/Taylor Series/script4.py new file mode 100644 index 0000000..1f41c97 --- /dev/null +++ b/FSF-2020/series-and-transformations/Taylor Series/script4.py @@ -0,0 +1,82 @@ +from manimlib.imports import* +import math + + +class graphScene(GraphScene): + CONFIG = { + "x_min": -8, + "x_max": 8, + "y_min": -8, + "y_max": 8, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$x$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "x_labeled_nums": range(-8, 8, 1), + } + def construct(self): + + 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) + + self.setup_axes(animate=True) + lnx=self.get_graph(lambda x:math.log2(x),color=RED,x_min=0.01,x_max=8) + equation=self.get_graph(lambda x:math.log2(2)+(x-2)/2-((x-2)**2)/8+((x-2)**3)/24-((x-2)**4)/64+((x-2)**5)/160-((x-2)**6)/384,color=BLUE) + + terms=[TextMobject("$T_{n}:=$"),TextMobject("$ln(2)$"),TextMobject("$+\\frac { x-2 }{ 2 } $"),TextMobject("$-\\frac { (x-2)^{2} }{ 8 }$"),TextMobject("+..")] + for obj in terms: + obj.scale(0.5) + + terms[0].shift(3*UP+3*RIGHT) + terms[1].next_to(terms[0],buff=0.1) + terms[2].next_to(terms[1],buff=0.1) + terms[3].next_to(terms[2],buff=0.1) + terms[4].next_to(terms[3],buff=0.1) + + self.play(ShowCreation(lnx)) + self.wait(1) + self.play(FadeIn(equation),FadeIn(terms[0]),FadeIn(terms[1]),FadeIn(terms[2]),FadeIn(terms[3]),FadeIn(terms[4])) + self.wait(1) + + bottomText1=TextMobject("$R_{n}(x)=\\frac { d }{ dx } ($","area bounded","$)$") + + bottomText1.set_color_by_tex_to_color_map({"area bounded":ORANGE}) + #bottomText2.set_color_by_tex_to_color_map({"area bounded":BLUE}) + arrow=TextMobject("$\downarrow$") + arrow.scale(2.5) + arrow.shift(ORIGIN+x_each_unit*RIGHT*9.5+UP*y_each_unit) + increasingText=TextMobject("Increases!") + increasingText.set_color(GREEN) + followupText=TextMobject("as n increase!") + followupText.scale(0.3) + followupText.shift(ORIGIN+x_each_unit*11*RIGHT+UP*y_each_unit*1.1) + increasingText.shift(ORIGIN+x_each_unit*11*RIGHT+UP*y_each_unit*1.6) + increasingText.scale(0.4) + + bottomText1.scale(0.5) + #bottomText2.scale(0.5) + #bottomText3.scale(0.5) + + bottomText1.shift(3.5*LEFT+2*DOWN) + #bottomText2.shift(3.5*LEFT+2.4*DOWN) + #bottomText3.shift(3.5*LEFT+2.8*DOWN) + + dline=DashedLine(start=ORIGIN+8*y_each_unit*UP,end=ORIGIN+8*y_each_unit*DOWN) + dline.shift(ORIGIN+x_each_unit*4*RIGHT) + + area1=self.get_riemann_rectangles(lnx,x_max=8,x_min=4,dx=0.01,start_color=BLUE,end_color=RED,stroke_width=0,fill_opacity=0.8) + area2=self.get_riemann_rectangles(equation,x_max=5.2,x_min=4,dx=0.025,start_color=BLACK,end_color=BLACK,stroke_width=0,fill_opacity=1) + + self.play(Write(dline)) + self.wait(0.5) + self.play(ShowCreation(area1),ShowCreation(area2),Write(bottomText1)) + # self.play(Write(bottomText2)) + # self.play(FadeIn(bottomText3)) + self.play(Write(arrow)) + self.wait(0.7) + self.play(Write(increasingText)) + self.play(FadeIn(followupText)) + self.wait(2) +
\ No newline at end of file |