Latest scenes for Fourier series video

This commit is contained in:
Grant Sanderson 2019-06-25 09:03:55 -07:00
parent a3c1640fb7
commit c6d6e500fb
6 changed files with 1333 additions and 84 deletions

View file

@ -40,6 +40,13 @@ SCENES_IN_ORDER = [
YouSaidThisWasEasier,
AskAboutComplexNotVector,
SimpleComplexExponentExample,
LooseWithLanguage,
DemonstrateAddingArrows,
TRangingFrom0To1,
LabelRotatingVectors,
IntegralTrick,
SwapIntegralAndSum,
FootnoteOnSwappingIntegralAndSum,
# Oldies
# FourierSeriesIllustraiton,

View file

@ -97,7 +97,6 @@ class FourierCirclesScene(Scene):
phase = np.log(coefficient).imag
vector.rotate(phase, about_point=ORIGIN)
vector.freq = freq
vector.phase = phase
vector.coefficient = coefficient
vector.center_func = center_func
vector.add_updater(self.update_vector)
@ -105,12 +104,13 @@ class FourierCirclesScene(Scene):
def update_vector(self, vector, dt):
time = self.get_vector_time()
vector.set_angle(
vector.phase + time * vector.freq * TAU
)
vector.shift(
vector.center_func() - vector.get_start()
)
coef = vector.coefficient
freq = vector.freq
phase = np.log(coef).imag
vector.set_length(abs(coef))
vector.set_angle(phase + time * freq * TAU)
vector.shift(vector.center_func() - vector.get_start())
return vector
def get_circles(self, vectors):

View file

@ -672,3 +672,32 @@ class SimpleComplexExponentExample(ClarifyInputAndOutput):
)
input_line.add_numbers(*range(0, 30, 5))
return input_line
class TRangingFrom0To1(SimpleComplexExponentExample):
CONFIG = {
"input_space_rect_config": {
"width": 6,
"height": 2,
},
}
def construct(self):
self.setup_input_space()
self.setup_input_trackers()
self.play(
self.input_tracker.set_value, 1,
run_time=10,
rate_func=linear
)
def get_input_line(self, rect):
result = ClarifyInputAndOutput.get_input_line(self, rect)
result.stretch(0.9, 0)
result.set_stroke(width=2)
for sm in result.get_family():
if isinstance(sm, DecimalNumber):
sm.stretch(1 / 0.9, 0)
sm.set_stroke(width=0)
return result

File diff suppressed because it is too large Load diff

View file

@ -156,3 +156,36 @@ class YouSaidThisWasEasier(TeacherStudentsScene):
)
self.look_at(self.screen)
self.wait(3)
class LooseWithLanguage(TeacherStudentsScene):
def construct(self):
terms = VGroup(
TextMobject("``Complex number''"),
TextMobject("``Vector''"),
)
colors = [YELLOW, BLUE]
for term, color in zip(terms, colors):
term.set_color(color)
terms.scale(1.5)
terms.arrange(DOWN, buff=LARGE_BUFF)
terms.to_edge(UP)
terms.match_x(self.students)
self.teacher_says(
"Loose with\\\\language",
bubble_kwargs={"width": 3, "height": 3},
run_time=2,
)
self.play(
FadeInFrom(terms[1], DOWN),
self.get_student_changes(
"thinking", "pondering", "erm",
look_at_arg=terms,
)
)
self.play(FadeInFromDown(terms[0]))
self.wait()
self.play(Swap(*terms))
self.wait(3)

View file

@ -6,7 +6,7 @@ from active_projects.diffyq.part2.wordy_scenes import WriteHeatEquationTemplate
class FourierSeriesFormula(Scene):
def construct(self):
formula = TexMobject(
"c_{n} = \\int_0^1 e^{-2\\pi i {n} {t}}f({t})d{t}",
"c_{n} = \\int_0^1 e^{-2\\pi i {n} {t}}f({t}){dt}",
tex_to_color_map={
"{n}": RED,
"{t}": YELLOW,
@ -1111,3 +1111,103 @@ class AskAboutComplexNotVector(Scene):
self.wait()
self.play(ShowCreationThenFadeAround(i_part))
self.wait()
class SwapIntegralAndSum(Scene):
def construct(self):
self.perform_swap()
self.show_average_of_individual_terms()
def perform_swap(self):
tex_config = {
"tex_to_color_map": {
"=": WHITE,
"\\int_0^1": WHITE,
"{t}": PINK,
"{dt}": interpolate_color(PINK, WHITE, 0.25),
"{\\cdot 1}": YELLOW,
"{0}": YELLOW,
"{1}": YELLOW,
"{2}": YELLOW,
},
}
int_ft = TexMobject(
"\\int_0^1 f({t}) {dt}",
**tex_config
)
int_sum = TexMobject(
"""
=
\\int_0^1 \\left(
\\cdots +
c_{\\cdot 1}e^{{\\cdot 1} \\cdot 2\\pi i {t}} +
c_{0}e^{{0} \\cdot 2\\pi i {t}} +
c_{1}e^{{1} \\cdot 2\\pi i {t}} +
c_{2}e^{{2} \\cdot 2\\pi i {t}} +
\\cdots
\\right){dt}
""",
**tex_config
)
sum_int = TexMobject(
"""
= \\cdots +
\\int_0^1
c_{\\cdot 1}e^{{\\cdot 1} \\cdot 2\\pi i {t}}
{dt} +
\\int_0^1
c_{0}e^{{0} \\cdot 2\\pi i {t}}
{dt} +
\\int_0^1
c_{1}e^{{1} \\cdot 2\\pi i {t}}
{dt} +
\\int_0^1
c_{2}e^{{2} \\cdot 2\\pi i {t}}
{dt} +
\\cdots
""",
**tex_config
)
self.fix_minuses(int_sum)
self.fix_minuses(sum_int)
# top_line = VGroup(int_ft, int_sum)
# top_line.arrange(RIGHT, buff=SMALL_BUFF)
# top_line.set_width(FRAME_WIDTH - 1)
# top_line.to_corner(UL)
group = VGroup(int_ft, int_sum, sum_int)
group.arrange(
DOWN, buff=MED_LARGE_BUFF,
aligned_edge=LEFT
)
group.set_width(FRAME_WIDTH - 1)
group.to_corner(UL)
int_ft.align_to(int_sum[1], LEFT)
int_ft.shift(0.2 * RIGHT)
self.add(int_ft)
self.add(int_sum)
self.add(sum_int)
def show_average_of_individual_terms(self):
pass
#
def fix_minuses(self, tex_mob):
for mob in tex_mob.get_parts_by_tex("{\\cdot 1}"):
minus = TexMobject("-")
minus.match_style(mob[0])
minus.set_width(
3 * mob[0].get_width(),
stretch=True,
)
minus.move_to(mob, LEFT)
mob.submobjects[0] = minus
class FootnoteOnSwappingIntegralAndSum(Scene):
def construct(self):
pass