emphasize_limit_definition.py
1from manim import *2import numpy as np3 4class EmphasizeLimitDefinition(Scene):5 def construct(self):6 # Title7 title = Text("证明数列极限不存在", font="SimSun", font_size=36)8 title.to_edge(UP)9 self.play(Write(title))10 self.wait(1)11 12 # Show sequence a_n = (-1)^n13 sequence_def = MathTex(r"a_n = (-1)^n", font_size=40)14 sequence_def.next_to(title, DOWN, buff=0.3)15 self.play(Write(sequence_def))16 self.wait(2)17 18 # Create axes higher up19 axes = Axes(20 x_range=[0, 30, 5],21 y_range=[-2, 2, 1],22 axis_config={"include_tip": True},23 x_length=10, # 缩小x轴长度24 y_length=5 # 缩小y轴长度25 )26 axes.next_to(sequence_def, DOWN, buff=0) # 向上移动0.5个单位(减少buff值)27 28 # Axes labels29 x_label = MathTex("n", font_size=30).next_to(axes.x_axis, RIGHT)30 y_label = MathTex("a_n", font_size=30).next_to(axes.y_axis, UP)31 32 # 定义outside_after_10变量在更外层的作用域33 outside_after_10 = VGroup()34 35 self.play(Create(axes), Write(x_label), Write(y_label))36 self.wait(2)37 38 # Plot sequence points39 def seq_func(n):40 return (-1)**n41 42 # Create all points43 points = [axes.c2p(n, seq_func(n)) for n in range(1, 31)]44 dots = VGroup(*[Dot(point, color=BLUE, radius=0.07) for point in points])45 46 # Show all points at once47 self.play(Create(dots), run_time=2)48 self.wait(2)49 50 # Try to show convergence to L = 151 limit_line_1 = DashedLine(52 axes.c2p(0, 1),53 axes.c2p(30, 1),54 color=YELLOW55 )56 limit_label_1 = MathTex("L = 1", color=YELLOW, font_size=30).next_to(limit_line_1, RIGHT, buff=0.2)57 58 self.play(Create(limit_line_1), Write(limit_label_1))59 self.wait(1)60 61 # Show epsilon band around L = 162 epsilon_val = 0.563 epsilon_band_upper = DashedLine(64 axes.c2p(0, 1 + epsilon_val),65 axes.c2p(30, 1 + epsilon_val),66 color=YELLOW67 )68 epsilon_band_lower = DashedLine(69 axes.c2p(0, 1 - epsilon_val),70 axes.c2p(30, 1 - epsilon_val),71 color=YELLOW72 )73 74 epsilon_brace = BraceBetweenPoints(75 axes.c2p(25, 1 - epsilon_val),76 axes.c2p(25, 1 + epsilon_val),77 color=YELLOW78 )79 epsilon_label = MathTex("2\\varepsilon = 1.0", color=YELLOW, font_size=24).next_to(epsilon_brace, RIGHT, buff=0.1).shift(DOWN*0.2)80 81 self.play(82 Create(epsilon_band_upper),83 Create(epsilon_band_lower),84 GrowFromCenter(epsilon_brace),85 Write(epsilon_label)86 )87 self.wait(2)88 89 # Highlight points outside epsilon band (odd terms at -1)90 odd_points = VGroup(*[dots[i] for i in range(1, len(dots), 2)]) # Points at -191 self.play(odd_points.animate.set_color(RED), run_time=1.5)92 self.wait(1)93 94 # Emphasize the key concept: for any N, there exists n > N outside the band95 concept_text = Text("关键概念:对于任意N,总存在n>N使得点在带外", font="SimSun", font_size=24)96 concept_text.next_to(axes, DOWN, buff=0.3).shift(UP*0.8)97 self.play(Write(concept_text))98 self.wait(2)99 100 # Demonstrate this concept with different values of N101 # N = 5102 n_line_5 = DashedLine(103 axes.c2p(5, -2),104 axes.c2p(5, 2),105 color=GREEN106 )107 n_label_5 = MathTex("N = 5", color=GREEN, font_size=24).next_to(n_line_5, UP, buff=0.1)108 109 self.play(Create(n_line_5), Write(n_label_5))110 self.wait(1)111 112 # Highlight points after N=5 that are outside the band (points at -1)113 outside_after_5 = VGroup()114 for n in range(5+1, 31): # n > N (5)115 if n % 2 == 1: # Odd n values correspond to points at -1116 outside_after_5.add(dots[n-1]) # Subtract 1 to convert n to index117 118 # Add highlight circles around the points119 highlight_circles_5 = VGroup()120 for point in outside_after_5:121 circle = Circle(radius=0.15, color=ORANGE, stroke_width=5).move_to(point)122 highlight_circles_5.add(circle)123 124 self.play(125 outside_after_5.animate.set_color(ORANGE), 126 *[Create(circle) for circle in highlight_circles_5],127 run_time=1.5128 )129 self.wait(1)130 131 # Show that there are points outside the band after N=5132 exists_text_5 = Text("存在n=7,9,11,... > 5使得点在带外", 133 font="SimSun", font_size=20, color=ORANGE)134 exists_text_5.next_to(axes, DOWN, buff=0.3).shift(UP*1.3)135 self.play(Write(exists_text_5))136 self.wait(2)137 138 # 恢复淡出文字和线条,并恢复点的颜色139 self.play(140 FadeOut(exists_text_5),141 FadeOut(n_line_5),142 FadeOut(n_label_5),143 FadeOut(highlight_circles_5),144 outside_after_5.animate.set_color(BLUE)145 )146 147 # Add demonstration for N = 20148 # N = 20149 n_line_20 = DashedLine(150 axes.c2p(20, -2),151 axes.c2p(20, 2),152 color=RED153 )154 n_label_20 = MathTex("N = 20", color=RED, font_size=24).next_to(n_line_20, UP, buff=0.1)155 156 self.play(Create(n_line_20), Write(n_label_20))157 self.wait(1)158 159 # Highlight points after N=20 that are outside the band (points at -1)160 outside_after_20 = VGroup()161 for n in range(20+1, 31): # n > N (20)162 if n % 2 == 1: # Odd n values correspond to points at -1163 outside_after_20.add(dots[n-1]) # Subtract 1 to convert n to index164 165 # Add highlight circles around the points166 highlight_circles_20 = VGroup()167 for point in outside_after_20:168 circle = Circle(radius=0.15, color=ORANGE, stroke_width=5).move_to(point)169 highlight_circles_20.add(circle)170 171 self.play(172 outside_after_20.animate.set_color(ORANGE),173 *[Create(circle) for circle in highlight_circles_20],174 run_time=1.5175 )176 self.wait(1)177 178 # Show that there are points outside the band after N=20179 exists_text_20 = Text("存在n=21,23,... > 20使得点在带外", 180 font="SimSun", font_size=20, color=ORANGE)181 exists_text_20.next_to(axes, DOWN, buff=0.3).shift(UP*1.3)182 self.play(Write(exists_text_20))183 self.wait(2)184 185 # 恢复淡出文字和线条,但不淡出点186 self.play(187 FadeOut(exists_text_20),188 FadeOut(n_line_20),189 FadeOut(n_label_20),190 FadeOut(highlight_circles_20),191 outside_after_20.animate.set_color(BLUE)192 )193 194 # Fade out first attempt but keep axes and dots195 self.play(196 FadeOut(limit_line_1),197 FadeOut(limit_label_1),198 FadeOut(epsilon_band_upper),199 FadeOut(epsilon_band_lower),200 FadeOut(epsilon_brace),201 FadeOut(epsilon_label),202 FadeOut(concept_text),203 odd_points.animate.set_color(BLUE)204 )205 self.wait(1)206 207 # Try to show convergence to L = -1208 limit_line_neg1 = DashedLine(209 axes.c2p(0, -1),210 axes.c2p(30, -1),211 color=GREEN212 )213 limit_label_neg1 = MathTex("L = -1", color=GREEN, font_size=30).next_to(limit_line_neg1, RIGHT, buff=0.2)214 215 self.play(Create(limit_line_neg1), Write(limit_label_neg1))216 self.wait(1)217 218 # Show epsilon band around L = -1219 epsilon_band_neg1_upper = DashedLine(220 axes.c2p(0, -1 + epsilon_val),221 axes.c2p(30, -1 + epsilon_val),222 color=GREEN223 )224 epsilon_band_neg1_lower = DashedLine(225 axes.c2p(0, -1 - epsilon_val),226 axes.c2p(30, -1 - epsilon_val),227 color=GREEN228 )229 230 epsilon_brace_neg1 = BraceBetweenPoints(231 axes.c2p(25, -1 - epsilon_val),232 axes.c2p(25, -1 + epsilon_val),233 color=GREEN234 )235 epsilon_label_neg1 = MathTex("2\\varepsilon = 1.0", color=GREEN, font_size=24).next_to(epsilon_brace_neg1, RIGHT, buff=0.1).shift(DOWN*0.2)236 237 self.play(238 Create(epsilon_band_neg1_upper),239 Create(epsilon_band_neg1_lower),240 GrowFromCenter(epsilon_brace_neg1),241 Write(epsilon_label_neg1)242 )243 self.wait(2)244 245 # Highlight points outside epsilon band (even terms at +1)246 even_points = VGroup(*[dots[i] for i in range(0, len(dots), 2)]) # Points at +1247 self.play(even_points.animate.set_color(RED), run_time=1.5)248 self.wait(1)249 250 # Emphasize the key concept again251 concept_text_neg1 = Text("关键概念:对于任意N,总存在n>N使得点在带外", font="SimSun", font_size=24)252 concept_text_neg1.next_to(axes, DOWN, buff=0.3).shift(UP*0.8)253 self.play(Write(concept_text_neg1))254 self.wait(2)255 256 # Demonstrate with N = 10257 n_line_10 = DashedLine(258 axes.c2p(10, -2),259 axes.c2p(10, 2),260 color=PURPLE261 )262 n_label_10 = MathTex("N = 10", color=PURPLE, font_size=24).next_to(n_line_10, UP, buff=0.1)263 264 self.play(Create(n_line_10), Write(n_label_10))265 self.wait(1)266 267 # Highlight points after N=10 that are outside the band (points at +1)268 # outside_after_10 = VGroup() # 已经在外部定义269 for n in range(10+1, 31): # n > N (10)270 if n % 2 == 0: # Even n values correspond to points at +1271 outside_after_10.add(dots[n-1]) # Subtract 1 to convert n to index272 273 # Add highlight circles around the points274 highlight_circles_10 = VGroup()275 for point in outside_after_10:276 circle = Circle(radius=0.15, color=ORANGE, stroke_width=5).move_to(point)277 highlight_circles_10.add(circle)278 279 self.play(280 outside_after_10.animate.set_color(ORANGE),281 *[Create(circle) for circle in highlight_circles_10],282 run_time=1.5283 )284 self.wait(1)285 286 # Show that there are points outside the band after N=10287 exists_text_10 = Text("存在n=12,14,16,... > 10使得点在带外", font="SimSun", font_size=20, color=ORANGE)288 exists_text_10.next_to(axes, DOWN, buff=0.3).shift(UP*1.3)289 self.play(Write(exists_text_10))290 self.wait(2)291 292 # 恢复淡出文字和线条,但不淡出点293 self.play(294 FadeOut(exists_text_10),295 FadeOut(n_line_10),296 FadeOut(n_label_10),297 FadeOut(highlight_circles_10),298 outside_after_10.animate.set_color(BLUE)299 # 不再淡出 outside_after_10300 )301 302 # N = 25 (moved from later to demonstrate not converging to -1)303 n_line_25 = DashedLine(304 axes.c2p(25, -2),305 axes.c2p(25, 2),306 color=GREEN307 )308 n_label_25 = MathTex("N = 25", color=GREEN, font_size=24).next_to(n_line_25, UP, buff=0.1)309 310 self.play(Create(n_line_25), Write(n_label_25))311 self.wait(1)312 313 # Highlight points after N=25 that are outside the band (points at +1)314 outside_after_25 = VGroup()315 for n in range(25+1, 31): # n > N (25)316 if n % 2 == 0: # Even n values correspond to points at +1317 outside_after_25.add(dots[n-1]) # Subtract 1 to convert n to index318 319 # Add highlight circles around the points320 highlight_circles_25 = VGroup()321 for point in outside_after_25:322 circle = Circle(radius=0.15, color=ORANGE, stroke_width=5).move_to(point)323 highlight_circles_25.add(circle)324 325 self.play(326 outside_after_25.animate.set_color(ORANGE),327 *[Create(circle) for circle in highlight_circles_25],328 run_time=1.5329 )330 self.wait(1)331 332 # Show that there are points outside the band after N=25333 exists_text_25 = Text("存在n=26,28,... > 25使得点在带外", 334 font="SimSun", font_size=20, color=ORANGE)335 exists_text_25.next_to(axes, DOWN, buff=0.3).shift(UP*1.3)336 self.play(Write(exists_text_25))337 self.wait(2)338 339 # Show conclusion that sequence does not converge to L=-1340 not_converge_neg1 = Text("数列不以-1为极限", font="SimSun", font_size=24, color=YELLOW)341 not_converge_neg1.next_to(exists_text_25, DOWN, buff=0.2).shift(DOWN*0.35)342 self.play(Write(not_converge_neg1))343 self.wait(2)344 345 # 不淡出任何直线图像和文字346 self.play(347 # 保留所有元素:坐标轴、点、极限线、epsilon带、文字等348 even_points.animate.set_color(BLUE)349 )350 351 final_conclusion = Text("数列 ", font="SimSun", font_size=24)352 formula = MathTex(r"a_n = (-1)^n", font_size=24)353 final_text = Text(" 没有极限", font="SimSun", font_size=24)354 final_conclusion_group = VGroup(final_conclusion, formula, final_text).arrange(RIGHT, buff=0.1)355 final_conclusion_group.next_to(not_converge_neg1, DOWN, buff=0.2) # 放在"数列不以-1为极限"正下方356 self.play(Write(final_conclusion_group))357 self.wait(2)358 359 # Show formal definition360 formal_def = MathTex(361 r"\exists \varepsilon > 0, \forall N, \exists n > N, |a_n - L| \geq \varepsilon",362 font_size=24363 )364 formal_def.next_to(final_conclusion_group, DOWN, buff=0.3)365 self.play(Write(formal_def))366 self.wait(3) 讲解
这个视频围绕「利用定义证明数列极限不存在」展开。画面把问题、图像和公式放在同一条理解路径中,让抽象关系先被看见。
开头先建立问题背景和主要对象,让观察从标题、坐标或第一组关系进入。
画面中出现的文字「证明数列极限不存在」给出视觉入口。随后画面通过对象创建、移动、淡入淡出和高亮,把抽象命题拆成可以跟随的步骤。
随后出现更具体的图像或公式提示,动画会把局部对象和整体结论联系起来。这里可以重点观察变量、曲线、区域或向量如何随镜头推进而变化。
核心公式可以写成:
这类公式可以和画面中的符号一一对应。
观察路径
观察路径可以分三步:先锁定「利用定义证明数列极限不存在」中的核心对象,尤其留意极限不存在、epsilon-N 定义、数列极限之间的联系;再跟随画面中变量、图像或向量的变化;最后回到公式或结论,判断局部变化如何支撑整体关系。
本页可以从极限不存在、epsilon-N 定义、数列极限这些概念进入,继续沿相邻问题观察同一类数学结构。