6
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Pythonによる科学・技術計算] (偏)微分, 数式, sympy

Last updated at Posted at 2017-07-18

#内容
sympyを利用して初等関数の導関数を求める。


#コード

from sympy import *      # sympyライブラリから全ての機能をimoprt
sym.init_printing()      # 出力を整形

x=Symbol('x')                  # 文字'x'を変数xとして定義
y=Symbol('y')                 # 文字 'y'を変数yとして定義


#微分
diff(sin(x),x)  #sin(x)の微分
diff(exp(x),x)   # e^xの微分

# 高階微分
diff(x**4+x**3,x,2)  # x^4+x^3の2階微分


#偏微分
diff(x**2+x*y+2*y**2,x)  # x^2+xy+2y^2のxによる偏微分


# 微分記号を残す場合
Derivative(y(t),t)

#結果

上から順に,以下の通りになる。

スクリーンショット 2017-07-18 14.24.42.png

スクリーンショット 2017-08-02 2.21.57.png

6
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?