多项式
12 x 3 + 2 x − 16 12 x^{3}+2 x-16 12x3+2x−16
三项:
-
12x3
-
2x
-
-16
-
两个系数(12 和 2) 和一个常量-16
-
变量 x
-
指数 3
标准形式
随着x的指数增长排列(升幂)
3
x
+
4
x
y
2
−
3
+
x
3
3 x+4 x y^{2}-3+x^{3}
3x+4xy2−3+x3
指数最高项在前(降幂)
x
3
+
4
x
y
2
+
3
x
−
3
x^{3}+4 x y^{2}+3 x-3
x3+4xy2+3x−3
多项式化简
x 3 + 2 x 3 − 3 x − x + 8 − 3 3 x 3 − 4 x + 5 \begin{array}{l}x^{3}+2 x^{3}-3 x-x+8-3 \\ 3 x^{3}-4 x+5\end{array} x3+2x3−3x−x+8−33x3−4x+5
from random import randint
x = randint(1,100) # 取任意值验证多项式化简
(x**3 + 2*x**3 - 3*x - x + 8 - 3) == (3*x**3 - 4*x + 5)
True
多项式相加
( 3 x 3 − 4 x + 5 ) + ( 2 x 3 + 3 x 2 − 2 x + 2 ) 3 x 3 + 2 x 3 + 3 x 2 − 4 x − 2 x + 5 + 2 5 x 3 + 3 x 2 − 6 x + 7 \begin{array}{c}\left(3 x^{3}-4 x+5\right)+\left(2 x^{3}+3 x^{2}-2 x+2\right) \\ 3 x^{3}+2 x^{3}+3 x^{2}-4 x-2 x+5+2 \\ 5 x^{3}+3 x^{2}-6 x+7\end{array} (3x3−4x+5)+(2x3+3x2−2x+2)3x3+2x3+3x2−4x−2x+5+25x3+3x2−6x+7
x = randint(1,100)
(3*x**3 - 4*x + 5) + (2*x**3 + 3*x**2 - 2*x + 2) == 5*x**3 + 3*x**2 - 6*x + 7
True
多项式相减
( 2 x 2 − 4 x + 5 ) − ( x 2 − 2 x + 2 ) ( 2 x 2 − 4 x + 5 ) + ( − x 2 + 2 x − 2 ) 2 x 2 + − x 2 + − 4 x + 2 x + 5 + − 2 x 2 − 2 x + 3 \begin{array}{c}\left(2 x^{2}-4 x+5\right)-\left(x^{2}-2 x+2\right) \\ \left(2 x^{2}-4 x+5\right)+\left(-x^{2}+2 x-2\right) \\ 2 x^{2}+-x^{2}+-4 x+2 x+5+-2 \\ x^{2}-2 x+3\end{array} (2x2−4x+5)−(x2−2x+2)(2x2−4x+5)+(−x2+2x−2)2x2+−x2+−4x+2x+5+−2x2−2x+3
from random import randint
x = randint(1,100)
(2*x**2 - 4*x + 5) - (x**2 - 2*x + 2) == x**2 - 2*x + 3
True
多项式相乘
- 用第一个多项式的每一项乘以第二个多项式
- 把相乘的结果合并同类项
( x 4 + 2 ) ( 2 x 2 + 3 x − 3 ) 2 x 6 + 3 x 5 − 3 x 4 + 4 x 2 + 6 x − 6 \begin{array}{c}\left(x^{4}+2\right)\left(2 x^{2}+3 x-3\right) \\ 2 x^{6}+3 x^{5}-3 x^{4}+4 x^{2}+6 x-6\end{array} (x4+2)(2x2+3x−3)2x6+3x5−3x4+4x2+6x−6
x = randint(1,100)
(x**4 + 2)*(2*x**2 + 3*x - 3) == 2*x**6 + 3*x**5 - 3*x**4 + 4*x**2 + 6*x - 6
True
多项式相除
简单例子
( 4 x + 6 x 2 ) ÷ 2 x 4 x + 6 x 2 2 x 4 x 2 x + 6 x 2 2 x 2 + 3 x \begin{array}{c}\left(4 x+6 x^{2}\right) \div 2 x \\ \frac{4 x+6 x^{2}}{2 x} \\ \frac{4 x}{2 x}+\frac{6 x^{2}}{2 x} \\ 2+3 x\end{array} (4x+6x2)÷2x2x4x+6x22x4x+2x6x22+3x
x = randint(1,100)
(4*x + 6*x**2) / (2*x) == 2 + 3*x
True
长除法
( x 2 + 2 x − 3 ) ÷ ( x − 2 ) x − 2 ∣ x 2 + 2 x − 3 ‾ x − 2 ∣ x x 2 + 2 x − 3 x 2 − 2 x \begin{array}{c}\left(x^{2}+2 x-3\right) \div(x-2) \\ x-2 \mid \overline{x^{2}+2 x-3} \\ x-2 \mid \frac{x}{x^{2}+2 x-3} \\ x^{2}-2 x\end{array} (x2+2x−3)÷(x−2)x−2∣x2+2x−3x−2∣x2+2x−3xx2−2x
x 2 ∣ x 2 + 2 x − 3 − ( x 2 − 2 x ) 4 x − 3 x − 2 ∣ x 2 + 2 x − 3 − ( x 2 − 2 x ) 4 x − 3 − ( 4 x − 8 ) 5 x + 4 + 5 x − 2 \begin{array}{c}\frac{x}{2 \mid x^{2}+2 x-3} \\ \frac{-\left(x^{2}-2 x\right)}{4 x-3} \\ x-2 \mid x^{2}+2 x-3 \\ \frac{-\left(x^{2}-2 x\right)}{4 x-3} \\ -\left(\frac{4 x-8)}{5}\right. \\ x+4+\frac{5}{x-2}\end{array} 2∣x2+2x−3x4x−3−(x2−2x)x−2∣x2+2x−34x−3−(x2−2x)−(54x−8)x+4+x−25
x = randint(3,100)
(x**2 + 2*x -3)/(x-2) == x + 4 + (5/(x-2))
True
因式
16可以如下表示
- 1 x 16
- 2 x 8
- 4 x 4
或者 1, 2, 4, 8 是 16 的因子
用多项式乘来表示多项式
− 6 x 2 y 3 ( 2 x y 2 ) ( − 3 x y ) \begin{array}{c}-6 x^{2} y^{3} \\ \left(2 x y^{2}\right)(-3 x y)\end{array} −6x2y3(2xy2)(−3xy)
又如
( x + 2 ) ( 2 x 2 − 3 y + 2 ) = 2 x 3 + 4 x 2 − 3 x y + 2 x − 6 y + 4 (x+2)\left(2 x^{2}-3 y+2\right)=2 x^{3}+4 x^{2}-3 x y+2 x-6 y+4 (x+2)(2x2−3y+2)=2x3+4x2−3xy+2x−6y+4
那么x+2 和 2x2 - 3y + 2 都是 2x3 + 4x2 - 3xy + 2x - 6y + 4的因子
最大公共因子
16 | 24 |
---|---|
1 x 16 | 1 x 24 |
2 x 8 | 2 x 12 |
2 x 8 | 3 x 8 |
4 x 4 | 4 x 6 |
8是16和24的最大公约数
15 x 2 y 9 x y 3 15 x^{2} y \quad 9 x y^{3} 15x2y9xy3
这两个多项式的最大公共因子是?
最大公共因子
先看系数,他们都包含3
- 3 x 5 = 15
- 3 x 3 = 9
再看x项, x2 和 x。
最后看y项, y 和 y3。
最大公共因子是3xy
最大公共因子
可见最大公共因子总包括
- 系数的最大公约数
- 变量指数的最小值
用多项式除来验证:
15 x 2 y 3 x y 9 x y 3 3 x y 3 x y ( 5 x ) = 15 x 2 y 3 x y ( 3 y 2 ) = 9 x y 3 \begin{array}{l}\frac{15 x^{2} y}{3 x y} \quad \frac{9 x y^{3}}{3 x y} \\ 3 x y(5 x)=15 x^{2} y \\ 3 x y\left(3 y^{2}\right)=9 x y^{3}\end{array} 3xy15x2y3xy9xy33xy(5x)=15x2y3xy(3y2)=9xy3
x = randint(1,100)
y = randint(1,100)
print((3*x*y)*(5*x) == 15*x**2*y)
print((3*x*y)*(3*y**2) == 9*x*y**3)
True
True
用系数最大公约数作因式分解
6 x + 15 y 6 x + 15 y = 3 ( 2 x ) + 3 ( 5 y ) 6 x + 15 y = 3 ( 2 x ) + 3 ( 5 y ) = 3 ( 2 x + 5 y ) \begin{array}{c}6 x+15 y \\ 6 x+15 y=3(2 x)+3(5 y) \\ 6 x+15 y=3(2 x)+3(5 y)=3(2 x+5 y)\end{array} 6x+15y6x+15y=3(2x)+3(5y)6x+15y=3(2x)+3(5y)=3(2x+5y)
x = randint(1,100)
y = randint(1,100)
(6*x + 15*y) == (3*(2*x) + 3*(5*y)) == (3*(2*x + 5*y))
True
用最大公共因子作因式分解
15 x 2 y + 9 x y 3 3 x y ( 5 x ) = 15 x 2 y 3 x y ( 3 y 2 ) = 9 x y 3 15 x 2 y + 9 x y 3 = 3 x y ( 5 x + 3 y 2 ) \begin{array}{c}15 x^{2} y+9 x y^{3} \\ 3 x y(5 x)=15 x^{2} y \\ 3 x y\left(3 y^{2}\right)=9 x y^{3} \\ 15 x^{2} y+9 x y^{3}=3 x y\left(5 x+3 y^{2}\right)\end{array} 15x2y+9xy33xy(5x)=15x2y3xy(3y2)=9xy315x2y+9xy3=3xy(5x+3y2)
x = randint(1,100)
y = randint(1,100)
(15*x**2*y + 9*x*y**3) == (3*x*y*(5*x + 3*y**2))
True
用平方差公式作因式分解
x 2 − 9 x 2 − 3 2 ( x − 3 ) ( x + 3 ) \begin{array}{c}x^{2}-9 \\ x^{2}-3^{2} \\ (x-3)(x+3)\end{array} x2−9x2−32(x−3)(x+3)
x = randint(1,100)
(x**2 - 9) == (x - 3)*(x + 3)
True
用平方作因式分解
x 2 + 10 x + 25 ( x + 5 ) ( x + 5 ) ( x + 5 ) 2 ( a + b ) 2 = a 2 + b 2 + 2 a b \begin{array}{c}x^{2}+10 x+25 \\ (x+5)(x+5) \\ (x+5)^{2} \\ (a+b)^{2}=a^{2}+b^{2}+2 a b\end{array} x2+10x+25(x+5)(x+5)(x+5)2(a+b)2=a2+b2+2ab
a = randint(1,100)
b = randint(1,100)
a**2 + b**2 + (2*a*b) == (a + b)**2
True
二次方程
y = 2 ( x − 1 ) ( x + 2 ) y = 2 x 2 + 2 x − 4 \begin{array}{l}y=2(x-1)(x+2) \\ y=2 x^{2}+2 x-4\end{array} y=2(x−1)(x+2)y=2x2+2x−4
x = np.array(range(-9, 9))
y = 2 * x **2 + 2 * x - 4
plt.plot(x, y, color="grey") # 画二次曲线 (抛物线)
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
plt.show()
会是什么形状?
y = − 2 x 2 + 6 x + 7 y=-2 x^{2}+6 x+7 y=−2x2+6x+7
x = np.array(range(-8, 12))
y = -2 * x ** 2 + 6 * x + 7
plt.plot(x, y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
plt.show()
抛物线的顶点
y = a x 2 + b x + c y=a x^{2}+b x+c y=ax2+bx+c
a, b, c是系数
它产生的抛物线有顶点,或者是最高点,或者是最低点。
def plot_parabola(a, b, c):
vx = (-1*b)/(2*a) # 顶点
vy = a*vx**2 + b*vx + c
minx = int(vx - 10) # 范围
maxx = int(vx + 11)
x = np.array(range(minx, maxx))
y = a * x ** 2 + b * x + c
miny = y.min()
maxy = y.max()
plt.plot(x, y, color="grey") # 画曲线
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
sx = [vx, vx] # 画中心线
sy = [miny, maxy]
plt.plot(sx, sy, color='magenta')
plt.scatter(vx,vy, color="red") # 画顶点
plot_parabola(2, 2, -4)
plt.show()
plot_parabola(-2, 3, 5)
plt.show()
抛物线的交点(二次方程的解)
y = 2 ( x − 1 ) ( x + 2 ) 2 ( x − 1 ) ( x + 2 ) = 0 x = 1 x = − 2 \begin{array}{c}y=2(x-1)(x+2) \\ 2(x-1)(x+2)=0 \\ x=1 \\ x=-2\end{array} y=2(x−1)(x+2)2(x−1)(x+2)=0x=1x=−2
# 画曲线
plot_parabola(2, 2, -4)
# 画交点
x1 = -2
x2 = 1
plt.scatter([x1,x2],[0,0], color="green")
plt.annotate('x1',(x1, 0))
plt.annotate('x2',(x2, 0))
plt.show()
二次方程的解公式
a x 2 + b x + c = 0 x = − b ± b 2 − 4 a c 2 a \begin{array}{c}a x^{2}+b x+c=0 \\ x=\frac{-b \pm \sqrt{b^{2}-4 a c}}{2 a}\end{array} ax2+bx+c=0x=2a−b±b2−4ac
def plot_parabola_from_formula (a, b, c):
plot_parabola(a, b, c) # 画曲线
x1 = (-b + (b*b - 4*a*c)**0.5)/(2 * a)
x2 = (-b - (b*b - 4*a*c)**0.5)/(2 * a)
plt.scatter([x1, x2], [0, 0], color="green") # 画解
plt.annotate('x1', (x1, 0))
plt.annotate('x2', (x2, 0))
plt.show()
plot_parabola_from_formula (2, -16, 2)
函数
f ( x ) = x 2 + 2 f ( 3 ) = 11 \begin{array}{c}f(x)=x^{2}+2 \\ f(3)=11\end{array} f(x)=x2+2f(3)=11
def f(x):
return x**2 + 2
f(3)
11
x = np.array(range(-100, 101))
plt.xlabel('x')
plt.ylabel('f(x)')
plt.grid()
plt.plot(x, f(x), color='purple')
plt.show()
函数的定义域
f ( x ) = x + 1 , { x ∈ R } g ( x ) = ( 12 2 x ) 2 , { x ∈ R ∣ x ≠ 0 } g ( x ) = ( 12 2 x ) 2 , x ≠ 0 \begin{array}{c}f(x)=x+1,\{x \in \mathbb{R}\} \\ g(x)=\left(\frac{12}{2 x}\right)^{2},\{x \in \mathbb{R} \quad \mid \quad \mathbf{x} \neq 0\} \\ g(x)=\left(\frac{12}{2 x}\right)^{2}, \quad x \neq 0\end{array} f(x)=x+1,{x∈R}g(x)=(2x12)2,{x∈R∣x=0}g(x)=(2x12)2,x=0
def g(x):
if x != 0:
return (12/(2*x))**2
x = range(-100, 101)
y = [g(a) for a in x]
print(g(0.1))
plt.xlabel('x')
plt.ylabel('g(x)')
plt.grid()
plt.plot(x, y, color='purple')
# 绘制临界点, 如果取接近0的值,临界点附件函数的形状变得不可见
plt.plot(0, g(1), color='purple', marker='o', markerfacecolor='w', markersize=8)
plt.show()
3600.0
h ( x ) = 2 x , { x ∈ R ∣ x ≥ 0 } h(x)=2 \sqrt{x},\{x \in \mathbb{R} \mid x \geq 0\} h(x)=2x ,{x∈R∣x≥0}
def h(x):
if x >= 0:
return 2 * np.sqrt(x)
x = range(-100, 101)
y = [h(a) for a in x]
plt.xlabel('x')
plt.ylabel('h(x)')
plt.grid()
plt.plot(x, y, color='purple')
# 画出边界
plt.plot(0, h(0), color='purple', marker='o', markerfacecolor='purple', markersize=8)
plt.show()
j ( x ) = x + 2 , x ≥ 0 and x ≤ 5 { x ∈ R ∣ 0 ≤ x ≤ 5 } \begin{aligned} j(x) &=x+2, \quad x \geq 0 \text { and } x \leq 5 \\ &\{x \in \mathbb{R} \mid 0 \leq \mathrm{x} \leq 5\} \end{aligned} j(x)=x+2,x≥0 and x≤5{x∈R∣0≤x≤5}
def j(x):
if x >= 0 and x <= 5:
return x + 2
x = range(-100, 101)
y = [j(a) for a in x]
plt.xlabel('x')
plt.ylabel('j(x)')
plt.grid()
plt.plot(x, y, color='purple')
# 两个边界点
plt.plot(0, j(0), color='purple', marker='o', markerfacecolor='purple', markersize=8)
plt.plot(5, j(5), color='purple', marker='o', markerfacecolor='purple', markersize=8)
plt.show()
阶梯函数
k ( x ) = { 0 , if x = 0 1 , if x = 100 k(x)=\left\{\begin{array}{ll}0, & \text { if } x=0 \\ 1, & \text { if } x=100\end{array}\right. k(x)={0,1, if x=0 if x=100
def k(x):
if x == 0:
return 0
elif x == 100:
return 1
x = range(-100, 101)
y = [k(a) for a in x]
plt.xlabel('x')
plt.ylabel('k(x)')
plt.grid()
plt.scatter(x, y, color='purple')
plt.show()
函数的值域
p ( x ) = x 2 + 1 { p ( x ) ∈ R ∣ p ( x ) ≥ 1 } \begin{array}{c}p(x)=x^{2}+1 \\ \{p(x) \in \mathbb{R} \quad \mid \quad \mathrm{p}(\mathrm{x}) \geq 1\}\end{array} p(x)=x2+1{p(x)∈R∣p(x)≥1}
def p(x):
return x**2 + 1
x = np.array(range(-100, 101))
plt.xlabel('x')
plt.ylabel('p(x)')
plt.grid()
plt.plot(x, p(x), color='purple')
plt.show()