supremum_infimum.py
1from manim import *2import numpy as np3 4config.tex_template = TexTemplateLibrary.ctex5config.tex_template.add_to_preamble(r"\setCJKmainfont{STSong}")6 7class SupremumInfimum(Scene):8 def construct(self):9 # 创建标题10 title = Text("确界原理演示", font="STSong", font_size=48)11 12 self.play(Write(title))13 self.wait(1)14 self.play(FadeOut(title))15 16 # 创建坐标系17 axes = Axes(18 x_range=[0, 10, 1],19 y_range=[-1, 3, 0.5],20 axis_config={"include_tip": True},21 x_length=10,22 y_length=623 )24 25 x_label = axes.get_x_axis_label("n")26 y_label = axes.get_y_axis_label("x_n")27 28 self.play(Create(axes), Write(x_label), Write(y_label))29 30 # 创建一个有界但不单调的数列31 def sequence_func(x):32 return 2 + np.sin(x) * np.exp(-x/5)33 34 # 创建数列点和连线35 x_vals = np.linspace(0, 10, 50)36 points = [axes.coords_to_point(x, sequence_func(x)) for x in x_vals]37 curve = VMobject()38 curve.set_points_smoothly(points)39 curve.set_color(BLUE)40 41 dots = VGroup(*[Dot(point) for point in points[::5]])42 43 self.play(Create(curve), Create(dots))44 45 # 创建上确界线46 sup_value = 347 sup_line = DashedLine(48 axes.coords_to_point(0, sup_value),49 axes.coords_to_point(10, sup_value),50 color=RED51 )52 sup_label = MathTex(r"\sup x_n", color=RED).next_to(sup_line, RIGHT)53 54 # 创建下确界线55 inf_value = 156 inf_line = DashedLine(57 axes.coords_to_point(0, inf_value),58 axes.coords_to_point(10, inf_value),59 color=GREEN60 )61 inf_label = MathTex(r"\inf x_n", color=GREEN).next_to(inf_line, RIGHT)62 63 # 显示确界64 self.play(65 Create(sup_line),66 Write(sup_label)67 )68 self.play(69 Create(inf_line),70 Write(inf_label)71 )72 73 # 添加定义说明74 sup_def = Text(75 "上确界:数列的最小上界",76 font="STSong",77 color=RED78 ).scale(0.4)79 inf_def = Text(80 "下确界:数列的最大下界",81 font="STSong",82 color=GREEN83 ).scale(0.4)84 85 definitions = VGroup(sup_def, inf_def).arrange(DOWN, aligned_edge=LEFT)86 definitions.to_corner(UL)87 88 self.play(Write(definitions))89 90 # 演示上界性质91 epsilon = 0.292 point_above = Dot(axes.coords_to_point(5, sup_value + epsilon), color=RED)93 cross = Cross(point_above, color=RED)94 95 self.play(Create(point_above))96 self.play(Create(cross))97 self.wait(1)98 99 # 演示稠密性质100 for x in [2, 4, 6, 8]:101 point_near = Dot(102 axes.coords_to_point(x, sequence_func(x)),103 color=YELLOW104 )105 self.play(106 Create(point_near),107 FadeOut(point_near),108 run_time=0.5109 )110 111 self.wait(2)112 113def main():114 import os115 os.system("manim -pql supremum_infimum.py SupremumInfimum")116 117if __name__ == "__main__":118 main() 讲解
这个视频围绕「上确界的定义,你们开学了吗?」展开。画面把问题、图像和公式放在同一条理解路径中,让抽象关系先被看见。
开头先建立问题背景和主要对象,让观察从标题、坐标或第一组关系进入。
画面中出现的文字「确界原理演示」给出视觉入口。随后画面通过对象创建、移动、淡入淡出和高亮,把抽象命题拆成可以跟随的步骤。
随后出现更具体的图像或公式提示,动画会把局部对象和整体结论联系起来。这里可以重点观察变量、曲线、区域或向量如何随镜头推进而变化。
核心公式可以写成:
这类公式可以和画面中的符号一一对应。
观察路径
观察路径可以分三步:先锁定「上确界的定义,你们开学了吗?」中的核心对象,尤其留意确界原理、下确界、有界集合之间的联系;再跟随画面中变量、图像或向量的变化;最后回到公式或结论,判断局部变化如何支撑整体关系。
本页可以从确界原理、下确界、有界集合、实数完备性这些概念进入,继续沿相邻问题观察同一类数学结构。