虛數單位
| 高斯整數導航 | ||||||
|---|---|---|---|---|---|---|
| ↑ | ||||||
| 2i | ||||||
| −1+i | i | 1+i | ||||
| ← | −2 | −1 | 0 | 1 | 2 | → |
| −1−i | −i | 1−i | ||||
| −2i | ||||||
| ↓ | ||||||
| 各式各樣的數 | ||
| 基本 | ||
|
<math>\mathbb{N}\subseteq\mathbb{Z}\subseteq\mathbb{Q}\subseteq\mathbb{R}\subseteq\mathbb{C}</math> File:NumberSetinC.svg
| ||
| 延伸 | ||
| 其他 | ||
|
圓周率 <math>\pi = 3.14159265 </math>… | ||
在數學、物理及工程學裏,虛數單位是指二次方程<math>x^2 + 1 = 0</math>的解。雖然沒有這樣的實數可以滿足這個二次方程,但可以通過虛數單位將實數系統<math>\mathbb{R}</math>延伸至複數系統<math>\mathbb{C}</math>。延伸的主要動機為有很多實係數多項式方程式無實數解。例如剛才提到的方程式<math>x^2 + 1 = 0</math>就無實數解。可是倘若我們允許解答為虛數,那麼這方程式以及所有的多項式方程式都有解。虛數單位通常標記為<math>i</math>,但在涉及電氣、電機工程等電學相關領域時,則往往標記為<math>j</math>,這是為了避免與電流(記為<math>i(t)</math>或<math>i</math>)相混淆。
定義[編輯]
| <math>\ldots</math> |
| <math>{ {i}^{-{ 3}} } = i </math> |
| <math>{ {i}^{-{ 2}} } = -1 </math> |
| <math>{ {i}^{-{ 1}} } = -i </math> |
| <math>{ {i}^{0} } = 1 </math> |
| <math>{ {i}^{1} } = i </math> |
| <math>{ {i}^{2} } = -1 </math> |
| <math>{ {i}^{3} } = -i </math> |
| <math>{ {i}^{4} } = 1 </math> |
| <math>{ {i}^{5} } = i </math> |
| <math>{ {i}^{6} } = -1 </math> |
| <math>\ldots</math> |
虛數單位<math>i</math>定義為二次方程式<math>x^2 + 1 = 0</math>的兩個根中的一個。這方程式又可等價表達為:
- <math>{ {x}^{2} } = -1 </math>。
由於實數的平方絕不可能是負數,我們假設有這麼一個數目解答,給它設定一個符號<math>i</math>。很重要的一點是,<math> i </math>是一個良定義的數學構造。
另外,虛數單位同樣可以表示為:
- <math>i = \sqrt{ -{ 1} } </math>
然而<math>i = \sqrt{ -{ 1} } </math>往往被誤認為是錯的,他們的證明的方法是:
- 因為<math>-1 = i\cdot i=\left(\sqrt{-1}\right)\times\left(\sqrt{-1}\right)=\sqrt{\left(-1\right)\times\left(-1\right)}=\sqrt{1}=1</math>,但是-1不等於1。
- 但請注意:<math>\sqrt{a \cdot b}=\sqrt{a}\cdot\sqrt{b}</math>成立的條件有<math>a</math>,<math>b</math>不能為負數。
實數運算可以延伸至虛數與複數。當計算一個表達式時,我們只需要假設<math>i</math>是一個未知數,然後依照<math>i</math>的定義,替代任何<math>i^2</math>的出現為-1。<math>i</math>的更高整數冪數也可以替代為<math>-i</math>,<math>1</math>,或<math>i</math>,根據下述方程式:
- <math>i^3 = i^2 i = (-1) i = -i</math>,
- <math>i^4 = i^3 i = (-i) i = -(i^2) = -(-1) = 1</math>,
- <math>i^5 = i^4 i = (1) i = i</math>。
一般地,有以下的公式:
- <math>i^{4n} = 1</math>
- <math>i^{4n+1} = i</math>
- <math>i^{4n+2} = -1</math>
- <math>i^{4n+3} = -i</math>
- <math>i^n = i^{n \bmod 4}</math>
其中<math>\bmod 4</math>表示被4除的餘數。
補充定義[編輯]
虛數單位 <math>i</math> 是複數域 <math>\mathbb{C}</math> 中的一個基本元素,其核心性質由以下等價方式之一定義:
代數定義[編輯]
作為二次方程 <math>x^2 + 1 = 0</math> 的一個解。即,<math>i</math> 是滿足方程
- <math>i^2 = -1</math>
的數。由於該方程在實數域 <math>\mathbb{R}</math> 內無解,引入 <math>i</math> 是構造更廣的數系——複數體的關鍵步驟。
作為有序對[編輯]
在複數嚴格的公理化構造中,複數定義為有序對 <math>(a, b)</math>,其中 <math>a, b \in \mathbb{R}</math>。在此框架下,虛數單位 <math>i</math> 被定義為有序對
- <math>i := (0, 1)</math>。
而複數的乘法規則定義為 <math>(a, b) \cdot (c, d) = (ac - bd, ad + bc)</math>。由此可驗證:
- <math>i^2 = (0, 1) \cdot (0, 1) = (0\cdot0 - 1\cdot1, 0\cdot1 + 1\cdot0) = (-1, 0) = -1</math>。
這一定義完全繞開了「負數的平方根」這一初始概念,從而在邏輯上更為基礎。
i和-i[編輯]
方程<math>x^2 = -1</math>有兩個不同的解,它們都是有效的,且互為共軛虛數及倒數。更加確切地,一旦固定了方程的一個解<math>i</math>,那麼<math>-i</math>(不等於<math>i</math>)也是一個解,由於這個方程是<math>i</math>的唯一的定義,因此這個定義表面上有歧義。然而,只要把其中一個解選定,並固定為<math>i</math>,那麼實際上是沒有歧義的。這是因為,雖然<math>-i</math>和<math>i</math>在數量上不是相等的(它們是一對共軛虛數),但是<math>i</math>和<math>-i</math>之間沒有質量上的區別(-1和+1就不是這樣的)。在任何的等式中同時將所有i替換為-i,該等式仍成立。
- <math>-i^2 = 1</math>
- <math>-i = i^{-1} = \frac{1}{i}</math>
正當的使用[編輯]
虛數單位有時記為<math>\sqrt{-1}</math>。但是,使用這種記法時需要非常謹慎,這是因為有些在實數範圍內成立的公式在複數範圍內並不成立。例如,公式<math>\sqrt{a} \cdot \sqrt{b} = \sqrt{a \cdot b}</math>僅對於非負的實數<math>a</math>和<math>b</math>才成立。
假若這個關係在虛數仍成立,則會出現以下情況:
- <math>-1 = i \cdot i = \sqrt{-1} \cdot \sqrt{-1} = \sqrt{(-1) \cdot (-1)} = \sqrt{1} = 1</math>(不正確)
- <math>-1 = i \cdot i = \pm \sqrt{-1} \cdot \pm \sqrt{-1} = \pm \sqrt{(-1) \cdot (-1)} = \pm \sqrt{1} = \pm 1</math>(不正確)
- <math>\frac{1}{i} = \frac{\sqrt{1}}{\sqrt{-1}} = \sqrt{\frac{1}{-1}} = \sqrt{-1} = i</math>(不正確)
與主平方根的關係[編輯]
在複數體中,「平方根」是一個多值函數。對於非負實數 <math>a</math>,符號 <math>\sqrt{a}</math> 通常指其唯一的非負實平方根(稱為**主平方根**或**主平方根**)。然而,對於負數或一般的複數,符號 <math>\sqrt{z}</math> 必須明確其分支的選擇。通常,複數的**主平方根**函數定義為其輻角落在區間 <math>(-\pi, \pi]</math> 內的那個根。 在這種約定下,<math>\sqrt{-1}</math> 的主值是 <math>i</math>(而非 <math>-i</math>)。即便如此,涉及多個複數的主平方根的恆等式也普遍不成立。因此,在處理複數時,最安全且清晰的做法是直接使用符號 <math>i</math> 及其基本性質 <math>i^2 = -1</math> 進行計算,避免對負數直接應用根號運算法則。
i的運算[編輯]
利用複數的運算規則和歐拉公式,可以對虛數單位 <math>i</math> 進行各種數學運算,包括平方根、冪、對數和三角函數。以下運算除特殊說明外,均為與 <math>i</math> 有關的多值函數,在實際應用時必須指明函數的定義選擇在黎曼面的哪一支。下面列出的僅僅是最常採用的黎曼面分支的計算結果。
基本運算與冪循環[編輯]
虛數單位 <math>i</math> 的整數冪遵循一個週期為4的循環:
- <math>\begin{align}
i^1 &= i, \\ i^2 &= -1, \\ i^3 &= -i, \\ i^4 &= 1, \end{align}</math> 一般地,對任意整數 <math>n</math>,有:
- <math>i^n = i^{n \bmod 4}</math>
其中 <math>\bmod 4</math> 表示被4除的餘數。
平方根[編輯]
<math>i</math> 的平方根為:
- <math>\sqrt{i} = \pm \left( \frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2} i \right) = \pm \frac{\sqrt{2}}{2}(1 + i)</math>
使用主平方根符號表示其主值:
- <math>\sqrt{i} = \frac{\sqrt{2}}{2}(1 + i)</math>
其解法為先假設兩實數 <math>x</math> 及 <math>y</math>,使得 <math>(x + iy)^2 = i</math>,然後求解 <math>x, y</math>。[1]
一般冪運算[編輯]
利用歐拉公式 <math>e^{i\theta} = \cos \theta + i \sin \theta</math>,可以將虛數單位表示為指數形式:
- <math>i = e^{i\left(\frac{\pi}{2} + 2k\pi\right)}</math>,其中 <math>k \in \mathbb{Z}</math> 為任意整數。
由此可推導出更一般的冪運算公式。設 <math>a, b, c \in \mathbb{R}</math>,且 <math>a > 0</math>,則有:
- 以 <math>i</math> 為指數的冪(實數的虛數次冪):
- <math>a^{i} = e^{i \ln a} = \cos(\ln a) + i \sin(\ln a)</math>
這是一個模為1的複數,其幾何意義是在複數平面上將點1旋轉 <math>\ln a</math> 弧度。
- 以虛數為指數的冪(實數底數的純虛數次冪):
- <math>a^{b i} = e^{b i \ln a} = \cos(b \ln a) + i \sin(b \ln a)</math>
- 複數的複數次冪(最一般的情況):
- <math>a^{b + c i} = a^{b} \cdot a^{c i} = a^{b} \left[ \cos(c \ln a) + i \sin(c \ln a) \right]</math>
此公式清晰地分離了結果在複數平面上的**伸縮因子** <math>a^b</math> 和**旋轉因子** <math>a^{c i}</math>。
- 最為人熟知的特例:<math>i</math> 的 <math>i</math> 次冪
- <math>i^i = \left[ e^{i (\frac{\pi}{2} + 2k \pi)} \right]^i = e^{i^2 (\frac{\pi}{2} + 2k \pi)} = e^{-(\frac{\pi}{2} + 2k \pi)}</math>,<math>k \in \mathbb{Z}</math>
代入不同的 <math>k</math> 值,可計算出無限多的解。當 <math>k = 0</math> 時,得到其主值 <math>e^{-\frac{\pi}{2}} \approx</math> 0.207879576...[2]
對數[編輯]
- 以 <math>i</math> 為底的對數:
對於正實數 <math>x > 0</math>,有:
- <math>\log_i x = {{2 \ln x} \over i\pi} = -i \cdot \frac{2 \ln x}{\pi}</math>(取主值)
- 更一般地,對於正實數 <math>a > 0</math> 且 <math>a \neq 1</math>,以 <math>i</math> 為底的對數可由換底公式導出:
- <math>\log_i a = \frac{\ln a}{\ln i} = \frac{\ln a}{i\left(\frac{\pi}{2} + 2k\pi\right)} = -i \cdot \frac{2 \ln a}{(4k+1)\pi}</math>, <math>k \in \mathbb{Z}</math>。
這是一個純虛數,且由於 <math>\ln i</math> 的多值性,其結果也有無窮多個值。
三角與雙曲函數[編輯]
以下恆等式揭示了虛數單位如何聯繫三角函數與雙曲函數,這是歐拉公式的直接推論。對於實數 <math>x</math>:
- <math>\begin{align}
\cos(i x) &= \cosh x \\ \sin(i x) &= i \sinh x \\ \tan(i x) &= i \tanh x \end{align}</math> 這些公式表明,對虛自變量的三角函數求值,會轉化為實自變量的雙曲函數。
作為直接應用,可以計算:
- <math>\cos i = \cosh 1 = {{e + \frac{1}{e}} \over 2} = {{e^2 + 1} \over 2e} \approx 1.54308064...</math>
- <math>\sin i = i\sinh 1 = {{e - \frac{1}{e}} \over 2} i = {{e^2 - 1} \over 2e} i \approx (1.17520119...) i</math>
在程式語言
- 大部分的程式語言都不提供虛數單位,且平方根函數(大多為sqrt()或Math.Sqrt())的引數不可以是負數,因此,必須自行建立類別後方可使用。
- 但Lisp的許多實現與方言,如Common Lisp,內建虛數和複數的支持。不少動態語言受其影響,也在語言本身或標準庫中支持虛數和複數,如Python、Ruby。
- 一些傳統編程語言,如C語言,也從C99開始支持虛數和複數。
- 在Matlab,虛數單位的表示方法為i或j,但i和j在for迴圈可以有其他用途。
- 在Mathematica,虛數單位的表示方法為I、𝕚或𝕛。
- 在Maple,必須啟用虛數功能,並選擇用i還是j表示虛數單位。
- Go語言於第 1.0 版就內建虛數和複數的支持,變數類型為
complex64和complex128[3]。
代碼示例
以下是一些編程語言中定義虛數單位 <math>i</math> 及進行基本複數運算的方法:
| 編程語言 | 示例代碼 (定義虛數單位與基礎運算) | 備註與輸出示例 |
|---|---|---|
| Python | # 虚数单位用后缀 j 表示
i = 1j
print(f"虚数单位 i = {i}")
print(f"i 的平方 i² = {i ** 2}")
# 输出:虚数单位 i = 1j
# 输出:i 的平方 i² = (-1+0j)
# 复数构造与运算
z1 = 3 + 4j # 复数字面量
z2 = complex(1, -2) # complex(实部, 虚部) 函数
print(f"复数 z1 = {z1}")
print(f"复数 z2 = {z2}")
print(f"z1 + z2 = {z1 + z2}") # 加法:(4+2j)
print(f"z1 * z2 = {z1 * z2}") # 乘法:(11-2j)
# 使用 cmath 模块进行更多运算
import cmath
print(f"e^(i*π) = {cmath.exp(1j * cmath.pi)}") # 欧拉公式,近似 (-1+1.2246467991473532e-16j)
|
* Python 原生支持複數類型,屬於 complex 類。
|
| C語言 (C99標準) | #include <complex.h>
#include <stdio.h>
int main(void) {
// 宏 I 表示虚数单位 i
double complex i = I;
double complex z1 = 3.0 + 4.0 * I;
double complex z2 = 1.0 - 2.0 * I;
// 基本运算
double complex i_squared = i * i;
double complex sum = z1 + z2;
double complex product = z1 * z2;
// 输出结果,creal()和cimag()分别提取实部和虚部
printf("i² = %.2f %+.2fi\n", creal(i_squared), cimag(i_squared));
// 输出:i² = -1.00 +0.00i
printf("z1 + z2 = %.2f %+.2fi\n", creal(sum), cimag(sum));
// 输出:z1 + z2 = 4.00 +2.00i
printf("z1 * z2 = %.2f %+.2fi\n", creal(product), cimag(product));
// 输出:z1 * z2 = 11.00 -2.00i
return 0;
}
|
* 需包含 <complex.h> 頭文件,並使用標準宏 I 表示虛數單位。
|
註解
參見
參考文獻
- Paul J. Nahin, An Imaginary Tale, The Story of √-1, Princeton University Press, 1998
}}