mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 21:44:19 +08:00
End of inventing math video
This commit is contained in:
@ -203,7 +203,7 @@ class Mobject(object):
|
|||||||
return (result.real, result.imag, 0)
|
return (result.real, result.imag, 0)
|
||||||
return self.apply_function(point_map)
|
return self.apply_function(point_map)
|
||||||
|
|
||||||
def highlight(self, color = "red", condition = None):
|
def highlight(self, color = "yellow", condition = None):
|
||||||
"""
|
"""
|
||||||
Condition is function which takes in one arguments, (x, y, z).
|
Condition is function which takes in one arguments, (x, y, z).
|
||||||
"""
|
"""
|
||||||
|
@ -935,15 +935,20 @@ class YouJustInventedSomeMath(Scene):
|
|||||||
mob.shift(UP)
|
mob.shift(UP)
|
||||||
for mob in text[3:]:
|
for mob in text[3:]:
|
||||||
mob.shift(1.3*DOWN)
|
mob.shift(1.3*DOWN)
|
||||||
you = draw_you().center().rewire_part_attributes()
|
# you = draw_you().center().rewire_part_attributes()
|
||||||
|
# smile = PiCreature().mouth.center().shift(you.mouth.get_center())
|
||||||
|
you = PiCreature().highlight("grey")
|
||||||
|
you.center().rewire_part_attributes()
|
||||||
|
|
||||||
self.add(you)
|
self.add(you)
|
||||||
for mob in text:
|
for mob in text:
|
||||||
self.add(mob)
|
self.add(mob)
|
||||||
self.dither(0.2)
|
self.dither(0.2)
|
||||||
|
self.animate(WaveArm(you))
|
||||||
self.animate(BlinkPiCreature(you))
|
self.animate(BlinkPiCreature(you))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SeekMoreGeneralTruths(Scene):
|
class SeekMoreGeneralTruths(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
summands = [
|
summands = [
|
||||||
@ -987,17 +992,19 @@ class ChopIntervalInProportions(Scene):
|
|||||||
if mode == "p":
|
if mode == "p":
|
||||||
num_terms = 4
|
num_terms = 4
|
||||||
prop = 0.7
|
prop = 0.7
|
||||||
left_terms = map(tex_mobject, ["(1-p)", "p(1-p)"]+[
|
left_terms = map(tex_mobject, ["(1-p)", ["p","(1-p)"]]+[
|
||||||
"p^%d(1-p)"%(count)
|
["p^%d"%(count), "(1-p)"]
|
||||||
for count in range(2, num_terms)
|
for count in range(2, num_terms)
|
||||||
])
|
])
|
||||||
right_terms = map(tex_mobject, ["p"] + [
|
right_terms = map(tex_mobject, ["p"] + [
|
||||||
"p^%d"%(count+1)
|
["p", "^%d"%(count+1)]
|
||||||
for count in range(1, num_terms)
|
for count in range(1, num_terms)
|
||||||
])
|
])
|
||||||
interval = zero_to_one_interval()
|
interval = zero_to_one_interval()
|
||||||
left = INTERVAL_RADIUS*LEFT
|
left = INTERVAL_RADIUS*LEFT
|
||||||
right = INTERVAL_RADIUS*RIGHT
|
right = INTERVAL_RADIUS*RIGHT
|
||||||
|
left_paren = tex_mobject("(")
|
||||||
|
right_paren = tex_mobject(")").shift(right + 1.1*UP)
|
||||||
curr = left.astype("float")
|
curr = left.astype("float")
|
||||||
brace_to_replace = None
|
brace_to_replace = None
|
||||||
term_to_replace = None
|
term_to_replace = None
|
||||||
@ -1023,17 +1030,63 @@ class ChopIntervalInProportions(Scene):
|
|||||||
arrow.points = np.array(list(reversed(arrow.points)))
|
arrow.points = np.array(list(reversed(arrow.points)))
|
||||||
additional_anims = [ShowCreation(arrow)]
|
additional_anims = [ShowCreation(arrow)]
|
||||||
if brace_to_replace is not None:
|
if brace_to_replace is not None:
|
||||||
self.animate(
|
if mode == "p":
|
||||||
Transform(
|
lt, rt = lt.split(), rt.split()
|
||||||
brace_to_replace.repeat(2),
|
if count == 1:
|
||||||
CompoundMobject(*braces)
|
new_term_to_replace = deepcopy(term_to_replace)
|
||||||
),
|
new_term_to_replace.center().shift(last+UP+0.3*LEFT)
|
||||||
Transform(
|
left_paren.center().shift(last+1.1*UP)
|
||||||
term_to_replace,
|
self.animate(
|
||||||
CompoundMobject(lt, rt)
|
FadeIn(lt[1]),
|
||||||
),
|
FadeIn(rt[0]),
|
||||||
*additional_anims
|
Transform(
|
||||||
)
|
brace_to_replace.repeat(2),
|
||||||
|
CompoundMobject(*braces)
|
||||||
|
),
|
||||||
|
FadeIn(left_paren),
|
||||||
|
FadeIn(right_paren),
|
||||||
|
Transform(term_to_replace, new_term_to_replace),
|
||||||
|
*additional_anims
|
||||||
|
)
|
||||||
|
self.dither()
|
||||||
|
self.animate(
|
||||||
|
Transform(
|
||||||
|
term_to_replace,
|
||||||
|
CompoundMobject(lt[0], rt[1])
|
||||||
|
),
|
||||||
|
FadeOut(left_paren),
|
||||||
|
FadeOut(right_paren)
|
||||||
|
)
|
||||||
|
self.remove(left_paren, right_paren)
|
||||||
|
else:
|
||||||
|
self.animate(
|
||||||
|
FadeIn(lt[1]),
|
||||||
|
FadeIn(rt[0]),
|
||||||
|
Transform(
|
||||||
|
brace_to_replace.repeat(2),
|
||||||
|
CompoundMobject(*braces)
|
||||||
|
),
|
||||||
|
Transform(
|
||||||
|
term_to_replace,
|
||||||
|
CompoundMobject(lt[0], rt[1])
|
||||||
|
),
|
||||||
|
*additional_anims
|
||||||
|
)
|
||||||
|
self.remove(*lt+rt)
|
||||||
|
lt, rt = CompoundMobject(*lt), CompoundMobject(*rt)
|
||||||
|
self.add(lt, rt)
|
||||||
|
else:
|
||||||
|
self.animate(
|
||||||
|
Transform(
|
||||||
|
brace_to_replace.repeat(2),
|
||||||
|
CompoundMobject(*braces)
|
||||||
|
),
|
||||||
|
Transform(
|
||||||
|
term_to_replace,
|
||||||
|
CompoundMobject(lt, rt)
|
||||||
|
),
|
||||||
|
*additional_anims
|
||||||
|
)
|
||||||
self.remove(brace_to_replace, term_to_replace)
|
self.remove(brace_to_replace, term_to_replace)
|
||||||
self.add(lt, rt, *braces)
|
self.add(lt, rt, *braces)
|
||||||
else:
|
else:
|
||||||
@ -1390,21 +1443,35 @@ class SumPowersOfTwoAnimation(Scene):
|
|||||||
|
|
||||||
class PretendTheyDoApproachNegativeOne(RearrangeEquation):
|
class PretendTheyDoApproachNegativeOne(RearrangeEquation):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
you, bubble = draw_you(with_bubble = True)
|
num_lines = 6
|
||||||
start_terms = "1 , 3 , 7 , 15 , 31 , \\cdots\\rightarrow -1".split(" ")
|
da = "\\downarrow"
|
||||||
end_terms = "2 , 4 , 8 , 16 , 32 , \\cdots\\rightarrow 0".split(" ")
|
columns = [
|
||||||
def transform(mob):
|
tex_mobject("\\\\".join([
|
||||||
bubble.add_content(mob)
|
n_func(n)
|
||||||
return mob
|
for n in range(num_lines)
|
||||||
index_map = dict([(a, a) for a in range(len(start_terms))])
|
]+last_bits), size = "\\Large").to_corner(UP+LEFT)
|
||||||
|
for n_func, last_bits in [
|
||||||
self.add(you, bubble)
|
(lambda n : str(2**(n+1)-1), ["\\vdots", da, "-1"]),
|
||||||
RearrangeEquation.construct(
|
(lambda n : "+1", ["", "", "+1"]),
|
||||||
self, start_terms, end_terms, index_map,
|
(lambda n : "=", ["", "", "="]),
|
||||||
size = "\\Huge",
|
(lambda n : str(2**(n+1)), ["\\vdots", da, "0"]),
|
||||||
start_transform = transform,
|
]
|
||||||
end_transform = transform
|
]
|
||||||
|
columns[-1].highlight()
|
||||||
|
columns[2].shift(0.2*DOWN)
|
||||||
|
shift_val = 3*RIGHT
|
||||||
|
for column in columns:
|
||||||
|
column.shift(shift_val)
|
||||||
|
shift_val = shift_val + (column.get_width()+0.2)*RIGHT
|
||||||
|
self.animate(ShimmerIn(columns[0]))
|
||||||
|
self.dither()
|
||||||
|
self.add(columns[1])
|
||||||
|
self.dither()
|
||||||
|
self.animate(
|
||||||
|
DelayByOrder(Transform(deepcopy(columns[0]), columns[-1])),
|
||||||
|
FadeIn(columns[2])
|
||||||
)
|
)
|
||||||
|
self.dither()
|
||||||
|
|
||||||
class DistanceBetweenRationalNumbers(Scene):
|
class DistanceBetweenRationalNumbers(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
@ -1521,7 +1588,7 @@ class ShiftInvarianceNumberLine(Scene):
|
|||||||
\\begin{flushleft}
|
\\begin{flushleft}
|
||||||
*yeah yeah, I know I'm still drawing them on a line,
|
*yeah yeah, I know I'm still drawing them on a line,
|
||||||
but until a few minutes from now I have no other way
|
but until a few minutes from now I have no other way
|
||||||
to draw them"
|
to draw them
|
||||||
\\end{flushright}
|
\\end{flushright}
|
||||||
""").scale(0.5).to_corner(DOWN+RIGHT)
|
""").scale(0.5).to_corner(DOWN+RIGHT)
|
||||||
|
|
||||||
|
@ -18,19 +18,19 @@ from inventing_math import divergent_sum, draw_you
|
|||||||
|
|
||||||
class SimpleText(Scene):
|
class SimpleText(Scene):
|
||||||
args_list = [
|
args_list = [
|
||||||
("Build from the start...",),
|
("Build the foundation of what we know",),
|
||||||
("What would that feel like?",),
|
("What would that feel like?",),
|
||||||
("Arbitrary decisions hinder generality",),
|
("Arbitrary decisions hinder generality",),
|
||||||
("Section 1: Discovering and Defining Infinite Sums",),
|
("Section 1: Discovering and Defining Infinite Sums",),
|
||||||
("Section 2: Seeking Generality",),
|
("Section 2: Seeking Generality",),
|
||||||
("Section 3: Redefining Distance",),
|
("Section 3: Redefining Distance",),
|
||||||
("``Approach''?",),
|
("``Approach''?",),
|
||||||
("Rigor would dicate you ignore these",),
|
("Rigor would dictate you ignore these",),
|
||||||
("dist($A$, $B$) = dist($A+x$, $B+x$) \\quad for all $x$",),
|
("dist($A$, $B$) = dist($A+x$, $B+x$) \\quad for all $x$",),
|
||||||
("How does a useful distance function differ from a random function?",),
|
("How does a useful distance function differ from a random function?",),
|
||||||
("Pause now, if you like, and see if you can invent your own distance function from this.",),
|
("Pause now, if you like, and see if you can invent your own distance function from this.",),
|
||||||
("$p$-adic metrics \\\\ ($p$ is any prime number)",),
|
("$p$-adic metrics \\\\ ($p$ is any prime number)",),
|
||||||
("This does not meant to match the history of discoveries",),
|
("This is not meant to match the history of discoveries",),
|
||||||
]
|
]
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def args_to_string(text):
|
def args_to_string(text):
|
||||||
@ -109,7 +109,27 @@ class PowersOfTwoSmall(Scene):
|
|||||||
self.add(you, bubble, bubble.content)
|
self.add(you, bubble, bubble.content)
|
||||||
|
|
||||||
|
|
||||||
|
class FinalSlide(Scene):
|
||||||
|
def construct(self):
|
||||||
|
self.add(text_mobject("""
|
||||||
|
\\begin{flushleft}
|
||||||
|
Needless to say, what I said here only scratches the
|
||||||
|
surface of the tip of the iceberg of the p-adic metric.
|
||||||
|
What is this new form of number I referred to?
|
||||||
|
Why were distances in the 2-adic metric all powers of
|
||||||
|
$\\frac{1}{2}$ and not some other base?
|
||||||
|
Why does it only work for prime numbers? \\\\
|
||||||
|
\\quad \\\\
|
||||||
|
I highly encourage anyone who has not seen p-adic numbers
|
||||||
|
to look them up and learn more, but even more edifying than
|
||||||
|
looking them up will be to explore this idea for yourself directly.
|
||||||
|
What properties make a distance function useful, and why?
|
||||||
|
What do I mean by ``useful''? Useful for what purpose?
|
||||||
|
Can you find infinite sums or sequences which feel like
|
||||||
|
they should converge in the 2-adic metric, but don't converge
|
||||||
|
to a rational number? Go on! Search! Invent!
|
||||||
|
\\end{flushleft}
|
||||||
|
""", size = "\\small"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user