Python 符號計算的瑞士軍刀——SymPy

來源:互聯網
上載者:User

標籤:python   符號計算   渲染   latex   

快速使用

在Anaconda 的Integration Environment Spyder中可以通過
Preferences > IPython console > Advanced Settings > Use symbolic math
來啟用 IPython’s SYMbolic PYthon (sympy) 模組

這個模組可以讓Spyder 以Latex 風格渲染出非常漂亮的數學運算式,並且在IPython 終端啟動時會自動在終端匯入一些基本的符號對象。

>>> from __future__ import division>>> from sympy import *>>> x, y, z, t = symbols(‘x y z t‘)>>> k, m, n = symbols(‘k m n‘, integer=True)>>> f, g, h = symbols(‘f g h‘, cls=Function)

在終端輸入如下指令

>>> from sympy import *>>> x = symbols(‘x‘)>>> a = Integral(cos(x)*exp(x), x)>>> Eq(a, a.doit())

終端顯示結果如下:

可以看到輸出的結果非常的漂亮!

更多介紹

Sympy 首頁地址:http://www.sympy.org/en/index.html

在官網上可以找到更多的執行個體代碼和教學文檔

比較有趣的是有一個 線上的SymPy Shell

在意在網頁中輸入運算式,然後得到返回的結果,如分別輸入

>>> expr = x**2 + x*y>>> srepr(expr)>>> expr = (x + y)**5>>> expand(expr)

在右邊的 SymPy Live Shell 中可以看到返回的結果,非常的 Nice!

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

Python 符號計算的瑞士軍刀——SymPy

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.