當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy special.itairy用法及代碼示例

本文簡要介紹 python 語言中 scipy.special.itairy 的用法。

用法:

scipy.special.itairy(x, out=None) = <ufunc 'itairy'>#

艾裏函數的積分

計算 Airy 函數從 0 到 x 的積分。

參數

x array_like

積分上限(浮點數)。

out ndarray 的元組,可選

函數值的可選輸出數組

返回

Apt 標量或 ndarray

Ai(t) 從 0 到 x 的積分。

Bpt 標量或 ndarray

Bi(t) 從 0 到 x 的積分。

Ant 標量或 ndarray

Ai(-t) 從 0 到 x 的積分。

Bnt 標量或 ndarray

Bi(-t) 從 0 到 x 的積分。

注意

Wrapper for a Fortran routine created by Shanjie Zhang and Jianming Jin [1].

參考

[1]

張善傑和金建明。 “特殊函數的計算”,John Wiley and Sons,1996 年。https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html

例子

計算 x=1. 處的函數。

>>> import numpy as np
>>> from scipy.special import itairy
>>> import matplotlib.pyplot as plt
>>> apt, bpt, ant, bnt = itairy(1.)
>>> apt, bpt, ant, bnt
(0.23631734191710949,
 0.8727691167380077,
 0.46567398346706845,
 0.3730050096342943)

通過為 x 提供 NumPy 數組來計算多個點的函數。

>>> x = np.array([1., 1.5, 2.5, 5])
>>> apt, bpt, ant, bnt = itairy(x)
>>> apt, bpt, ant, bnt
(array([0.23631734, 0.28678675, 0.324638  , 0.33328759]),
 array([  0.87276912,   1.62470809,   5.20906691, 321.47831857]),
 array([0.46567398, 0.72232876, 0.93187776, 0.7178822 ]),
 array([ 0.37300501,  0.35038814, -0.02812939,  0.15873094]))

繪製 -10 到 10 之間的函數。

>>> x = np.linspace(-10, 10, 500)
>>> apt, bpt, ant, bnt = itairy(x)
>>> fig, ax = plt.subplots(figsize=(6, 5))
>>> ax.plot(x, apt, label="$\int_0^x\, Ai(t)\, dt$")
>>> ax.plot(x, bpt, ls="dashed", label="$\int_0^x\, Bi(t)\, dt$")
>>> ax.plot(x, ant, ls="dashdot", label="$\int_0^x\, Ai(-t)\, dt$")
>>> ax.plot(x, bnt, ls="dotted", label="$\int_0^x\, Bi(-t)\, dt$")
>>> ax.set_ylim(-2, 1.5)
>>> ax.legend(loc="lower right")
>>> plt.show()
scipy-special-itairy-1.png

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.special.itairy。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。