泰勒公式原创
# miaim 制作
点击查看
from manim import *
class SquareAndCircle(Scene):
def construct(self):
banner = ManimBanner() # 背景
title = Title(f"Taylor ") # 不能用汉字
self.add(title, banner)
self.play(Create(title))
self.wait()
ex = MathTex(
r"e^x = 1 + x + \frac{1}{2} x^2 + \frac{1}{6} x^3 + \cdots + \frac{1}{n!} x^n + \cdots,x\in(-\infty,+\infty)",
substrings_to_isolate="x" # 只给x 上色
)
ex.set_color_by_tex("x", RED)
ex.scale(0.8)
self.add(ex)
self.play(Write(ex))
self.wait(3)
ex.shift(UP)
sinx = MathTex(
r"\sin x = x - \frac{1}{3!} x^3 + \frac{1}{5!} x^5 + \cdots + (-1)^{n}\frac{1}{(2n-1)!} x^{2n-1} + \cdots,x\in(-1,+1)",
substrings_to_isolate="x" # 只给x 上色
)
sinx.set_color_by_tex("x", GREEN)
sinx.scale(0.8)
self.add(sinx)
self.play(Write(sinx))
self.wait(3)
groups=VGroup(ex, sinx) # 建立组
groups.shift(UP)
cosx = MathTex(
r"\cos x = 1 - \frac{1}{2!} x^2 + \frac{1}{4!} x^4 + \cdots + (-1)^{n}\frac{1}{(2n)!} x^{2n} + \cdots,x\in(-1,+1)",
substrings_to_isolate="x" # 只给x 上色
)
cosx.set_color_by_tex("x", BLUE)
cosx.scale(0.8)
self.add(cosx)
self.play(Write(cosx))
self.wait(3)
groups.add(cosx) # 向组中添加元素
lnx = MathTex(
r"\ln(x+1) = x - \frac{1}{2} x^2 + \frac{1}{3} x^3 + \cdots + (-1)^{n}\frac{1}{(n)!} x^{n} + \cdots,x\in(-1,+1)",
substrings_to_isolate="x" # 只给x 上色
)
lnx.set_color_by_tex("x", PURPLE)
lnx.scale(0.8)
lnx.shift(DOWN)
self.add(lnx)
self.play(Write(lnx))
self.wait(3)
x_1 = MathTex(
r"\frac{1}{1-x} =1 + x + x^2 + \cdots + x^n + \cdots,x\in(-1,+1)",
substrings_to_isolate="x" # 只给x 上色
)
x_1.set_color_by_tex("x", PURPLE)
x_1.scale(0.8)
x_1.shift(DOWN*2)
self.add(x_1)
self.play(Write(x_1))
self.wait(3)
self.wait()
上次更新: 2022/08/19, 19:00:54