數學函數#

三角函數#

sin(x, /[, out, where, casting, order, ...])

元素級三角正弦函數。

cos(x, /[, out, where, casting, order, ...])

元素級餘弦函數。

tan(x, /[, out, where, casting, order, ...])

計算元素級正切函數。

arcsin(x, /[, out, where, casting, order, ...])

元素級反正弦函數。

asin(x, /[, out, where, casting, order, ...])

元素級反正弦函數。

arccos(x, /[, out, where, casting, order, ...])

元素級三角反餘弦函數。

acos(x, /[, out, where, casting, order, ...])

元素級三角反餘弦函數。

arctan(x, /[, out, where, casting, order, ...])

元素級三角反正切函數。

atan(x, /[, out, where, casting, order, ...])

元素級三角反正切函數。

hypot(x1, x2, /[, out, where, casting, ...])

給定直角三角形的「兩股」,傳回斜邊。

arctan2(x1, x2, /[, out, where, casting, ...])

元素級 x1/x2 的反正切函數,正確選擇象限。

atan2(x1, x2, /[, out, where, casting, ...])

元素級 x1/x2 的反正切函數,正確選擇象限。

degrees(x, /[, out, where, casting, order, ...])

將角度從弧度轉換為度。

radians(x, /[, out, where, casting, order, ...])

將角度從度轉換為弧度。

unwrap(p[, discont, axis, period])

透過取相對於週期的較大增量的補數來解開。

deg2rad(x, /[, out, where, casting, order, ...])

將角度從度轉換為弧度。

rad2deg(x, /[, out, where, casting, order, ...])

將角度從弧度轉換為度。

雙曲函數#

sinh(x, /[, out, where, casting, order, ...])

元素級雙曲正弦函數。

cosh(x, /[, out, where, casting, order, ...])

元素級雙曲餘弦函數。

tanh(x, /[, out, where, casting, order, ...])

計算元素級雙曲正切函數。

arcsinh(x, /[, out, where, casting, order, ...])

元素級反雙曲正弦函數。

asinh(x, /[, out, where, casting, order, ...])

元素級反雙曲正弦函數。

arccosh(x, /[, out, where, casting, order, ...])

元素級反雙曲餘弦函數。

acosh(x, /[, out, where, casting, order, ...])

元素級反雙曲餘弦函數。

arctanh(x, /[, out, where, casting, order, ...])

元素級反雙曲正切函數。

atanh(x, /[, out, where, casting, order, ...])

元素級反雙曲正切函數。

四捨五入#

round(a[, decimals, out])

均勻四捨五入到給定位數。

around(a[, decimals, out])

將陣列四捨五入到給定位數。

rint(x, /[, out, where, casting, order, ...])

將陣列元素四捨五入到最接近的整數。

fix(x[, out])

朝零方向四捨五入到最接近的整數。

floor(x, /[, out, where, casting, order, ...])

傳回輸入值的下限值,逐個元素。

ceil(x, /[, out, where, casting, order, ...])

傳回輸入值的上限值,逐個元素。

trunc(x, /[, out, where, casting, order, ...])

傳回輸入值的截斷值,逐個元素。

總和、乘積、差分#

prod(a[, axis, dtype, out, keepdims, ...])

傳回指定軸上陣列元素的乘積。

sum(a[, axis, dtype, out, keepdims, ...])

指定軸上陣列元素的總和。

nanprod(a[, axis, dtype, out, keepdims, ...])

傳回指定軸上陣列元素的乘積,將非數字 (NaN) 視為 1。

nansum(a[, axis, dtype, out, keepdims, ...])

傳回指定軸上陣列元素的總和,將非數字 (NaN) 視為零。

cumulative_sum(x, /, *[, axis, dtype, out, ...])

傳回沿著給定軸的元素累積總和。

cumulative_prod(x, /, *[, axis, dtype, out, ...])

傳回沿著給定軸的元素累積乘積。

cumprod(a[, axis, dtype, out])

傳回沿著給定軸的元素累積乘積。

cumsum(a[, axis, dtype, out])

傳回沿著給定軸的元素累積總和。

nancumprod(a[, axis, dtype, out])

傳回指定軸上陣列元素的累積乘積,將非數字 (NaN) 視為 1。

nancumsum(a[, axis, dtype, out])

傳回指定軸上陣列元素的累積總和,將非數字 (NaN) 視為零。

diff(a[, n, axis, prepend, append])

計算沿著給定軸的 n 階離散差分。

ediff1d(ary[, to_end, to_begin])

陣列中連續元素之間的差分。

gradient(f, *varargs[, axis, edge_order])

傳回 N 維陣列的梯度。

cross(a, b[, axisa, axisb, axisc, axis])

傳回兩個(向量陣列)的向量積。

trapezoid(y[, x, dx, axis])

使用複合梯形法則沿給定軸積分。

指數和對數#

exp(x, /[, out, where, casting, order, ...])

計算輸入陣列中所有元素的指數。

expm1(x, /[, out, where, casting, order, ...])

計算陣列中所有元素的 exp(x) - 1

exp2(x, /[, out, where, casting, order, ...])

計算輸入陣列中所有 p2**p

log(x, /[, out, where, casting, order, ...])

元素級自然對數。

log10(x, /[, out, where, casting, order, ...])

傳回輸入陣列的以 10 為底的對數,逐個元素。

log2(x, /[, out, where, casting, order, ...])

x 的以 2 為底的對數。

log1p(x, /[, out, where, casting, order, ...])

傳回輸入陣列加 1 的自然對數,逐個元素。

logaddexp(x1, x2, /[, out, where, casting, ...])

輸入指數的總和的對數。

