A community-maintained Python framework for creating mathematical animations.
Nearly the final animations for diffyq part 3
Grant Sanderson62c2772982e7
diff --git a/active_projects/ode/all_part3_scenes.py b/active_projects/ode/all_part3_scenes.pyindex 36f9236ee..6fe249532 100644--- a/active_projects/ode/all_part3_scenes.py+++ b/active_projects/ode/all_part3_scenes.py@@ -10,8 +10,10 @@ SCENES_IN_ORDER = [LastChapterWrapper,ThreeConstraints,OceanOfPossibilities,- # TODOThreeMainObservations,+ SimpleCosExpGraph,+ AddMultipleSolutions,+ FourierSeriesIllustraiton,BreakDownAFunction,SineCurveIsUnrealistic,AnalyzeSineCurve,@@ -42,13 +44,17 @@ SCENES_IN_ORDER = [SlopeToHeatFlow,CloserLookAtStraightLine,WriteOutBoundaryCondition,- TeacherStudentsScene,+ SoWeGotNowhere,ManipulateSinExpSurface,HeatEquationFrame,ShowFreq1CosExpDecay,ShowFreq2CosExpDecay,ShowFreq4CosExpDecay,- CompareFreqDecays,+ CompareFreqDecays1to2,+ CompareFreqDecays1to4,+ CompareFreqDecays2to4,+ ShowHarmonics,+ ShowHarmonicSurfaces,# SimpleCosExpGraph,# AddMultipleSolutions,diff --git a/active_projects/ode/part2/heat_equation.py b/active_projects/ode/part2/heat_equation.pyindex ebfdad39c..f50c1f415 100644--- a/active_projects/ode/part2/heat_equation.py+++ b/active_projects/ode/part2/heat_equation.py@@ -185,6 +185,7 @@ class BringTwoRodsTogether(Scene):y_label = axes.get_y_axis_label("\\text{Temperature}")y_label.to_edge(UP)+ axes.y_axis.label = y_labelaxes.y_axis.add(y_label)axes.y_axis.add_numbers(*range(20, 100, 20)diff --git a/active_projects/ode/part3/discrete_case.py b/active_projects/ode/part3/discrete_case.pyindex ae710aaff..7d0678133 100644--- a/active_projects/ode/part3/discrete_case.py+++ b/active_projects/ode/part3/discrete_case.py@@ -17,6 +17,7 @@ class ShowNewRuleAtDiscreteBoundary(DiscreteSetup):(3, 0.5),(4, 0.3),],+ "v_line_class": DashedLine,"v_line_config": {},@@ -183,7 +184,7 @@ class ShowNewRuleAtDiscreteBoundary(DiscreteSetup):bottom = dot.get_bottom()x = x_axis.p2n(bottom)proj_point = x_axis.n2p(x)- return DashedLine(+ return self.v_line_class(proj_point, bottom,**self.v_line_config,)@@ -294,9 +295,9 @@ class FlatEdgesForDiscreteEvolution(DiscreteEvolutionPoint1):class FlatEdgesForDiscreteEvolutionTinySteps(FlatEdgesForDiscreteEvolution):CONFIG = {"step_size": 0.025,- "wait_time": 0,+ "wait_time": 10,+ "v_line_class": Line,"v_line_config": {- "positive_space_ratio": 1,"stroke_opacity": 0.5,}}diff --git a/active_projects/ode/part3/staging.py b/active_projects/ode/part3/staging.pyindex 9b6a31c80..6bde259c6 100644--- a/active_projects/ode/part3/staging.py+++ b/active_projects/ode/part3/staging.py@@ -233,24 +233,25 @@ class ManyCousinsOfFourierThings(Scene):class FourierSeriesIllustraiton(Scene):CONFIG = {"n_range": range(1, 31, 2),- }-- def construct(self):- n_range = self.n_range-- axes1 = Axes(- number_line_config={+ "axes_config": {+ "number_line_config": {"include_tip": False,},- x_axis_config={+ "x_axis_config": {"tick_frequency": 1 / 4,"unit_size": 4,},- x_min=0,- x_max=1,- y_min=-1,- y_max=1,- )+ "x_min": 0,+ "x_max": 1,+ "y_min": -1,+ "y_max": 1,+ }+ }++ def construct(self):+ n_range = self.n_range++ axes1 = Axes(**self.axes_config)axes1.x_axis.add_numbers(0.5, 1,number_config={"num_decimal_places": 1}@@ -263,6 +264,7 @@ class FourierSeriesIllustraiton(Scene):group = VGroup(axes1, arrow, axes2)group.arrange(RIGHT, buff=LARGE_BUFF)group.shift(2 * UP)+ group.shift_onto_screen()sine_graphs = VGroup(*[axes1.get_graph(self.generate_nth_func(n))@@ -393,7 +395,14 @@ class FourierSeriesIllustraiton(Scene):class FourierSeriesOfLineIllustration(FourierSeriesIllustraiton):CONFIG = {- "n_range": range(1, 31, 2)+ "n_range": range(1, 31, 2),+ "axes_config": {+ "y_axis_config": {+ "unit_size": 2,+ "tick_frequency": 0.25,+ "numbers_with_elongated_ticks": [-1, 1],+ }+ }}def get_sum_tex(self):@@ -661,7 +670,7 @@ class InvestmentGrowth(Scene):"k": 0.05,"k_tex": "0.05","total_time": 43,- "time_rate": 4,+ "time_rate": 3,}def construct(self):@@ -752,7 +761,7 @@ class InvestmentGrowth(Scene):self.add(time_tracker)self.play(FadeInFromDown(ode))- self.wait(2)+ self.wait(6)self.play(FadeInFrom(exp, UP))self.wait(2)self.play(@@ -908,6 +917,7 @@ class BoundaryConditionInterlude(Scene):path_arc=60 * DEGREES,)+ # BC detourself.add(background)self.add(storyline[0])for im1, im2, arrow in zip(storyline, storyline[1:], storyline.arrows):@@ -932,6 +942,66 @@ class BoundaryConditionInterlude(Scene):self.play(ShowCreation(new_mid_arrow))self.wait()+ # From BC to next step+ rect1 = bc_image[2].copy()+ rect2 = storyline[1][2].copy()+ rect3 = storyline[2][2].copy()+ for rect in rect1, rect2, rect3:+ rect.set_stroke(YELLOW, 3)++ self.play(FadeIn(rect1))+ kw = {"path_arc": 60 * DEGREES}+ self.play(+ LaggedStart(+ Transform(rect1, rect2, **kw),+ # TransformFromCopy(rect1, rect3, **kw),+ lag_ratio=0.4,+ )+ )+ self.play(+ FadeOut(rect1),+ # FadeOut(rect3),+ )++ # Reorganize images+ im1, im3, im4 = storyline+ im2 = bc_image+ l_group = Group(im1, im2)+ r_group = Group(im3, im4)+ for group in l_group, r_group:+ group.generate_target()+ group.target.arrange(DOWN, buff=LARGE_BUFF)+ group.target.center()++ l_group.target.to_edge(LEFT)+ r_group.target.move_to(+ FRAME_WIDTH * RIGHT / 4+ )+ brace = Brace(r_group.target, LEFT)+ nv_text = brace.get_text("Next\\\\video")+ nv_text.scale(1.5, about_edge=RIGHT)+ nv_text.set_color(YELLOW)+ brace.set_color(YELLOW)++ arrows = VGroup(+ storyline.arrows,+ new_mid_arrow,+ )++ self.play(+ LaggedStart(+ MoveToTarget(l_group),+ MoveToTarget(r_group),+ lag_ratio=0.3,+ ),+ FadeOut(arrows),+ )+ self.play(+ GrowFromCenter(brace),+ FadeInFrom(nv_text, RIGHT)+ )+ self.wait()+def get_main_storyline(self):images = Group(self.get_sine_curve_image(),@@ -1012,3 +1082,149 @@ class GiantCross(Scene):)self.wait()++class EndScreen(PatreonEndScreen):+ CONFIG = {+ "specific_patrons": [+ "1stViewMaths",+ "Adrian Robinson",+ "Alexis Olson",+ "Andreas Benjamin Brössel",+ "Andrew Busey",+ "Ankalagon",+ "Antoine Bruguier",+ "Antonio Juarez",+ "Arjun Chakroborty",+ "Art Ianuzzi",+ "Awoo",+ "Ayan Doss",+ "AZsorcerer",+ "Barry Fam",+ "Bernd Sing",+ "Boris Veselinovich",+ "Brian Staroselsky",+ "Charles Southerland",+ "Chris Connett",+ "Christian Kaiser",+ "Clark Gaebel",+ "Cooper Jones",+ "Danger Dai",+ "Daniel Pang",+ "Dave B",+ "Dave Kester",+ "David B. Hill",+ "David Clark",+ "Delton Ding",+ "eaglle",+ "Empirasign",+ "emptymachine",+ "Eric Younge",+ "Eryq Ouithaqueue",+ "Federico Lebron",+ "Fernando Via Canel",+ "Giovanni Filippi",+ "Hal Hildebrand",+ "Hitoshi Yamauchi",+ "Isaac Jeffrey Lee",+ "j eduardo perez",+ "Jacob Hartmann",+ "Jacob Magnuson",+ "Jameel Syed",+ "Jason Hise",+ "Jeff Linse",+ "Jeff Straathof",+ "John C. Vesey",+ "John Griffith",+ "John Haley",+ "John V Wertheim",+ "Jonathan Eppele",+ "Kai-Siang Ang",+ "Kanan Gill",+ "Kartik Cating-Subramanian",+ "L0j1k",+ "Lee Redden",+ "Linh Tran",+ "Ludwig Schubert",+ "Magister Mugit",+ "Mark B Bahu",+ "Martin Price",+ "Mathias Jansson",+ "Matt Langford",+ "Matt Roveto",+ "Matthew Bouchard",+ "Matthew Cocke",+ "Michael Faust",+ "Michael Hardel",+ "Mirik Gogri",+ "Mustafa Mahdi",+ "Márton Vaitkus",+ "Nero Li",+ "Nikita Lesnikov",+ "Omar Zrien",+ "Owen Campbell-Moore",+ "Patrick",+ "Peter Ehrnstrom",+ "RedAgent14",+ "rehmi post",+ "Richard Comish",+ "Ripta Pasay",+ "Rish Kundalia",+ "Robert Teed",+ "Roobie",+ "Ryan Williams",+ "Sebastian Garcia",+ "Solara570",+ "Stephan Arlinghaus",+ "Steven Siddals",+ "Stevie Metke",+ "Tal Einav",+ "Ted Suzman",+ "Thomas Tarler",+ "Tianyu Ge",+ "Tom Fleming",+ "Valeriy Skobelev",+ "Xuanji Li",+ "Yavor Ivanov",+ "YinYangBalance.Asia",+ "Zach Cardwell",+ "Luc Ritchie",+ "Britt Selvitelle",+ "David Gow",+ "J",+ "Jonathan Wilson",+ "Joseph John Cox",+ "Magnus Dahlström",+ "Randy C. Will",+ "Ryan Atallah",+ "Lukas -krtek.net- Novy",+ "Jordan Scales",+ "Ali Yahya",+ "Arthur Zey",+ "Atul S",+ "dave nicponski",+ "Evan Phillips",+ "Joseph Kelly",+ "Kaustuv DeBiswas",+ "Lambda AI Hardware",+ "Lukas Biewald",+ "Mark Heising",+ "Mike Coleman",+ "Nicholas Cahill",+ "Peter Mcinerney",+ "Quantopian",+ "Roy Larson",+ "Scott Walter, Ph.D.",+ "Yana Chernobilsky",+ "Yu Jun",+ "D. Sivakumar",+ "Richard Barthel",+ "Burt Humburg",+ "Matt Russell",+ "Scott Gray",+ "soekul",+ "Tihan Seale",+ "Juan Benet",+ "Vassili Philippov",+ "Kurt Dicus",+ ],+ }diff --git a/active_projects/ode/part3/temperature_graphs.py b/active_projects/ode/part3/temperature_graphs.pyindex 28460ebbc..1fea7a6ec 100644--- a/active_projects/ode/part3/temperature_graphs.py+++ b/active_projects/ode/part3/temperature_graphs.py@@ -676,7 +676,7 @@ class OceanOfPossibilities(TemperatureGraphScene):axes.add(axes.input_plane)axes.scale(0.9)axes.center()- axes.shift(OUT + RIGHT)+ axes.shift(0.5 * OUT + RIGHT)self.add(axes)self.axes = axes@@ -687,7 +687,7 @@ class OceanOfPossibilities(TemperatureGraphScene):# Parameters for surface functioninitial_As = [2] + [- random.choice([-1, 1]) / n+ 0.8 * random.choice([-1, 1]) / nfor n in range(1, 20)]A_trackers = Group(*[@@ -1555,6 +1555,7 @@ class SimulateRealSineCurve(ShowEvolvingTempGraphWithArrows):"graph_x_min": 0,"graph_x_max": TAU,"arrow_xs": np.linspace(0, TAU, 13),+ "rod_opacity": 0.5,"wait_time": 30,"alpha": 0.5,}@@ -1590,7 +1591,7 @@ class SimulateRealSineCurve(ShowEvolvingTempGraphWithArrows):def add_rod(self):super().add_rod()- self.rod.set_opacity(0.5)+ self.rod.set_opacity(self.rod_opacity)self.rod.set_stroke(width=0)def initial_function(self, x):@@ -1796,6 +1797,24 @@ class FlatEdgesContinuousEvolution(ShowEvolvingTempGraphWithArrows):return ShowEvolvingTempGraphWithArrows.initial_function(self, x)+class MoreAccurateTempFlowWithArrows(ShowEvolvingTempGraphWithArrows):+ CONFIG = {+ "arrow_scale_factor": 1,+ "max_magnitude": 1,+ "freq_amplitude_pairs": [+ (1, 0.5),+ (2, 1),+ (3, 0.5),+ (4, 0.3),+ ],+ }++ def setup_axes(self):+ super().setup_axes()+ y_axis = self.axes.y_axis+ y_axis.remove(y_axis.label)++class SlopeToHeatFlow(FlatEdgesContinuousEvolution):CONFIG = {"wait_time": 20,@@ -2054,6 +2073,8 @@ class ManipulateSinExpSurface(TemperatureGraphScene):"^2": WHITE,},},+ "initial_phi": -90 * DEGREES,+ "initial_omega": 1,}def construct(self):@@ -2104,12 +2125,7 @@ class ManipulateSinExpSurface(TemperatureGraphScene):def add_sine_wave(self):self.initialize_parameter_trackers()- graph = always_redraw(- lambda: self.get_time_slice_graph(- self.axes, self.func,- t=self.t_tracker.get_value(),- )- )+ graph = self.get_graph()sin_label = TexMobject("\\sin\\left({x}\\right)",**self.tex_mobject_config,@@ -2224,20 +2240,15 @@ class ManipulateSinExpSurface(TemperatureGraphScene):def show_cos_exp_surface(self):axes = self.axes- max_t_tracker = ValueTracker(0)- surface = always_redraw(- lambda: self.get_surface(- self.axes, self.func,- v_max=max_t_tracker.get_value(),- )- )+ surface = self.get_cos_exp_surface()self.add(surface)+ surface.max_t_tracker.set_value(0)self.move_camera(phi=85 * DEGREES,theta=-80 * DEGREES,added_anims=[ApplyMethod(- max_t_tracker.set_value,+ surface.max_t_tracker.set_value,axes.y_max,run_time=4,),@@ -2400,10 +2411,34 @@ class ManipulateSinExpSurface(TemperatureGraphScene):#def initialize_parameter_trackers(self):- self.phi_tracker = ValueTracker(-90 * DEGREES)- self.omega_tracker = ValueTracker(1)+ self.phi_tracker = ValueTracker(+ self.initial_phi+ )+ self.omega_tracker = ValueTracker(+ self.initial_omega+ )self.t_tracker = ValueTracker(0)+ def get_graph(self):+ return always_redraw(+ lambda: self.get_time_slice_graph(+ self.axes, self.func,+ t=self.t_tracker.get_value(),+ )+ )++ def get_cos_exp_surface(self):+ max_t_tracker = ValueTracker(self.axes.y_max)+ surface = always_redraw(+ lambda: self.get_surface(+ self.axes,+ self.func,+ v_max=max_t_tracker.get_value(),+ )+ )+ surface.max_t_tracker = max_t_tracker+ return surface+def func(self, x, t):phi = self.phi_tracker.get_value()omega = self.omega_tracker.get_value()@@ -2441,17 +2476,26 @@ class ManipulateSinExpSurface(TemperatureGraphScene):class ShowFreq1CosExpDecay(ManipulateSinExpSurface):CONFIG = {"freq": 1,- "alpha": 0.1,+ "alpha": 0.2,}def construct(self):self.setup_axes()+ self.add_back_y_axis()self.initialize_parameter_trackers()self.phi_tracker.set_value(0)- self.omega_tracker.set_value(self.freq)+ self.omega_tracker.set_value(+ self.freq * TAU / 10,+ )#self.show_decay()+ def add_back_y_axis(self):+ axes = self.axes+ self.add(axes.y_axis)+ self.remove(axes.y_axis.numbers)+ self.remove(axes.y_axis.label)+def show_decay(self):axes = self.axest_tracker = self.t_tracker@@ -2472,16 +2516,16 @@ class ShowFreq1CosExpDecay(ManipulateSinExpSurface):plane = self.get_const_time_plane(axes)self.add(surface, plane, graph)- self.add(axes.y_axis)+self.set_camera_orientation(- phi=85 * DEGREES,- theta=-80 * DEGREES,+ phi=80 * DEGREES,+ theta=-85 * DEGREES,)+ self.begin_ambient_camera_rotation(rate=0.01)self.play(t_tracker.set_value, t_max,plane.t_tracker.set_value, t_max,- # run_time=t_max,- run_time=5,+ run_time=t_max,rate_func=linear,)@@ -2496,3 +2540,232 @@ class ShowFreq4CosExpDecay(ShowFreq1CosExpDecay):CONFIG = {"freq": 4,}+++class ShowHarmonics(SimulateRealSineCurve):+ CONFIG = {+ "rod_opacity": 0.75,+ "initial_omega": 1.27,+ "default_n_rod_pieces": 32,+ }++ def construct(self):+ self.add_axes()+ self.add_graph()+ self.add_rod()+ self.rod.add_updater(self.color_rod_by_graph)+ #+ self.show_formula()++ def add_graph(self):+ omega_tracker = ValueTracker(self.initial_omega)+ get_omega = omega_tracker.get_value+ graph = always_redraw(+ lambda: self.axes.get_graph(+ lambda x: np.cos(get_omega() * x),+ x_min=self.graph_x_min,+ x_max=self.graph_x_max,+ step_size=self.step_size,+ discontinuities=[5],+ ).color_using_background_image("VerticalTempGradient")+ )++ self.add(graph)+ self.graph = graph+ self.omega_tracker = omega_tracker++ def show_formula(self):+ rod = self.rod+ graph = self.graph+ axes = self.axes+ omega_tracker = self.omega_tracker+ L = TAU++ formula = TexMobject(+ "=", "\\cos\\left(",+ "2(\\pi / L)", "\\cdot", "{x}",+ "\\right)",+ tex_to_color_map={+ "{x}": GREEN,+ }+ )+ formula.next_to(+ self.axes.y_axis.label, RIGHT, SMALL_BUFF+ )+ omega_part = formula.get_part_by_tex("\\pi")+ omega_brace = Brace(omega_part, DOWN)+ omega = TexMobject("\\omega")+ omega.set_color(MAROON_B)+ omega.next_to(omega_brace, DOWN, SMALL_BUFF)+ formula.remove(omega_part)++ pi_over_L = TexMobject("(\\pi / L)")+ pi_over_L.move_to(omega_part)+ pi_over_L.match_color(omega)++ self.add(formula)+ self.add(omega_brace)+ self.add(omega)++ self.remove(graph)+ self.play(GrowFromEdge(rod, LEFT))+ self.play(+ ShowCreationThenFadeAround(axes.x_axis.label)+ )+ self.wait()+ self.play(FadeIn(graph))+ self.play(FadeInFromDown(pi_over_L))+ self.play(+ omega_tracker.set_value, PI / L,+ run_time=2+ )+ self.wait()++ # Show x+ x_tracker = ValueTracker(0)+ tip = ArrowTip(+ start_angle=-90 * DEGREES,+ color=WHITE,+ )+ tip.add_updater(lambda m: m.move_to(+ axes.x_axis.n2p(x_tracker.get_value()),+ DOWN,+ ))+ x_sym = TexMobject("x")+ x_sym.set_color(GREEN)+ x_sym.add_background_rectangle(buff=SMALL_BUFF)+ x_sym.add_updater(lambda m: m.next_to(tip, UP, SMALL_BUFF))++ self.play(+ Write(tip),+ Write(x_sym),+ )+ self.play(+ x_tracker.set_value, L,+ run_time=3,+ )+ self.wait()+ self.play(TransformFromCopy(+ x_sym, formula.get_part_by_tex("{x}")+ ))+ self.play(+ FadeOut(tip),+ FadeOut(x_sym),+ )++ # Harmonics+ pi_over_L.generate_target()+ n_sym = Integer(2)+ n_sym.match_color(pi_over_L)+ group = VGroup(n_sym, pi_over_L.target)+ group.arrange(RIGHT, buff=SMALL_BUFF)+ group.move_to(pi_over_L)++ self.play(+ MoveToTarget(pi_over_L),+ FadeInFromDown(n_sym),+ ApplyMethod(+ omega_tracker.set_value, 2 * PI / L,+ run_time=2,+ )+ )+ self.wait()+ for n in [*range(3, 9), 0]:+ new_n_sym = Integer(n)+ new_n_sym.move_to(n_sym, DR)+ new_n_sym.match_style(n_sym)+ self.play(+ FadeOutAndShift(n_sym, UP),+ FadeInFrom(new_n_sym, DOWN),+ omega_tracker.set_value, n * PI / L,+ )+ self.wait()+ n_sym = new_n_sym++ #+ def add_labels_to_axes(self):+ x_axis = self.axes.x_axis+ L = TexMobject("L")+ L.next_to(x_axis.get_end(), DOWN)+ x_axis.add(L)+ x_axis.label = L+++class ShowHarmonicSurfaces(ManipulateSinExpSurface):+ CONFIG = {+ "alpha": 0.2,+ "initial_phi": 0,+ "initial_omega": PI / 10,+ "n_iterations": 8,+ "default_surface_config": {+ "resolution": (40, 30),+ "surface_piece_config": {+ "stroke_width": 0.5,+ }+ }+ }++ def construct(self):+ self.setup_axes()+ self.initialize_parameter_trackers()+ self.add_surface()+ self.add_graph()+ self.show_all_harmonic_surfaces()++ def setup_axes(self):+ super().setup_axes()+ self.add(self.axes.y_axis)+ self.set_camera_orientation(+ phi=82 * DEGREES,+ theta=-80 * DEGREES,+ )++ def add_surface(self):+ self.surface = self.get_cos_exp_surface()+ self.add(self.surface)++ def add_graph(self):+ self.graph = self.get_graph()+ self.add(self.graph)++ def show_all_harmonic_surfaces(self):+ omega_tracker = self.omega_tracker+ formula = self.get_formula(str(1))+ L = self.axes.x_max++ self.begin_ambient_camera_rotation(rate=0.01)+ self.add_fixed_in_frame_mobjects(formula)+ self.wait(2)+ for n in range(2, self.n_iterations):+ if n > 5:+ n_str = "n"+ else:+ n_str = str(n)+ new_formula = self.get_formula(n_str)+ self.play(+ Transform(formula, new_formula),+ ApplyMethod(+ omega_tracker.set_value,+ n * PI / L+ ),+ )+ self.wait(3)++ #+ def get_formula(self, n_str):+ n_str = "{" + n_str + "}"+ result = TexMobject(+ "\\cos\\left(",+ n_str, "(", "\\pi / L", ")", "{x}"+ "\\right)"+ "e^{-\\alpha (", n_str, "\\pi / L", ")^2",+ "{t}}",+ tex_to_color_map={+ "{x}": GREEN,+ "{t}": YELLOW,+ "\\pi / L": MAROON_B,+ n_str: MAROON_B,+ }+ )+ result.to_edge(UP)+ return resultdiff --git a/active_projects/ode/part3/wordy_scenes.py b/active_projects/ode/part3/wordy_scenes.pyindex 50022c996..e32792cf3 100644--- a/active_projects/ode/part3/wordy_scenes.py+++ b/active_projects/ode/part3/wordy_scenes.py@@ -5,6 +5,10 @@ from active_projects.ode.part2.wordy_scenes import *class ThreeMainObservations(Scene):def construct(self):fourier = ImageMobject("Joseph Fourier")+ name = TextMobject("Joseph Fourier")+ name.match_width(fourier)+ name.next_to(fourier, DOWN, SMALL_BUFF)+ fourier.add(name)fourier.set_height(5)fourier.to_corner(DR)fourier.shift(LEFT)@@ -18,18 +22,15 @@ class ThreeMainObservations(Scene):observations = VGroup(TextMobject("1)",- # "Sine waves",- # "H",- # "Heat equation",+ "Sine = Nice",),TextMobject("2)",- # "Linearity"+ "Linearity"),TextMobject("3)",- # "Any$^{*}$ function is\\\\",- # "a sum of sine waves",+ "Fourier series"),)# heart = SuitSymbol("hearts")@@ -43,7 +44,7 @@ class ThreeMainObservations(Scene):observations.arrange(DOWN,aligned_edge=LEFT,- buff=LARGE_BUFF,+ buff=2 * LARGE_BUFF,)observations.set_height(FRAME_HEIGHT - 2)observations.to_corner(UL, buff=LARGE_BUFF)@@ -52,7 +53,7 @@ class ThreeMainObservations(Scene):self.play(ShowCreation(bubble))self.wait()self.play(LaggedStart(*[- TransformFromCopy(bubble, observation)+ TransformFromCopy(bubble, observation[0])for observation in observations], lag_ratio=0.2))self.play(@@ -60,6 +61,9 @@ class ThreeMainObservations(Scene):FadeOut(bubble),)self.wait()+ for obs in observations:+ self.play(FadeInFrom(obs[1], LEFT))+ self.wait()class LastChapterWrapper(Scene):@@ -158,6 +162,34 @@ class ThreeConstraints(WriteHeatEquationTemplate):self.bc_paren = bc_paren+class RectAroundEquation(WriteHeatEquationTemplate):+ def construct(self):+ eq = self.get_d1_equation()+ self.play(ShowCreationThenFadeAround(eq))+++class BorderRect(Scene):+ def construct(self):+ rect = FullScreenFadeRectangle()+ rect.set_stroke(WHITE, 3)+ rect.set_fill(opacity=0)+ self.add(rect)+++class SecondDerivativeOfSine(Scene):+ def construct(self):+ equation = TexMobject(+ "{d^2 \\over d{x}^2}",+ "\\cos\\left({x}\\right) =",+ "-\\cos\\left({x}\\right)",+ tex_to_color_map={+ "{x}": GREEN,+ }+ )++ self.add(equation)++class EquationAboveSineAnalysis(WriteHeatEquationTemplate):def construct(self):equation = self.get_d1_equation()@@ -214,6 +246,31 @@ class EquationAboveSineAnalysis(WriteHeatEquationTemplate):self.wait()+class ExpVideoWrapper(Scene):+ def construct(self):+ self.add(FullScreenFadeRectangle(+ fill_color=DARKER_GREY,+ fill_opacity=1,+ ))++ screen = ImageMobject("eoc_chapter5_thumbnail")+ screen.set_height(6)+ rect = SurroundingRectangle(screen, buff=0)+ rect.set_stroke(WHITE, 2)+ screen.add(rect)+ title = TextMobject("Need a refresher?")+ title.scale(1.5)+ title.to_edge(UP)+ screen.next_to(title, DOWN)++ screen.center()+ self.play(+ # FadeInFrom(title, LEFT),+ FadeInFrom(screen, DOWN),+ )+ self.wait()++class ShowSinExpDerivatives(WriteHeatEquationTemplate):CONFIG = {"tex_mobject_config": {@@ -653,10 +710,62 @@ class HeatEquationFrame(WriteHeatEquationTemplate):self.wait()-class CompareFreqDecays(Scene):+class CompareFreqDecays1to2(Scene):CONFIG = {"freqs": [1, 2]}def construct(self):- pass+ background = FullScreenFadeRectangle(+ fill_color=DARKER_GREY,+ fill_opacity=1,+ )++ screens = VGroup(*[+ ScreenRectangle(+ height=4,+ fill_color=BLACK,+ fill_opacity=1,+ stroke_width=1,+ stroke_color=WHITE,+ )+ for x in range(2)+ ])+ screens.arrange(RIGHT)+ screens.set_width(FRAME_WIDTH - 1)++ formulas = VGroup(*[+ self.get_formula(freq)+ for freq in self.freqs+ ])+ for formula, screen in zip(formulas, screens):+ formula.next_to(screen, UP)++ self.add(background)+ self.add(screens)+ self.add(formulas)+ self.wait()++ def get_formula(self, freq):+ f_str = str(freq)+ return TexMobject(+ "\\cos\\left(%s \\cdot {x}\\right)" % f_str,+ "e^{-\\alpha \\cdot %s^2 \\cdot {t}}" % f_str,+ tex_to_color_map={+ "{x}": GREEN,+ "{t}": YELLOW,+ f_str: MAROON_B,+ }+ )+++class CompareFreqDecays1to4(CompareFreqDecays1to2):+ CONFIG = {+ "freqs": [1, 4],+ }+++class CompareFreqDecays2to4(CompareFreqDecays1to2):+ CONFIG = {+ "freqs": [2, 4],+ }