3
7

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のdsolveメソッドを利用して,定数係数2階線形同次常微分方程式

$2y''(x)+5y'(x)+2y(x)=0$

の一般解を求める。

from sympy import *
"""
常微分方程式の一般解を求める
"""
x=Symbol('x')                  # 文字'x'を変数xとして定義
y=Symbol('y')                 # 文字 'y'を変数yとして定義

#dsolveにより一般解を求める。
dsolve(2*y(x).diff(x,2)+5*y(x).diff(x,1)+2*y(x))

注: コード中の5y(x).diff(x,1)は, $5 y'(x)$を表す。同様に2y(x).diff(x,2)は$2 y''(x)$を表す。

###結果

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

C1とC2は初期条件から定まる定数である。

3
7
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
3
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?