乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      SymPy簡易教程(三)

       londonKu 2012-09-30

      球諧函數(shù):

      In [1]: from sympy.abc import theta, phi

       

      In [2]: Ylm(1, 0, theta, phi)

      Out[2]:

           ————

      ╲╱ 3 *cos(θ)

      ────────────

              ——

        2*╲╱ π

       

      In [3]: Ylm(1, 1, theta, phi)

      Out[3]:

          ——            I

      -╲╱ 6   *│sin(θ)│*?

      ────────────────────

                 ——

            4*╲╱ π

       

      In [4]: Ylm(2, 1, theta, phi)

      Out[4]:

         ———                  I

      -╲╱ 30  *│sin(θ)│*cos(θ)*?

      ────────────────────────────

                      ——

                4*╲╱ π

      階乘和伽瑪函數(shù):

      In [1]: x = Symbol("x")

       

      In [2]: y = Symbol("y", integer=True)

       

      In [3]: factorial(x)

      Out[3]: Γ(1 + x)

       

      In [4]: factorial(y)

      Out[4]: y!

       

      In [5]: factorial(x).series(x, 0, 3)

      Out[5]:

                          2           2    2  2

                         x *EulerGamma    π *x

      1 - x*EulerGamma + ────────────── + ───── + O(x**3)

                               2            12

      Zeta函數(shù):

      In [18]: zeta(4, x)

      Out[18]: ζ(4, x)

       

      In [19]: zeta(4, 1)

      Out[19]:

       4

      π

      ──

      90

       

      In [20]: zeta(4, 2)

      Out[20]:

            4

           π

      -1 + ──

           90

       

      In [21]: zeta(4, 3)

      Out[21]:

              4

        17   π

      - ── + ──

        16   90

      多項式:

      In [1]: chebyshevt(2, x)

      Out[1]:

              2

      -1 + 2*x

       

      In [2]: chebyshevt(4, x)

      Out[2]:

             2      4

      1 - 8*x  + 8*x

       

      In [3]: legendre(2, x)

      Out[3]:

                2

             3*x

      -1/2 + ────

              2

       

      In [4]: legendre(8, x)

      Out[4]:

                 2         4         6         8

       35   315*x    3465*x    3003*x    6435*x

      ─── - ────── + ─────── - ─────── + ───────

      128     32        64        32       128

       

      In [5]: assoc_legendre(2, 1, x)

      Out[5]:

                   —————

                ╱     2

      -3*x*╲╱  1 - x

       

      In [6]: assoc_legendre(2, 2, x)

      Out[6]:

             2

      3 - 3*x

       

      In [7]: hermite(3, x)

      Out[7]:

                 3

      -12*x + 8*x

      微分方程

      isympy中:

      In [4]: f(x).diff(x, x) + f(x)     #注意在使用輸入該命令之前,一定要聲明f=Function('f')

      Out[4]:

         2

        d

      ─────(f(x)) + f(x)

      dx dx

       

      In [5]: dsolve(f(x).diff(x, x) + f(x), f(x))

      Out[5]: C?*sin(x) + C?*cos(x)

      代數(shù)方程

      isympy中:

      In [7]: solve(x**4 - 1, x)

      Out[7]: [i, 1, -1, -i]

       

      In [8]: solve([x + 5*y - 2, -3*x + 6*y - 15], [x, y])

      Out[8]: {y: 1, x: -3}

      線性代數(shù)

      矩陣

      矩陣由矩陣類創(chuàng)立:

      >>>from sympy import Matrix

      >>>Matrix([[1,0], [0,1]])

      [1, 0]

      [0, 1]

       

      不只是數(shù)值矩陣,亦可為代數(shù)矩陣,即矩陣中存在符號:

      >>>x = Symbol('x')

      >>>y = Symbol('y')

      >>>A = Matrix([[1,x], [y,1]])

      >>>A

      [1, x]

      [y, 1]

       

      >>>A**2

      [1 + x*y,     2*x]

      [    2*y, 1 + x*y]

      關于矩陣更多的例子,請看線性代數(shù)教程。

       

      系數(shù)匹配

      使用 .match()方法,引用Wild類,來執(zhí)行表達式的匹配。該方法會返回一個字典。

      >>>from sympy import *

      >>>x = Symbol('x')

      >>>p = Wild('p')

      >>>(5*x**2).match(p*x**2)

      {p_: 5}

       

      >>>q = Wild('q')

      >>>(x**2).match(p*x**q)

      {p_: 1, q_: 2}

       

      如果匹配不成功,則返回None

      >>>print (x+1).match(p**x)

      None

       

      可以使用Wild類的‘exclude’參數(shù)(排除參數(shù)),排除不需要和無意義的匹配結果,來保證結論中的顯示是唯一的:

      >>>x = Symbol('x')

      >>>p = Wild('p', exclude=[1,x])

      >>>print (x+1).match(x+p) # 1 is excluded

      None

      >>>print (x+1).match(p+1) # x is excluded

      None

      >>>print (x+1).match(x+2+p) # -1 is not excluded

      {p_: -1}

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多