LoginSignup
0
2

More than 3 years have passed since last update.

numpy 多項式関連 python

Last updated at Posted at 2019-06-01

poly

polyは、与えられた根の配列を持つ、多項式の係数を返す。

print(numpy.poly([-1, 1, 1, 10]))        #Output : [  1 -11   9  11 -10]
#-1, 1, 1, 10を根とする多項式は x^4-11x^3+9x^2+11x-10=0

roots

rootsは、指定された係数を持つ多項式の根を返す。

print(numpy.roots([1, 0, -1]))           #Output : [-1.  1.]
#x^2-1 = 0 の根は 1, -1

polyint

polyintは、多項式の不定積分を返す。

print(numpy.polyint([1, 1, 1]))          #Output : [ 0.33333333  0.5         1.          0.        ]
#x^2+x+1をxに関して不定積分すると1/3x^3 + 1/2x^2 + x + C(Cは積分定数)Cは、デフォルトでは0にされる

polyder

polyderは、多項式の導関数を返す。

print(numpy.polyder([1, 1, 1, 1]))       #Output : [3 2 1]
#x^3+x^2+x+1をxに関して微分すると、3x^2+2x+1

polyval

polyvalは、特定の値で多項式を評価する。

print(numpy.polyval([1, -2, 0, 2], 4))   #Output : 34
#x^3-2x^2+2に、x=4を代入した結果は34
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