常量函数,幂函数,指数函数,对数函数,三角函数和反三角函数成为基本初等函数。基本初等函数经过有限四则运算和符合运算得到的函数称为初等函数。
1. 常量函数
- 表达式: (其中 c 是常数)
- 参数的意思: 是一个固定的常数。
- 定义域:c
- 值域:
- 奇偶性: 偶函数
- 单调性: 不单调
- 周期性: 周期性(周期为任意值)
- manim示例:
from manim import * class FunctionC1(Scene): def construct(self): a1=MathTex("constant Function").shift(3.5*UP) self.add(a1) title = Title().shift(3.4*UP) self.add(title) # Create axes and shift them down ax = Axes().add_coordinates().shift(0.2*DOWN) # Plot the constant function f(x) = 1 curve = ax.plot(lambda x: 1, color=DARK_BLUE) label = MathTex(r"f(x) = 1 \\ c=1").next_to([-3,1.5,0], buff=0.1).set_color(DARK_BLUE) # Add a label to the curve #label = MathTex("f(x) = 1").next_to(curve, UR, buff=0.2).set_color(DARK_BLUE).shift(2*LEFT) # Add the axes and the curve to the scene self.add(ax, curve, label)
2. 幂函数
- 表达式: (其中 n为常数)
- 参数的意思: n是幂的指数。
- 定义域:
- n为正整数:x (−∞,+∞)
- n为负整数: x>0
- 值域:
- n为偶数:[0,+∞)
- n为奇数: (−∞,+∞)
- n为负数: (0,+∞)(当 x>0)
- 奇偶性:
- 偶函数(当 n为偶数)
- 奇函数(当 n 为奇数)
- 单调性:
- 当 n>0 时,单调递增(n为奇数时可在 x<0 区间内非单调)
- 当 n<0 时,在 x>0 区间单调递减。
- 周期性: 非周期性
示例:
from manim import *
class FunctionPow(Scene):
def construct(self):
# Title for the plot
title = Title("Power Functions")
self.add(title)
# Create axes
ax = Axes().add_coordinates().shift(0.2*DOWN)
#ax.add_coordinate_labels() # 添加坐标标签
# Plot the functions with appropriate ranges
curve1 = ax.plot(lambda x: x**(-2), color=DARK_BLUE, x_range=[0.1, 2.3]) # x > 0
curve2 = ax.plot(lambda x: x**0.5, color=YELLOW, x_range=[0, 2.3]) # x >= 0
curve3 = ax.plot(lambda x: x**1, color=GREEN, x_range=[-2.4, 2.3])
curve4 = ax.plot(lambda x: x**3, color=ORANGE, x_range=[-1.5, 1.2])
# Add labels to the curves
label1 = MathTex(r"f(x) = x^{-2}").next_to([2,0.5,0], buff=0.1).set_color(DARK_BLUE)
label2 = MathTex(r"g(x) = x^{0.5}").next_to(curve2, UR, buff=0.1).set_color(YELLOW)
label3 = MathTex(r"h(x) = x").next_to(curve3, UR, buff=0.1).set_color(GREEN)
label4 = MathTex(r"i(x) = x^3").next_to(curve4, DL, buff=0.1).set_color(ORANGE)
# Add everything to the scene
self.add(ax, curve1, curve2, curve3, curve4, label1, label2, label3, label4)
3. 指数函数
- 表达式: (其中 a>0,a≠1)
- 参数的意思: a是基数,x是指数。
- 定义域: x(−∞,+∞)
- 值域: (0,+∞)
- 奇偶性: 非奇偶函数
- 单调性:
- a>1时,单调递增
- 0<a<1时,单调递减
- 周期性: 非周期性
from manim import *
import math as ma
class FunctionExponential(Scene):
def construct(self):
# Title for the plot
title = Title("Exponential Function")
self.add(title)
# Create axes
ax = Axes(x_range=[-1,9],y_range=[-1,9],x_length=12,y_length=6).add_coordinates().shift(0.2*DOWN)
#ax.add_coordinate_labels() # 添加坐标标签
# Plot the functions with appropriate ranges
curve1 = ax.plot(lambda x: 0.5**x, color=DARK_BLUE, x_range=[-5, 5]) # 1> a > 0
curve2 = ax.plot(lambda x: 1.5**x, color=YELLOW, x_range=[-5, 2.7]) # a>1
curve3 = ax.plot(lambda x: ma.exp(x), color=PINK, x_range=[-5, 2.7]) # a>1
# Add labels to the curves
label1 = MathTex(r"f(x) = 0.5^{x} \\ a=0.5,0<a<1").next_to([1.5,-1,0], buff=0.1).set_color(DARK_BLUE)
label2 = MathTex(r"g(x) = 1.5^{x} \\ a=2,a>1").next_to(curve2, UR, buff=0.1).set_color(YELLOW)
label3 = MathTex(r"g(x) = e^{x} \\ a=2,a>1").next_to([-2,2,0]).set_color(PINK)
# Add everything to the scene
self.add(ax, curve1, curve2,curve3, label1, label2,label3)
4. 对数函数
- 表达式:(其中 a>0,a≠1)
- 参数的意思: a是底数,x 是对数的真数。
- 定义域: x(0,+∞)
- 值域: f(x)(−∞,+∞)
- 奇偶性: 非奇偶函数
- 单调性: 单调递增
- 周期性: 非周期性
from manim import *
import math as ma
class FunctionLogarithm(Scene):
def construct(self):
# Title for the plot
title = Title("Logarithmic Functions")
self.add(title)
# Create axes
ax = Axes(x_range=[0.01, 9], y_range=[-3, 3], x_length=10, y_length=5).add_coordinates().shift(0.2*DOWN)
# Plot the functions with appropriate ranges
curve1 = ax.plot(lambda x: ma.log(x, 0.5), color=DARK_BLUE, x_range=[0.01, 6]) # a < 1
curve2 = ax.plot(lambda x: ma.log(x, 2), color=YELLOW, x_range=[0.01, 8]) # a = 2
curve3 = ax.plot(lambda x: ma.log(x), color=PINK, x_range=[0.01, 8]) # a = e
# Add labels to the curves
label1 = MathTex(r"f(x) = \log_{0.5}{x} \\ a=0.5, 0<a<1").next_to([2.5, -2, 0], buff=0.1).set_color(DARK_BLUE)
label2 = MathTex(r"g(x) = \log_{2}{x} \\ a=2").next_to(curve3, UR, buff=0.1).set_color(YELLOW)
label3 = MathTex(r"h(x) = \log{x} \\ a=e").next_to([2.5,0.5, 0], buff=0.1).set_color(PINK)
# Add everything to the scene
self.add(ax, curve1, curve2, curve3, label1, label2, label3)
5. 三角函数
- 表达式:
- 正弦函数: f(x)=sinxf(x)=sinx
- 余弦函数: f(x)=cosxf(x)=cosx
- 正切函数: f(x)=tanxf(x)=tanx
- 参数的意思: xx 是角度(通常以弧度为单位)。
- 定义域:
- sin(x)和 cos(x): x(−∞,+∞)
- tan(x):
- 值域:
- sin(x)和 cos(x): [−1,1][−1,1]
- tan(x): (−∞,+∞)
- 奇偶性:
- sinx: 奇函数
- cosx: 偶函数
- tanx: 奇函数
- 单调性:
- sinx: 在 (2kπ,(2k+1)π) 上单调递增
- cosx: 在 (2kπ,(2k+1)π)上单调递减
- tanx: 在每个周期内单调递增
- 周期性:
- sin(x)和 cos(x): 周期 2π
- tanx: 周期 ππ
from manim import *
import numpy as np
class FunctionTrigonometric(Scene):
def construct(self):
# Title for the plot
title = Title("Trigonometric Functions")
self.add(title)
# Create axes
ax = Axes(x_range=[-6, 6], y_range=[-2, 2], x_length=12, y_length=6).add_coordinates().shift(0.2*DOWN)
# Plot the functions with appropriate ranges
curve1 = ax.plot(np.sin, color=DARK_BLUE, x_range=[-6, 4]) # Sin function
curve2 = ax.plot(np.cos, color=YELLOW, x_range=[-6, 5]) # Cos function
curve3 = ax.plot(np.tan, color=PINK, x_range=[-1.19, 1]) # Tan function
# Add labels to the curves
label1 = MathTex(r"f(x) = \sin{x}").next_to(curve1, DR, buff=0.1).set_color(DARK_BLUE)
label2 = MathTex(r"g(x) = \cos{x}").next_to(curve2, UR, buff=0.1).set_color(YELLOW)
label3 = MathTex(r"h(x) = \tan{x}").next_to(curve3, UR, buff=0.1).set_color(PINK)
# Add everything to the scene
self.add(ax, curve1, curve2, curve3, label1, label2, label3)
6. 反三角函数
- 表达式:
- arcsin(x)
- arccos(x)
- arctan(x)
- 参数的意思: x是三角函数的值。
- 定义域:
- arcsin(x): [−1,1]
- arccos(x: [−1,1]
- arctan(x): (−∞,+∞)
- 值域:
- arcsin(x):
- arccos(x):
- arctan(x):
- 奇偶性:
- arcsinx: 奇函数
- arccosx: 非奇偶函数
- arctanx: 奇函数
- 单调性:
- arcsinx: 单调递增
- arccosx: 单调递减
- arctanx: 单调递增
- 周期性: 非周期性
from manim import *
import numpy as np
import math
class FunctionInverseTrigonometric(Scene):
def construct(self):
# Title for the plot
title = Title("Inverse Trigonometric Functions")
self.add(title)
# Create axes
ax = Axes(x_range=[-7.5, 7.5], y_range=[-5, 5], x_length=12, y_length=6).add_coordinates().shift(0.2*DOWN)
# Plot the functions with appropriate ranges
curve1 = ax.plot(np.arcsin, color=DARK_BLUE, x_range=[-1, 1]) # Inverse Sin function
curve2 = ax.plot(math.acos, color=YELLOW, x_range=[-1, 1]) # Inverse Cos function
curve3 = ax.plot(np.arctan, color=PINK, x_range=[-10, 4]) # Inverse Tan function
# Add labels to the curves
label1 = MathTex(r"f(x) = \arcsin{x}").next_to(curve1, UR+3*UP, buff=0.1).set_color(DARK_BLUE)
label2 = MathTex(r"g(x) = \arccos{x}").next_to(curve2, DR+5*DOWN, buff=0.1).set_color(YELLOW)
label3 = MathTex(r"h(x) = \arctan(x)").next_to(curve3, UR, buff=0.1).set_color(PINK)
# Add everything to the scene
self.add(ax, curve1, curve2, curve3, label1, label2, label3)