from manim import* class circulate_prove(Scene): def construct(self): #self.add(NumberPlane()) t=Tex(r"$0.\dot{9}$ ? 1",color=BLUE).scale(3) t1 = Tex(r"$0.\dot{9}$ $<$ 1", color=BLUE).scale(3) t2=Tex(r"$0.\dot{9}$ = 1", color=BLUE).scale(3) t3=Tex(r"$0.\dot{9}$ $>$ 1",color=BLUE).scale(3) # &=可以用作等号对齐 self.play(ReplacementTransform(t,t1)) self.play(ReplacementTransform(t1,t2)) self.play(ReplacementTransform(t2,t3)) self.play(FadeOut(t3)) tex_1=MathTex(r'0.\dot{9} &= x\\ 9.\dot{9} &=10x\\ 9 &=9x\\ x&=1',font_size=80).move_to(LEFT*3) tex_2 = MathTex(r'{1\over3} &= 0.\dot{3} \\ {1\over3}\times3 &= 0.\dot{3}\times3 \\ 1&=0.\dot{9}', font_size=80).move_to(RIGHT * 3) #\times表示这样的'×'符号 self.play(Write(tex_1),run_time=4) self.play(Write(tex_2),run_time=4) # self.play(FadeTransformPieces(tex_1,tex_2,stretch=False,dim_to_match=2)) tex_3 = MathTex(r'0&=0+0+0+0+0 \dots \\ 0&=1-1+1-1+1-1+1-1 \dots \\ 0&=1+(-1)+1+(-1)+(1)+(-1)\dots\\ 0&=1', font_size=60, color="#66D9EF") box_1=SurroundingRectangle(tex_3[0][16]) box_2=SurroundingRectangle(tex_3[0][36]) box_3 = SurroundingRectangle(tex_3[0][63]) grp_box=VGroup(box_1,box_2,box_3) tex_4=MathTex(r'\dot{9}.0&=x\\ \dot{9}0.0&=10x\\ 9&=-9x\\ x&=-1=\dot{9}999\dots',font_size=80,color=YELLOW) grp=VGroup(tex_1,tex_2) self.play(ReplacementTransform(grp,tex_3),run_time=3) self.play(Create(grp_box)) self.wait(1.5) grp1=VGroup(tex_3,grp_box) self.play(ReplacementTransform(grp1,tex_4),run_time=3) self.wait() text=Text("用等比数列求和试试",font="KaiTi",font_size=60,color=BLUE).to_edge(UP) self.play(Write(text)) self.wait() tex_6=Tex(r'$0.\dot{9}=1$',font_size=60,color=BLUE).to_edge(UP) self.play(ReplacementTransform(text,tex_6)) self.wait() tex_5 = MathTex(r'a_{0}= 0.9,a_{1}= 0.09,a_{2}= 0.009,\dots,a_{n}= 0.\dot{0}9',color=YELLOW,font_size=60) self.play(ReplacementTransform(tex_4,tex_5),run_time=2) self.wait(2) self.play(tex_5.animate.move_to(UP*2),run_time=2,rate_functions=smooth) tex_7=MathTex(r'S_{n} =\frac{a_{0}\times \left ( 1-q^{n} \right ) }{1-q} =\frac{0.9\times \left ( 1-({\frac{1}{10}})^n \right ) }{1-\frac{1}{10} } ',font_size=60,color=YELLOW).next_to(tex_5,DOWN) self.play(Write(tex_7)) self.wait(1) tex_8 = MathTex(r'\lim_{n \to \infty} (\frac{1}{10}) ^n=0',color=YELLOW,font_size=60).next_to(tex_7,DOWN) self.play(Write(tex_8)) self.wait() grp2=VGroup(tex_5,tex_7,tex_8) self.play(FadeOut(grp2)) self.wait() tex_9=tex_6.copy().scale(3) tex_9.set_color(YELLOW) tex_9.move_to(ORIGIN) self.play(ReplacementTransform(tex_6,tex_9),run_time=5) self.wait(5)