0
2

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による科学・技術計算] 導関数(微分)の値を求める,数値計算

Last updated at Posted at 2017-07-18

#内容

sympyを利用して, $x^3$の導関数 ($= 3 x^2$) の $x= a = 2$における値 ($=6$)を求める。

diffメソッドにより導関数を求め, limitメソッドを用いて x -> a の極限値を評価することで導関数値を求めている。


#コード

derivative.py

from sympy import *
x=Symbol('x')      # 文字'x'を変数xとして定義
"""
例: x^3のx=2における導関数の値をもとめる
"""
def dfdx(x,a):
    return limit(diff(x**3,x),x,a)

dfdx(x,2)

結果

6

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?