SciPy มีฟังก์ชันทางคณิตศาสตร์พิเศษในโมดูล scipy.special รวมถึงการคำนวณรากที่สามและเลขยกกำลัง 10
1. Cube Root - รากที่สาม (cbrt)
คำนวณ ∛x สำหรับทุกค่า Real (รวมลบได้) ต่างจาก x**(1/3) ที่ให้ Complex สำหรับค่าลบ
ไวยากรณ์
scipy.special.cbrt(x)
ตัวอย่าง
from scipy.special import cbrt
my_cb = cbrt([27, 89, -8, -27])
print("The cube roots are :")
print(my_cb)
ผลลัพธ์
The cube roots are : [ 3. 4.4647451 -2. -3. ]
2. Exponential Base 10 (exp10)
คำนวณ 10^x สำหรับแต่ละ Element
ไวยากรณ์
scipy.special.exp10(x)
ตัวอย่าง
from scipy.special import exp10
my_exp = exp10([12, 17, -3, 0])
print("The exponential values are :")
print(my_exp)
ผลลัพธ์
The exponential values are : [1.e+12 1.e+17 1.e-03 1.e+00]
คำอธิบาย
นำเข้า
cbrtและexp10จากscipy.specialส่ง List/Array เข้าไป คืนค่า Array ผลลัพธ์
cbrtจัดการค่าลบได้ถูกต้อง (คืนค่าลบ)exp10เทียบเท่า10**xแต่เร็วกว่าสำหรับ Array ใหญ่
ฟังก์ชันเกี่ยวข้องใน scipy.special
| ฟังก์ชัน | คำอธิบาย |
|---|---|
| cbrt(x) | Cube Root (∛x) |
| exp10(x) | 10^x |
| exp(x) | e^x |
| exp2(x) | 2^x |
| log10(x) | log₁₀(x) |
| log2(x) | log₂(x) |
| sqrt(x) | Square Root (√x) |
ประโยชน์: ใช้ใน Signal Processing, Scientific Computing, Log-scale Calculations และการจัดการค่าที่มี Dynamic Range กว้าง