Skip to content

Commit 1b1d13a

Browse files
authored
Merge pull request #1 from GSri30/master
Updated Sri Harsha's readme.md
2 parents 6f94c01 + fdd0b06 commit 1b1d13a

File tree

12 files changed

+1221
-0
lines changed

12 files changed

+1221
-0
lines changed
110 KB
Binary file not shown.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
from manimlib.imports import *
2+
3+
4+
def formFormula(coeff_list,variable_list):
5+
coeff_list=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")]
6+
variable_list=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")]
7+
coeff_list[0].shift(2.2*UP+1.6*LEFT)
8+
for i in range(0,3):
9+
coeff_list[i].set_color(GOLD_A)
10+
variable_list[i].next_to(coeff_list[i],buff=0.1)
11+
if i!=2:
12+
coeff_list[i+1].next_to(variable_list[i],buff=0.1)
13+
dots=TextMobject("...")
14+
dots.next_to(variable_list[2])
15+
expansion=VGroup(coeff_list[0],coeff_list[1],coeff_list[2],variable_list[0],variable_list[1],variable_list[2],dots)
16+
expansion.scale(0.7)
17+
return expansion
18+
19+
class pieChart(Scene):
20+
def construct(self):
21+
circle1=Circle(radius=3,color=BLUE)
22+
powerText=TextMobject("Power Series")
23+
powerText.scale(0.8)
24+
self.play(FadeIn(powerText))
25+
self.play(ShowCreation(circle1))
26+
self.wait(1)
27+
28+
powerGroup=VGroup(circle1,powerText)
29+
30+
self.play(ApplyMethod(powerGroup.scale,0.5))
31+
self.play(ApplyMethod(powerGroup.move_to,2.2*UP))
32+
self.wait(0.5)
33+
expansion_power_coeff=[]
34+
variables_power=[]
35+
expansion_power=formFormula(expansion_power_coeff,variables_power)
36+
self.play(ReplacementTransform(powerText,expansion_power))
37+
self.wait(1)
38+
39+
circle2=Circle(radius=1.5)
40+
circle2.shift(2.2*UP)
41+
expansion_geo_coeff=[0]*3
42+
variables_geo=[0]*3
43+
arrow1_2=Line(start=0.7*UP,end=2.5*LEFT)
44+
expansion_geo_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")]
45+
for i in range(0,3):
46+
expansion_geo_coeff[i].set_color(GOLD_A)
47+
variables_geo=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")]
48+
expansion_geo_coeff[0].shift(2.2*UP+1.6*LEFT)
49+
for i in range(0,3):
50+
variables_geo[i].next_to(expansion_geo_coeff[i],buff=0.1)
51+
if i!=2:
52+
expansion_geo_coeff[i+1].next_to(variables_geo[i],buff=0.1)
53+
dots=TextMobject("...")
54+
dots.next_to(variables_geo[2])
55+
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)
56+
expansion_geo.scale(0.7)
57+
58+
self.play(ApplyMethod(circle2.shift,4*LEFT+2.5*DOWN),ApplyMethod(expansion_geo.shift,4*LEFT+2.5*DOWN))
59+
self.add(arrow1_2)
60+
self.wait(1)
61+
62+
ones=[TextMobject("1"),TextMobject("1"),TextMobject("1")]
63+
for i in range(0,3):
64+
ones[i].set_color(GOLD_A)
65+
ones[0].shift(0.3*DOWN,5*LEFT)
66+
ones[1].next_to(ones[0],buff=0.5)
67+
ones[2].next_to(ones[1],buff=0.7)
68+
self.play(ReplacementTransform(expansion_geo_coeff[0],ones[0]),ReplacementTransform(expansion_geo_coeff[1],ones[1]),ReplacementTransform(expansion_geo_coeff[2],ones[2]))
69+
self.wait(1)
70+
expansion_geo=VGroup(ones[0],ones[1],ones[2],variables_geo[0],variables_geo[1],variables_geo[2],dots)
71+
72+
expansion_geo_final=TextMobject("$1+x+{ x }^{ 2 }..$")
73+
expansion_geo_final.scale(0.8)
74+
expansion_geo_final.shift(0.3*DOWN+4*LEFT)
75+
self.play(ReplacementTransform(expansion_geo,expansion_geo_final))
76+
self.wait(1)
77+
78+
circle3=Circle(radius=1.5,color=GREEN)
79+
circle3.shift(2.2*UP)
80+
expansion_taylor_coeff=[0]*3
81+
variables_taylor=[0]*3
82+
arrow1_3=Line(start=0.7*UP,end=DOWN*0.3)
83+
expansion_taylor_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")]
84+
for i in range(0,3):
85+
expansion_taylor_coeff[i].set_color(GOLD_A)
86+
variables_taylor=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")]
87+
expansion_taylor_coeff[0].shift(2.2*UP+1.6*LEFT)
88+
for i in range(0,3):
89+
variables_taylor[i].next_to(expansion_taylor_coeff[i],buff=0.1)
90+
if i!=2:
91+
expansion_taylor_coeff[i+1].next_to(variables_taylor[i],buff=0.1)
92+
dots=TextMobject("...")
93+
dots.next_to(variables_taylor[2])
94+
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)
95+
expansion_taylor.scale(0.7)
96+
97+
self.play(ApplyMethod(circle3.shift,4*DOWN),ApplyMethod(expansion_taylor.shift,4*DOWN))
98+
self.add(arrow1_3)
99+
self.wait(1)
100+
101+
differentials=[TextMobject("$f(0)$"),TextMobject("${ f'\left( 0 \\right) }$"),TextMobject("$\\frac { f''\left( 0 \\right) }{ 2! }$")]
102+
for i in range(0,3):
103+
differentials[i].set_color(GOLD_A)
104+
differentials[0].shift(1.8*DOWN+1.15*LEFT)
105+
differentials[1].shift(1.8*DOWN+0.45*LEFT)
106+
differentials[2].shift(1.8*DOWN+0.45*RIGHT)
107+
differentials[0].scale(0.35)
108+
differentials[1].scale(0.35)
109+
differentials[2].scale(0.35)
110+
self.play(ReplacementTransform(expansion_taylor_coeff[0],differentials[0]),ReplacementTransform(expansion_taylor_coeff[1],differentials[1]),ReplacementTransform(expansion_taylor_coeff[2],differentials[2]))
111+
self.wait(2)
112+
expansion_taylor_final=VGroup(differentials[0],differentials[1],differentials[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots)
113+
114+
self.play(FadeOut(expansion_geo_final),FadeOut(expansion_taylor_final))
115+
geoText=TextMobject("Geometric Series")
116+
geoText.scale(0.7)
117+
geoText.shift(4*LEFT+0.3*DOWN)
118+
taylorText=TextMobject("Taylor Series")
119+
taylorText.scale(0.7)
120+
taylorText.shift(1.8*DOWN)
121+
self.play(FadeIn(geoText),FadeIn(taylorText))
122+
self.wait(1)
123+
124+
soOntext=TextMobject("So on..!")
125+
soOntext.shift(4*RIGHT)
126+
soOntext.scale(0.8)
127+
self.play(FadeIn(soOntext))
128+
self.wait(2)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
from manimlib.imports import *
2+
import numpy as np
3+
4+
5+
class convergence(Scene):
6+
def construct(self):
7+
originalFormula=TextMobject("$\sum _{ n=0 }^{ \infty }{ { a }_{ n }{ x }^{ n } }$")
8+
originalFormula.set_color(RED)
9+
self.play(Write(originalFormula))
10+
self.wait(1)
11+
self.play(ApplyMethod(originalFormula.shift,2.7*UP))
12+
self.wait(1)
13+
14+
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 }$"]
15+
termsTogetherString="+".join(terms)
16+
termsTogether=TextMobject(termsTogetherString+"...")
17+
termsTogether.scale(0.8)
18+
termsTogether.shift(2.7*UP)
19+
self.play(ReplacementTransform(originalFormula,termsTogether))
20+
self.wait(1)
21+
22+
termMobjectRect=[0]*12
23+
termMobject=TextMobject(terms[0])
24+
termMobject.shift(2.7*UP+6.2*LEFT)
25+
for i in range(1,13):
26+
termMobjectOld=termMobject
27+
termMobjectOld.scale(0.8)
28+
if(i<12):
29+
termMobject=TextMobject(terms[i])
30+
termMobject.next_to(termMobjectOld)
31+
if(i==1):
32+
rectDefine=TextMobject("Here","each rectangle","represents the","value of the term")
33+
rectDefine.set_color_by_tex_to_color_map({"each rectangle":BLUE,"value of the term":YELLOW})
34+
rectDefine.scale(0.7)
35+
rectDefine.shift(3.2*DOWN)
36+
self.play(Write(rectDefine))
37+
self.wait(1)
38+
if(i==2):
39+
ratio=TextMobject("If $\\frac { a_{ n+1 } }{ { a }_{ n } } < 1$")
40+
ratio.set_color(RED)
41+
ratio.scale(0.7)
42+
ratio.move_to(3.2*DOWN)
43+
inequality=TextMobject("$a_{ n+1 } < a_{ n }$")
44+
inequality.set_color(RED)
45+
inequality.scale(0.7)
46+
inequality.move_to(3.2*DOWN)
47+
self.play(FadeOut(rectDefine))
48+
self.play(Write(ratio))
49+
self.wait(1)
50+
self.play(ReplacementTransform(ratio,inequality))
51+
self.wait(1)
52+
#self.play(ApplyMethod(termMobjectOld.move_to,(2-0.3*i)*DOWN+RIGHT*0.2*i))
53+
termMobjectRect[i-1]=Rectangle(height=0.1,width=(5-0.4*i))
54+
termMobjectRect[i-1].move_to((2-0.2*i)*DOWN+RIGHT*0.2*i)
55+
#rectangles[p] = termMobjectRect
56+
#p+=1
57+
self.play(ReplacementTransform(termMobjectOld,termMobjectRect[i-1]))
58+
59+
uparrow=TextMobject("$\\uparrow$")
60+
uparrow.set_color(GREEN)
61+
uparrow.scale(6)
62+
uparrow.shift(4*RIGHT+0.5*DOWN)
63+
self.play(ShowCreation(uparrow))
64+
self.wait(1)
65+
66+
converges=TextMobject("Converges!")
67+
converges.set_color(RED)
68+
converges.scale(0.6)
69+
converges.next_to(uparrow)
70+
self.play(FadeIn(converges))
71+
self.wait(2)
72+
73+
self.play(FadeOut(converges),FadeOut(uparrow),FadeOut(inequality))
74+
self.wait(0.5)
75+
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])
76+
self.play(ApplyMethod(rect.scale,0.2))
77+
for i in range(0,12):
78+
self.play(ApplyMethod(termMobjectRect[i].shift,i*0.04*DOWN+(11-(3-0.11*i)*i)*LEFT*0.3))
79+
func=TextMobject("$\\approx$","$f(x)$")
80+
func.set_color_by_tex_to_color_map({"$f(x)$":RED})
81+
func.scale(0.8)
82+
func.shift(DOWN+4.5*RIGHT+0.1*UP)
83+
self.play(FadeIn(func))
84+
85+
rightarrow=TextMobject("$\\rightarrow$")
86+
rightarrow.set_color(GREEN)
87+
rightarrow.scale(4)
88+
rightarrow.shift(2*DOWN)
89+
converges=TextMobject("Hence even the","sum converges!")
90+
converges.set_color_by_tex_to_color_map({"sum converges!":RED})
91+
converges.move_to(3*DOWN)
92+
converges.scale(0.7)
93+
self.play(Write(rightarrow),FadeIn(converges))
94+
self.wait(2)
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
from manimlib.imports import*
2+
import math
3+
4+
class intro(Scene):
5+
def construct(self):
6+
introText1=TextMobject("Let's analyse")
7+
introText2=TextMobject("for")
8+
function_main=TextMobject("$\sum { { (-1) }^{ n }{ x }^{ 2n } }$")
9+
function_main.set_color(GREEN)
10+
introText1.scale(1.2)
11+
introText1.shift(2*UP)
12+
introText2.scale(0.7)
13+
introText2.shift(UP)
14+
function_main.scale(2)
15+
function_main.shift(DOWN)
16+
function_expan=TextMobject("$1-{ x }^{ 2 }+{ x }^{ 4 }-{ x }^{ 6 }+{ x }^{ 8 }+..$")
17+
function_expan.set_color(RED)
18+
function_expan.scale(1.2)
19+
function_expan.shift(2*UP)
20+
21+
self.play(Write(introText1))
22+
self.play(FadeIn(introText2))
23+
self.wait(0.5)
24+
self.play(Write(function_main))
25+
self.wait(1)
26+
27+
self.play(FadeOut(introText1),FadeOut(introText2))
28+
self.play(ApplyMethod(function_main.shift,3*UP))
29+
self.wait(0.5)
30+
self.play(ReplacementTransform(function_main,function_expan))
31+
self.wait(1)
32+
self.play(ApplyMethod(function_expan.scale,0.5))
33+
function_expan.to_edge(UP+RIGHT)
34+
self.play(ReplacementTransform(function_expan,function_expan))
35+
self.wait(1)
36+
37+
38+
class graphScene(GraphScene):
39+
CONFIG = {
40+
"x_min": -8,
41+
"x_max": 8,
42+
"y_min": -8,
43+
"y_max": 8,
44+
"graph_origin": ORIGIN,
45+
"function_color": RED,
46+
"axes_color": GREEN,
47+
"x_axis_label": "$x$",
48+
"y_axis_label": "$y$",
49+
"exclude_zero_label": True,
50+
"x_labeled_nums": range(-1, 2, 1),
51+
"y_labeled_nums": range(0,2,1)
52+
}
53+
54+
def construct(self):
55+
56+
x_each_unit = self.x_axis_width / (self.x_max - self.x_min)
57+
y_each_unit = self.y_axis_height / (self.y_max - self.y_min)
58+
59+
function_expan=TextMobject("$1-{ x }^{ 2 }+{ x }^{ 4 }-{ x }^{ 6 }+{ x }^{ 8 }+..$")
60+
function_expan.set_color(RED)
61+
function_expan.scale(0.6)
62+
function_expan.to_edge(UP+RIGHT)
63+
self.add(function_expan)
64+
65+
self.setup_axes(animate=True)
66+
67+
eqText=[TextMobject("$1$"),TextMobject("$1-{ x }^{ 2 }$"),TextMobject("$1-{ x }^{ 2 }+{ x }^{ 4 }$"),TextMobject("$1-{ x }^{ 2 }+{ x }^{ 4 }-{ x }^{ 6 }$")]
68+
for i in range(0,len(eqText)):
69+
eqText[i].scale(0.6)
70+
eqText[i].set_color(BLUE)
71+
eqText[i].shift(ORIGIN+UP*2*y_each_unit+RIGHT*3.3*x_each_unit)
72+
eqTextTerm=TextMobject("And so on..!")
73+
eqTextTerm.set_color(BLUE)
74+
eqTextTerm.scale(0.6)
75+
eqTextTerm.shift(ORIGIN+UP*2*y_each_unit+3*RIGHT*x_each_unit)
76+
equation1 = self.get_graph(lambda x : 1,color = RED,x_min = -8,x_max=8)
77+
equation2 = self.get_graph(lambda x : 1-math.pow(x,2),color = RED,x_min = -1.7,x_max=1.7)
78+
equation3 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4),color = RED,x_min = -1.6,x_max=1.6)
79+
equation4 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6),color = RED,x_min = -1.45,x_max=1.45)
80+
equation5 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6)+math.pow(x,8),color = RED,x_min = -1.35,x_max=1.35)
81+
equation6 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6)+math.pow(x,8)-math.pow(x,10),color = RED,x_min = -1.3,x_max=1.3)
82+
equation7 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6)+math.pow(x,8)-math.pow(x,10)+math.pow(x,12),color = RED,x_min = -1.25,x_max=1.25)
83+
equation8 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6)+math.pow(x,8)-math.pow(x,10)+math.pow(x,12)-math.pow(x,14),color = RED,x_min = -1.2,x_max=1.2)
84+
equation9 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6)+math.pow(x,8)-math.pow(x,10)+math.pow(x,12)-math.pow(x,14)+math.pow(x,16),color = RED,x_min = -1.15,x_max=1.15)
85+
equation10 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4)-math.pow(x,6)+math.pow(x,8)-math.pow(x,10)+math.pow(x,12)-math.pow(x,14)+math.pow(x,16)-math.pow(x,18),color = RED,x_min = -1.15,x_max=1.15)
86+
87+
textBtwAnim1=TextMobject("Here the graph just","oscilates")
88+
textBtwAnim1.set_color_by_tex_to_color_map({"oscilates":BLUE})
89+
textBtwAnim2=TextMobject("after","the","point","(as we add higher order terms)")
90+
textBtwAnim2.set_color_by_tex_to_color_map({"after":BLUE,"point":YELLOW})
91+
textBtwAnim3=TextMobject("$x=1$")
92+
textBtwAnim1.scale(0.4)
93+
textBtwAnim2.scale(0.4)
94+
textBtwAnim3.scale(1.2)
95+
textBtwAnim1.shift(2.1*DOWN+4.3*RIGHT)
96+
textBtwAnim2.shift(2.4*DOWN+4.1*RIGHT)
97+
textBtwAnim3.shift(2.9*DOWN+4.3*RIGHT)
98+
99+
self.play(ShowCreation(equation1),run_time=0.8)
100+
self.add(eqText[0])
101+
self.wait(1)
102+
self.play(ReplacementTransform(equation1,equation2),ReplacementTransform(eqText[0],eqText[1]))
103+
self.wait(0.5)
104+
self.play(ReplacementTransform(equation2,equation3),ReplacementTransform(eqText[1],eqText[2]))
105+
self.wait(0.4)
106+
self.play(ReplacementTransform(equation3,equation4),ReplacementTransform(eqText[2],eqText[3]))
107+
self.wait(0.3)
108+
self.play(FadeOut(eqText[3]))
109+
self.play(FadeIn(eqTextTerm))
110+
self.play(Write(textBtwAnim1),Write(textBtwAnim2))
111+
self.play(FadeIn(textBtwAnim3))
112+
self.play(ReplacementTransform(equation4,equation5))
113+
self.wait(0.2)
114+
self.play(ReplacementTransform(equation5,equation6))
115+
self.wait(0.2)
116+
self.play(ReplacementTransform(equation6,equation7))
117+
self.wait(0.2)
118+
self.play(ReplacementTransform(equation7,equation8))
119+
self.wait(0.2)
120+
self.play(ReplacementTransform(equation8,equation9))
121+
self.wait(0.2)
122+
self.play(ReplacementTransform(equation9,equation10))
123+
self.wait(1)
124+
125+
self.play(FadeOut(textBtwAnim1),FadeOut(textBtwAnim2),FadeOut(textBtwAnim3),FadeOut(equation10),FadeOut(eqTextTerm))
126+
self.wait(1)
127+
128+
convergeLine=Line(start=ORIGIN+x_each_unit*LEFT,end=ORIGIN+x_each_unit*RIGHT,color=WHITE)
129+
divergeLineLeft=Line(start=ORIGIN+x_each_unit*LEFT,end=ORIGIN+x_each_unit*LEFT*8,color=RED)
130+
divergeLineRight=Line(start=ORIGIN+x_each_unit*RIGHT,end=ORIGIN+x_each_unit*8*RIGHT,color=RED)
131+
circle1=Circle(radius=0.01,color=PURPLE_E)
132+
circle2=Circle(radius=0.01,color=PURPLE_E)
133+
circle1.shift(ORIGIN+LEFT*x_each_unit)
134+
circle2.shift(ORIGIN+RIGHT*x_each_unit)
135+
convergeText=TextMobject("Converges")
136+
divergeText1=TextMobject("Diverges")
137+
divergeText2=TextMobject("Diverges")
138+
convergeText.set_color(GREEN)
139+
divergeText1.set_color(RED)
140+
divergeText2.set_color(RED)
141+
convergeText.scale(0.5)
142+
divergeText1.scale(0.5)
143+
divergeText2.scale(0.5)
144+
convergeText.shift(1.6*UP)
145+
divergeText1.shift(0.3*UP+1.5*LEFT)
146+
divergeText2.shift(0.3*UP+1.5*RIGHT)
147+
self.play(Write(divergeLineLeft),Write(divergeLineRight))
148+
self.play(FadeIn(convergeLine))
149+
self.wait(0.5)
150+
self.play(FadeOut(self.axes))
151+
self.play(Write(circle1),Write(circle2))
152+
self.wait(0.5)
153+
self.play(ApplyMethod(convergeLine.shift,1.3*UP),ApplyMethod(function_expan.shift,5*LEFT+DOWN))
154+
self.play(FadeIn(convergeText),FadeIn(divergeText1),FadeIn(divergeText2))
155+
self.wait(2)
156+

0 commit comments

Comments
 (0)