cmath --- 複數的數學函式¶ cmath 模組提供處理複數的基本數學函式,包括三角函式、指數函式、對數函式,以及在直角座標 (real, imag) 與極座標 (r, phi) 表示法之間的轉換。 函式¶ cmath.cos(z: complex) → complex¶ 傳回 z 的餘弦值。 cmath.exp(z: complex) → complex¶ 傳回 z 的指數值。 cmath.log(z: complex) → complex¶ 傳回 z 的自然對數。分支切割線位於負實軸上。 cmath.log10(z: complex) → complex¶ 傳回 z 以 10 為底的對數。分支切割線位於負實軸上。 cmath.phase(z: complex) → float¶ 傳回數值 z 的相位,範圍為 (-pi, +pi]。 cmath.polar(z: complex) → Tuple[float, float]¶ 以 tuple 形式傳回 z 的極座標形式。 cmath.rect(r: float, phi: float) → complex¶ 傳回模數為 r、相位為 phi 的複數。 cmath.sin(z: complex) → complex¶ 傳回 z 的正弦值。 cmath.sqrt(z: complex) → complex¶ 傳回 z 的平方根。 常數¶ cmath.e: float¶ 自然對數的底數 cmath.pi: float¶ 圓的周長與直徑之比