logaddexp2(x1, x2, /[, out, where, casting, ...])

以 2 為底的輸入指數總和的對數。

其他特殊函數#

i0(x)

第一類零階修正貝索函數。

sinc(x)

傳回標準化 sinc 函數。

浮點常式#

signbit(x, /[, out, where, casting, order, ...])

當符號位元設定(小於零)時,傳回元素級 True。

copysign(x1, x2, /[, out, where, casting, ...])

將 x1 的符號更改為 x2 的符號,逐個元素。

frexp(x[, out1, out2], / [[, out, where, ...])

將 x 的元素分解為尾數和以 2 為底的指數。

ldexp(x1, x2, /[, out, where, casting, ...])

傳回 x1 * 2**x2,逐個元素。

nextafter(x1, x2, /[, out, where, casting, ...])

傳回 x1 朝 x2 方向的下一個浮點值,逐個元素。

spacing(x, /[, out, where, casting, order, ...])

傳回 x 與最接近的相鄰數字之間的距離。

有理常式#

lcm(x1, x2, /[, out, where, casting, order, ...])

傳回 |x1||x2| 的最小公倍數

gcd(x1, x2, /[, out, where, casting, order, ...])

傳回 |x1||x2| 的最大公因數

算術運算#

add(x1, x2, /[, out, where, casting, order, ...])

元素級加法運算。

reciprocal(x, /[, out, where, casting, ...])

傳回引數的倒數,逐個元素。

positive(x, /[, out, where, casting, order, ...])

數值正值,逐個元素。

negative(x, /[, out, where, casting, order, ...])

數值負值,逐個元素。

multiply(x1, x2, /[, out, where, casting, ...])

元素級乘法運算。

divide(x1, x2, /[, out, where, casting, ...])

元素級除法運算。

power(x1, x2, /[, out, where, casting, ...])

第一個陣列元素從第二個陣列取冪,逐個元素。

pow(x1, x2, /[, out, where, casting, order, ...])

第一個陣列元素從第二個陣列取冪,逐個元素。

subtract(x1, x2, /[, out, where, casting, ...])

元素級減法運算。

true_divide(x1, x2, /[, out, where, ...])

元素級除法運算。

floor_divide(x1, x2, /[, out, where, ...])

傳回小於或等於輸入值除法的最大整數。

float_power(x1, x2, /[, out, where, ...])

第一個陣列元素從第二個陣列取冪,逐個元素。

fmod(x1, x2, /[, out, where, casting, ...])

傳回元素級除法餘數。

mod(x1, x2, /[, out, where, casting, order, ...])

傳回元素級除法餘數。

modf(x[, out1, out2], / [[, out, where, ...])

傳回陣列的小數部分和整數部分,逐個元素。

remainder(x1, x2, /[, out, where, casting, ...])

傳回元素級除法餘數。

divmod(x1, x2[, out1, out2], / [[, out, ...])

同時傳回元素級商數和餘數。

處理複數#

angle(z[, deg])

傳回複數引數的角度。

real(val)

傳回複數引數的實部。

imag(val)

傳回複數引數的虛部。

conj(x, /[, out, where, casting, order, ...])

傳回元素級複共軛。

conjugate(x, /[, out, where, casting, ...])

傳回元素級複共軛。

尋找極值#

maximum(x1, x2, /[, out, where, casting, ...])

元素級陣列元素最大值。

max(a[, axis, out, keepdims, initial, where])

傳回陣列的最大值或沿軸的最大值。

amax(a[, axis, out, keepdims, initial, where])

傳回陣列的最大值或沿軸的最大值。

fmax(x1, x2, /[, out, where, casting, ...])

元素級陣列元素最大值。

nanmax(a[, axis, out, keepdims, initial, where])

傳回陣列的最大值或沿軸的最大值,忽略任何 NaN。

minimum(x1, x2, /[, out, where, casting, ...])

元素級陣列元素最小值。

min(a[, axis, out, keepdims, initial, where])

傳回陣列的最小值或沿軸的最小值。

amin(a[, axis, out, keepdims, initial, where])

傳回陣列的最小值或沿軸的最小值。

fmin(x1, x2, /[, out, where, casting, ...])

元素級陣列元素最小值。

nanmin(a[, axis, out, keepdims, initial, where])

傳回陣列的最小值或沿軸的最小值,忽略任何 NaN。

其他#

convolve(a, v[, mode])

傳回兩個一維序列的離散線性卷積。

clip(a[, a_min, a_max, out, min, max])

裁剪(限制)陣列中的值。

sqrt(x, /[, out, where, casting, order, ...])

傳回陣列的非負平方根,逐個元素。

cbrt(x, /[, out, where, casting, order, ...])

傳回陣列的立方根,逐個元素。

square(x, /[, out, where, casting, order, ...])

傳回輸入值的元素級平方。

absolute(x, /[, out, where, casting, order, ...])

計算元素級絕對值。

fabs(x, /[, out, where, casting, order, ...])

計算元素級絕對值。

sign(x, /[, out, where, casting, order, ...])

傳回數字符號的元素級指示。

heaviside(x1, x2, /[, out, where, casting, ...])

計算 Heaviside 階躍函數。

nan_to_num(x[, copy, nan, posinf, neginf])

將 NaN 替換為零,將無窮大替換為大的有限數字(預設行為),或使用 nanposinf 和/或 neginf 關鍵字定義的數字。

real_if_close(a[, tol])

如果輸入是複數,且所有虛部都接近於零,則傳回實部。

interp(x, xp, fp[, left, right, period])

單調遞增樣本點的一維線性內插。

bitwise_count(x, /[, out, where, casting, ...])

計算 x 絕對值中的 1 位元數。