# Scipy特殊包

• 立方根函式
• 指數函式
• 相對誤差指數函式
• 對數和指數函式
• 蘭伯特函式
• 排列和組合函式
• 伽馬函式

``````from scipy.special import cbrt
res = cbrt([10, 9, 0.1254, 234])
print (res)
``````

``````[ 2.15443469 2.08008382 0.50053277 6.16224015]
``````

``````from scipy.special import exp10
res = exp10([2, 4])
print (res)
``````

``````[   100.  10000.]
``````

`x`接近零時，`exp(x)`接近`1`，所以`exp(x)-1`的數值計算可能遭受災難性的精度損失。 然後`exprel(x)`被實現以避免精度的損失，這在`x`接近於零時發生。

``````from scipy.special import exprel
res = exprel([-0.25, -0.1, 0, 0.1, 0.25])
print (res)
``````

``````[0.88479687 0.95162582 1.   1.05170918 1.13610167]
``````

``````from scipy.special import logsumexp
import numpy as np
a = np.arange(10)
res = logsumexp(a)
print (res)
``````

``````9.45862974443
``````

``````from scipy.special import lambertw
w = lambertw(1)
print (w)
print (w * np.exp(w))
``````

``````(0.56714329041+0j)
(1+0j)
``````

``````from scipy.special import comb
res = comb(10, 3, exact = False,repetition=True)
print (res)
``````

``````220.0
``````

``````from scipy.special import perm
res = perm(10, 3, exact = True)
print (res)
``````

``````720
``````

``````from scipy.special import gamma
res = gamma([0, 0.5, 1, 5])
print (res)
``````

``````[inf  1.77245385  1.  24.]
``````