A community-maintained Python framework for creating mathematical animations.
Further eoc8 progress
Grant Sanderson0b7f51836656
diff --git a/eoc/chapter2.py b/eoc/chapter2.pyindex aa44822b8..e8ad119a5 100644--- a/eoc/chapter2.py+++ b/eoc/chapter2.py@@ -402,7 +402,7 @@ class IntroduceCar(Scene):class GraphCarTrajectory(GraphScene):CONFIG = {"x_min" : 0,- "x_max" : 10.01,+ "x_max" : 10,"x_labeled_nums" : range(1, 11),"x_axis_label" : "Time (seconds)","y_min" : 0,diff --git a/eoc/chapter8.py b/eoc/chapter8.pyindex d6a5c99b9..6e4f11c2f 100644--- a/eoc/chapter8.py+++ b/eoc/chapter8.py@@ -457,11 +457,7 @@ class Antiderivative(PiCreatureScene):functions = self.get_functions("t^2", "2t")alt_functions = self.get_functions("???", "t(8-t)")top_arc, bottom_arc = arcs = self.get_arcs(functions)- derivative = TextMobject("Derivative")- derivative.next_to(top_arc, UP)- antiderivative = TextMobject("``Antiderivative''")- antiderivative.next_to(bottom_arc, DOWN)- antiderivative.highlight(bottom_arc.get_color())+ derivative, antiderivative = self.get_arc_labels(arcs)group = VGroup(functions, arcs, derivative, antiderivative)self.add(functions, top_arc, derivative)@@ -488,7 +484,6 @@ class Antiderivative(PiCreatureScene):)self.dither()-def get_functions(self, left_tex, right_tex):left = TexMobject(left_tex)left.shift(2*LEFT)@@ -517,6 +512,16 @@ class Antiderivative(PiCreatureScene):return arcs+ def get_arc_labels(self, arcs):+ top_arc, bottom_arc = arcs+ derivative = TextMobject("Derivative")+ derivative.next_to(top_arc, UP)+ antiderivative = TextMobject("``Antiderivative''")+ antiderivative.next_to(bottom_arc, DOWN)+ antiderivative.highlight(bottom_arc.get_color())++ return VGroup(derivative, antiderivative)+class AreaUnderVGraph(PlotVelocity):def construct(self):self.setup_axes()@@ -1492,23 +1497,26 @@ class Chapter1Wrapper(Chapter2Wrapper):"title" : "Essence of calculus, chapter 1",}-class AreaIsDerivative(PlotVelocity):+class AreaIsDerivative(PlotVelocity, ReconfigurableScene):CONFIG = {"y_axis_label" : "",- # "num_rects" : 250,- "num_rects" : 20,+ "num_rects" : 250,+ "dT" : 0.25,}def setup(self):PlotVelocity.setup(self)+ ReconfigurableScene.setup(self)self.setup_axes()self.add(*self.get_v_graph_and_label())+ self.x_axis_label_mob.shift(MED_LARGE_BUFF*DOWN)+ self.v_graph_label.shift(MED_LARGE_BUFF*DOWN)self.foreground_mobjects = []def construct(self):- self.force_skipping()-self.introduce_variable_area()self.write_integral()+ self.nudge_input()+ self.show_rectangle_approximation()def introduce_variable_area(self):area = self.area = self.get_area(0, 6)@@ -1527,21 +1535,25 @@ class AreaIsDerivative(PlotVelocity):def write_integral(self):integral = TexMobject("\\int", "^T", "_0", "v(t)", "\\,dt")integral.to_corner(UP+RIGHT)+ integral.shift(2*LEFT)top_T = integral.get_part_by_tex("T")moving_T = self.T_label_group[0]- s_T = TexMobject("s(T) = ")+ s_T = TexMobject("s(T)", "= ")+ s_T.highlight_by_tex("s", DISTANCE_COLOR)s_T.next_to(integral, LEFT)int_arrow, s_arrow = [Arrow(mob.get_left(), self.area.get_center(),color = WHITE- ),+ )for mob in integral, s_T]- self.revert_to_original_skipping_status()+ distance_word = TextMobject("Distance")+ distance_word.move_to(self.area)+self.play(Write(integral))self.play(ShowCreation(int_arrow))self.foreground_mobjects.append(int_arrow)@@ -1549,7 +1561,7 @@ class AreaIsDerivative(PlotVelocity):self.change_area_bounds(new_t_max = 8,rate_func = there_and_back,- run_time = 2,+ run_time = 3,)self.play(Indicate(top_T))self.play(ReplacementTransform(@@ -1558,13 +1570,133 @@ class AreaIsDerivative(PlotVelocity):self.change_area_bounds(new_t_max = 3,rate_func = there_and_back,+ run_time = 3+ )+ self.dither()+ self.play(Write(distance_word, run_time = 2))+ self.play(+ ReplacementTransform(int_arrow, s_arrow),+ FadeIn(s_T)+ )+ self.dither()+ self.play(FadeOut(distance_word))+ self.change_area_bounds(new_t_max = 0, run_time = 2)+ self.change_area_bounds(+ new_t_max = 8,+ rate_func = None,+ run_time = 7.9,+ )+ self.dither()+ self.change_area_bounds(new_t_max = 5)+ self.dither()++ def nudge_input(self):+ dark_area = self.area.copy()+ dark_area.set_fill(BLACK, opacity = 0.5)+ curr_T = self.x_axis.point_to_number(self.area.get_right())+ new_T = curr_T + self.dT++ rect = Rectangle(+ stroke_width = 0,+ fill_color = YELLOW,+ fill_opacity = 0.75+ )+ rect.replace(+ VGroup(+ VectorizedPoint(self.coords_to_point(new_T, 0)),+ self.right_v_line,+ ),+ stretch = True+ )++ dT_brace = Brace(rect, DOWN, buff = 0)+ dT_label = dT_brace.get_text("$dT$", buff = SMALL_BUFF)+ dT_label_group = VGroup(dT_label, dT_brace)++ ds_label = TexMobject("ds")+ ds_label.next_to(rect, RIGHT, LARGE_BUFF, UP)+ ds_label.highlight(DISTANCE_COLOR)+ ds_arrow = Arrow(ds_label.get_left(), rect.get_left())+ ds_arrow.highlight(WHITE)++ v_brace = Brace(rect, LEFT, buff = SMALL_BUFF)+ v_T_label = v_brace.get_text("$v(T)$", buff = SMALL_BUFF)++ self.change_area_bounds(new_t_max = new_T)+ self.play(+ FadeIn(dark_area),+ *map(Animation, self.foreground_mobjects)+ )+ self.play(+ FadeOut(self.T_label_group),+ FadeIn(dT_label_group)+ )+ self.dither()+ self.play(Write(ds_label))+ self.play(ShowCreation(ds_arrow))+ self.dither(2)+ self.play(GrowFromCenter(v_brace))+ self.play(ReplacementTransform(+ self.v_graph_label.get_part_by_tex("v").copy(),+ v_T_label,run_time = 2+ ))+ self.dither()+ self.play(Indicate(dT_label))+ self.dither()++ self.rect = rect+ self.dT_label_group = dT_label_group+ self.v_T_label_group = VGroup(v_T_label, v_brace)+ self.dark_area = dark_area+ self.ds_label = ds_label+ self.ds_arrow = ds_arrow++ def show_rectangle_approximation(self):+ formula1 = TexMobject("ds", "=", "v(T)", "dT")+ formula2 = TexMobject("{ds", "\\over\\,", "dT}", "=", "v(T)")+ for formula in formula1, formula2:+ formula.next_to(self.v_graph_label, UP, LARGE_BUFF)+ formula.highlight_by_tex("ds", DISTANCE_COLOR)++ self.play(+ DrawBorderThenFill(self.rect),+ Animation(self.ds_arrow)+ )+ self.dither()+ self.play(*[+ ReplacementTransform(+ mob, formula1.get_part_by_tex(tex),+ run_time = 2+ )+ for mob, tex in [+ (self.ds_label, "ds"),+ (self.ds_arrow, "="),+ (self.v_T_label_group[0].copy(), "v(T)"),+ (self.dT_label_group[0].copy(), "dT"),+ ]+ ])+ self.dither()+ self.transition_to_alt_config(+ dT = self.dT/5.0,+ transformation_kwargs = {"run_time" : 2},)self.dither()+ self.play(*[+ ReplacementTransform(+ formula1.get_part_by_tex(tex),+ formula2.get_part_by_tex(tex),+ )+ for tex in "ds", "=", "v(T)", "dT"+ ] + [+ Write(formula2.get_part_by_tex("over"))+ ])+ self.dither()+####- def add_T_label(self, x_val):+ def add_T_label(self, x_val, **kwargs):triangle = RegularPolygon(n=3, start_angle = np.pi/2)triangle.scale_to_fit_height(MED_SMALL_BUFF)triangle.move_to(self.coords_to_point(x_val, 0), UP)@@ -1580,14 +1712,16 @@ class AreaIsDerivative(PlotVelocity):self.play(DrawBorderThenFill(triangle),ShowCreation(v_line),- Write(T_label, run_time = 1)+ Write(T_label, run_time = 1),+ **kwargs)self.T_label_group = VGroup(T_label, triangle)self.right_v_line = v_linedef get_area(self, t_min, t_max):- dx = float(t_max - t_min) / self.num_rects+ numerator = max(t_max - t_min, 0.01)+ dx = float(numerator) / self.num_rectsreturn self.get_riemann_rectangles(self.v_graph,x_min = t_min,@@ -1599,8 +1733,10 @@ class AreaIsDerivative(PlotVelocity):def change_area_bounds(self, new_t_min = None, new_t_max = None, **kwargs):curr_t_min = self.x_axis.point_to_number(self.area.get_left())curr_t_max = self.x_axis.point_to_number(self.area.get_right())- new_t_min = new_t_min or curr_t_min- new_t_max = new_t_max or curr_t_max+ if new_t_min is None:+ new_t_min = curr_t_min+ if new_t_max is None:+ new_t_max = curr_t_maxgroup = VGroup(self.area, self.right_v_line, self.T_label_group)def update_group(group, alpha):@@ -1614,6 +1750,9 @@ class AreaIsDerivative(PlotVelocity):new_v_line.highlight(v_line.get_color())T_label.move_to(new_v_line.get_bottom(), UP)+ #Fade close to 0+ T_label[0].set_fill(opacity = min(1, t_max))+Transform(area, new_area).update(1)Transform(v_line, new_v_line).update(1)return group@@ -1625,6 +1764,497 @@ class AreaIsDerivative(PlotVelocity):)+class DirectInterpretationOfDsDt(TeacherStudentsScene):+ def construct(self):+ equation = TexMobject("{ds", "\\over\\,", "dT}", "(T)", "=", "v(T)")+ ds, over, dt, of_T, equals, v = equation+ equation.next_to(self.get_pi_creatures(), UP, LARGE_BUFF)+ equation.shift(RIGHT)+ v.highlight(VELOCITY_COLOR)++ s_words = TextMobject("Tiny change in", "distance")+ s_words.next_to(ds, UP+LEFT, LARGE_BUFF)+ s_words.shift_onto_screen()+ s_arrow = Arrow(s_words[1].get_bottom(), ds.get_left())+ s_words.add(s_arrow)+ s_words.highlight(DISTANCE_COLOR)++ t_words = TextMobject("Tiny change in", "time")+ t_words.next_to(dt, DOWN+LEFT)+ t_words.to_edge(LEFT)+ t_arrow = Arrow(t_words[1].get_top(), dt.get_left())+ t_words.add(t_arrow)+ t_words.highlight(TIME_COLOR)++ self.add(ds, over, dt, of_T)+ for words, part in (s_words, ds), (t_words, dt):+ self.play(+ FadeIn(+ words,+ run_time = 2,+ submobject_mode = "lagged_start",+ ),+ self.students[1].change_mode, "raise_right_hand"+ )+ self.play(part.highlight, words.get_color())+ self.dither()+ self.play(Write(VGroup(equals, v)))+ self.change_student_modes(*["pondering"]*3)+ self.dither(3)++class FindAntiderivative(Antiderivative):+ def construct(self):+ self.introduce()+ self.first_part()+ self.second_part()+ self.combine()+ self.add_plus_C()++ def introduce(self):+ q_marks, rhs = functions = self.get_functions("???", "t(8-t)")+ expanded_rhs = TexMobject("8t - t^2")+ expanded_rhs.move_to(rhs, LEFT)+ expanded_rhs.highlight(rhs.get_color())+ self.v_part1 = VGroup(*expanded_rhs[:2])+ self.v_part2 = VGroup(*expanded_rhs[2:])+ for part in self.v_part1, self.v_part2:+ part.save_state()++ top_arc, bottom_arc = arcs = self.get_arcs(functions)+ derivative, antiderivative = words = self.get_arc_labels(arcs)++ self.add(functions)+ self.play(*map(ShowCreation, arcs))+ for word in words:+ self.play(FadeIn(word, submobject_mode = "lagged_start"))+ self.dither()+ self.change_mode("confused")+ self.dither(2)+ self.play(*[+ ReplacementTransform(+ rhs[i], expanded_rhs[j],+ run_time = 2,+ path_arc = np.pi+ )+ for i, j in enumerate([1, 4, 0, 2, 3, 4])+ ]+[+ self.pi_creature.change_mode, "hesitant"+ ])+ self.dither()++ self.q_marks = q_marks+ self.arcs = arcs+ self.words = words++ def first_part(self):+ four_t_squared, two_t = self.get_functions("4t^2", "2t")+ four = four_t_squared[0]+ four.shift(UP)+ four.set_fill(opacity = 0)+ t_squared = VGroup(*four_t_squared[1:])+ two_t.move_to(self.v_part1, LEFT)++ self.play(self.v_part2.to_corner, UP+RIGHT)+ self.play(+ self.pi_creature.change, "plain", self.v_part1+ )+ self.play(ApplyWave(+ self.q_marks,+ direction = UP,+ amplitude = SMALL_BUFF+ ))+ self.dither(2)+ self.play(+ FadeOut(self.q_marks),+ FadeIn(t_squared),+ self.v_part1.shift, DOWN+RIGHT,+ )+ self.play(*[+ ReplacementTransform(+ t_squared[i].copy(), two_t[1-i],+ run_time = 2,+ path_arc = -np.pi/6.+ )+ for i in 0, 1+ ])+ self.change_mode("thinking")+ self.dither()+ self.play(four.set_fill, YELLOW, 1)+ self.play(four.shift, DOWN)+ self.play(FadeOut(two_t))+ self.play(self.v_part1.restore)+ self.play(four.highlight, DISTANCE_COLOR)+ self.dither(2)++ self.s_part1 = four_t_squared++ def second_part(self):+ self.arcs_copy = self.arcs.copy()+ self.words_copy = self.words.copy()+ part1_group = VGroup(+ self.s_part1, self.v_part1,+ self.arcs_copy, self.words_copy+ )++ neg_third_t_cubed, three_t_squared = self.get_functions(+ "- \\frac{1}{3} t^3", "3t^2"+ )+ three_t_squared.move_to(self.v_part1, LEFT)+ neg = neg_third_t_cubed[0]+ third = VGroup(*neg_third_t_cubed[1:4])+ t_cubed = VGroup(*neg_third_t_cubed[4:])+ three = three_t_squared[0]+ t_squared = VGroup(*three_t_squared[1:])++ self.play(+ part1_group.scale, 0.5,+ part1_group.to_corner, UP+LEFT,+ self.pi_creature.change_mode, "plain"+ )+ self.play(+ self.v_part2.restore,+ self.v_part2.shift, LEFT+ )+ self.play(FadeIn(self.q_marks))+ self.dither()++ self.play(+ FadeOut(self.q_marks),+ FadeIn(t_cubed),+ self.v_part2.shift, DOWN+RIGHT+ )+ self.play(*[+ ReplacementTransform(+ t_cubed[i].copy(), three_t_squared[j],+ path_arc = -np.pi/6,+ run_time = 2,+ )+ for i, j in (0, 1), (1, 0), (1, 2)+ ])+ self.dither()+ self.play(FadeIn(third))+ self.play(FadeOut(three))+ self.dither(2)+ self.play(Write(neg))+ self.play(+ FadeOut(t_squared),+ self.v_part2.shift, UP+LEFT+ )+ self.dither(2)++ self.s_part2 = neg_third_t_cubed++ def combine(self):+ self.play(+ self.v_part1.restore,+ self.v_part2.restore,+ self.s_part1.scale, 2,+ self.s_part1.next_to, self.s_part2, LEFT,+ FadeOut(self.arcs_copy),+ FadeOut(self.words_copy),+ run_time = 2,+ )+ self.change_mode("happy")+ self.dither(2)++ def add_plus_C(self):+ s_group = VGroup(self.s_part1, self.s_part2)+ plus_Cs = [+ TexMobject("+%d"%d)+ for d in range(1, 8)+ ]+ for plus_C in plus_Cs:+ plus_C.highlight(YELLOW)+ plus_C.move_to(s_group, RIGHT)+ plus_C = plus_Cs[0]++ self.change_mode("sassy")+ self.dither()+ self.play(+ s_group.next_to, plus_C.copy(), LEFT,+ GrowFromCenter(plus_C),+ )+ self.dither()+ for new_plus_C in plus_Cs[1:]:+ self.play(Transform(plus_C, new_plus_C))+ self.dither()++class GraphSPlusC(GraphDistanceVsTime):+ CONFIG = {+ "y_axis_label" : "Distance"+ }+ def construct(self):+ self.setup_axes()+ graph = self.get_graph(+ s_func,+ color = DISTANCE_COLOR,+ x_min = 0,+ x_max = 8,+ )+ tangent = self.get_secant_slope_group(+ 6, graph, dx = 0.01+ ).secant_line+ v_line = self.get_vertical_line_to_graph(+ 6, graph, line_class = DashedLine+ )+ v_line.scale_in_place(2)+ v_line.highlight(WHITE)+ graph_label, plus_C = full_label = TexMobject(+ "s(t) = 4t^2 - \\frac{1}{3}t^3", "+C"+ )+ plus_C.highlight(YELLOW)+ full_label.next_to(graph.points[-1], DOWN)+ full_label.to_edge(RIGHT)++ self.play(ShowCreation(graph))+ self.play(FadeIn(graph_label))+ self.dither()+ self.play(+ graph.shift, UP,+ run_time = 2,+ rate_func = there_and_back+ )+ self.play(ShowCreation(tangent))+ graph.add(tangent)+ self.play(ShowCreation(v_line))+ self.play(+ graph.shift, 2*DOWN,+ run_time = 4,+ rate_func = there_and_back,+ )+ self.play(Write(plus_C))+ self.play(+ graph.shift, 2*UP,+ rate_func = there_and_back,+ run_time = 4,+ )+ self.dither()++class LowerBound(AreaIsDerivative):+ CONFIG = {+ "num_rects" : 20,+ "graph_origin" : 2.5*DOWN + 6*LEFT+ }++ def construct(self):+ self.force_skipping()++ self.add_integral_and_area()+ self.mention_lower_bound()+ self.drag_right_endpoint_to_zero()+ self.write_antiderivative_difference()+ self.show_alternate_antiderivative_difference()+ self.add_constant_to_antiderivative()+ self.write_fundamental_theorem_of_calculus()+ self.information_of_continuum_vs_endpoints()++ def add_integral_and_area(self):+ self.area = self.get_area(0, 6)+ self.integral = self.get_integral("0", "T")+ self.remove(self.x_axis.numbers)+ self.add(self.area, self.integral)+ self.add_T_label(6, run_time = 0)++ def mention_lower_bound(self):+ lower_bound = self.integral.get_part_by_tex("0")+ circle = Circle(color = YELLOW)+ circle.replace(lower_bound)+ circle.scale_in_place(3)+ zero_label = lower_bound.copy()++ self.play(ShowCreation(circle))+ self.play(Indicate(lower_bound))+ self.play(+ zero_label.scale, 1.5,+ zero_label.next_to, self.graph_origin, DOWN, MED_LARGE_BUFF,+ FadeOut(circle)+ )+ self.dither()++ self.zero_label = zero_label++ def drag_right_endpoint_to_zero(self):+ zero_integral = self.get_integral("0", "0")+ zero_integral[1].highlight(YELLOW)+ zero_int_bounds = list(reversed(+ zero_integral.get_parts_by_tex("0")+ ))+ for bound in zero_int_bounds:+ circle = Circle(color = YELLOW)+ circle.replace(bound)+ circle.scale_in_place(3)+ bound.circle = circle+ self.integral.save_state()+ equals_zero = TexMobject("=0")+ equals_zero.next_to(zero_integral, RIGHT)+ equals_zero.highlight(GREEN)++ self.change_area_bounds(0, 0, run_time = 3)+ self.play(ReplacementTransform(+ self.zero_label.copy(), equals_zero+ ))+ self.play(Transform(self.integral, zero_integral))+ self.dither(2)+ for bound in zero_int_bounds:+ self.play(ShowCreation(bound.circle))+ self.play(FadeOut(bound.circle))+ self.play(*[+ ReplacementTransform(+ bound.copy(), VGroup(equals_zero[1])+ )+ for bound in zero_int_bounds+ ])+ self.dither(2)+ self.change_area_bounds(0, 5)+ self.play(+ self.integral.restore,+ FadeOut(equals_zero)+ )++ self.zero_integral = zero_integral++ def write_antiderivative_difference(self):+ antideriv_diff = self.get_antiderivative_difference("0", "T")+ equals, at_T, minus, at_zero = antideriv_diff+ antideriv_diff_at_eight = self.get_antiderivative_difference("0", "8")+ at_eight = antideriv_diff_at_eight.left_part+ integral_at_eight = self.get_integral("0", "8")++ for part in at_T, at_zero, at_eight:+ part.brace = Brace(part, DOWN, buff = SMALL_BUFF)+ part.brace.save_state()++ antideriv_text = at_T.brace.get_text("Antiderivative", buff = SMALL_BUFF)+ antideriv_text.highlight(MAROON_B)+ value_at_eight = at_eight.brace.get_text(+ "%.2f"%s_func(8)+ )+ happens_to_be_zero = at_zero.brace.get_text("""+ Happens to+ equal 0+ """)++ big_brace = Brace(VGroup(at_T, at_zero))+ cancel_text = big_brace.get_text("Cancels when $T=0$")++ self.play(*map(Write, [equals, at_T]))+ self.play(+ GrowFromCenter(at_T.brace),+ Write(antideriv_text, run_time = 2)+ )+ self.change_area_bounds(0, 5.5, rate_func = there_and_back)+ self.dither()+ self.play(+ ReplacementTransform(at_T.copy(), at_zero),+ Write(minus)+ )+ self.dither()+ self.play(+ ReplacementTransform(at_T.brace, big_brace),+ ReplacementTransform(antideriv_text, cancel_text)+ )+ self.change_area_bounds(0, 0, run_time = 4)+ self.dither()+ self.play(+ ReplacementTransform(big_brace, at_zero.brace),+ ReplacementTransform(cancel_text, happens_to_be_zero),+ )+ self.dither(2)+ self.change_area_bounds(0, 8, run_time = 2)+ self.play(+ Transform(self.integral, integral_at_eight),+ Transform(antideriv_diff, antideriv_diff_at_eight),+ MaintainPositionRelativeTo(at_zero.brace, at_zero),+ MaintainPositionRelativeTo(happens_to_be_zero, at_zero.brace),+ )+ self.play(+ GrowFromCenter(at_eight.brace),+ Write(value_at_eight)+ )+ self.dither(2)+ self.play(*map(FadeOut, [+ at_eight.brace, value_at_eight,+ at_zero.brace, happens_to_be_zero,+ ]))++ self.antideriv_diff = antideriv_diff++ def show_alternate_antiderivative_difference(self):+ new_integral = self.get_integral("1", "7")+ new_antideriv_diff = self.get_antiderivative_difference("1", "7")+ for tex_mob in [new_integral]+new_antideriv_diff[1::2]:+ tex_mob.highlight_by_tex("1", RED)+ tex_mob.highlight_by_tex("7", GREEN)+ tex_mob.highlight_by_tex("\\frac{1}{3}", WHITE)++ self.revert_to_original_skipping_status()+ self.change_area_bounds(1, 7, run_time = 2)+ self.play(+ Transform(self.integral, new_integral),+ Transform(self.antideriv_diff, new_antideriv_diff),+ )+ self.dither(3)+++ def add_constant_to_antiderivative(self):+ pass++ def write_fundamental_theorem_of_calculus(self):+ pass++ def information_of_continuum_vs_endpoints(self):+ pass++ #####++ def get_integral(self, lower_bound, upper_bound):+ result = TexMobject(+ "\\int", "^"+upper_bound, "_"+lower_bound,+ "t(8-t)", "\\,dt"+ )+ result.next_to(self.graph_origin, RIGHT, MED_LARGE_BUFF)+ result.to_edge(UP)+ return result++ def get_antiderivative_difference(self, lower_bound, upper_bound):+ strings = []+ for bound in upper_bound, lower_bound:+ try:+ d = int(bound)+ strings.append("(%d)"%d)+ except:+ strings.append(bound)+ parts = []+ for s in strings:+ part = TexMobject(+ "\\left(",+ "4", s, "^2", "-", "\\frac{1}{3}", s, "^3"+ "\\right))"+ )+ part.highlight_by_tex(s, YELLOW, substring = False)+ parts.append(part)+ result = VGroup(+ TexMobject("="), parts[0],+ TexMobject("-"), parts[1],+ )+ result.left_part, result.right_part = parts+ result.arrange_submobjects(RIGHT)+ result.scale(0.9)+ result.next_to(self.integral, RIGHT)+ return result+++++++++++++diff --git a/topics/characters.py b/topics/characters.pyindex 64d80e9cf..470924e92 100644--- a/topics/characters.py+++ b/topics/characters.py@@ -123,6 +123,11 @@ class PiCreature(SVGMobject):self.look(point - self.eyes.get_center())return self+ def change(self, new_mode, look_at_arg = None):+ self.change_mode(new_mode)+ if look_at_arg:+ self.look_at(look_at_arg)+ return selfdef get_looking_direction(self):return np.sign(np.round(