LoginSignup
9
6

More than 5 years have passed since last update.

【Python】2次関数をグラフにプロットする

Posted at

やりたいこと

2次関数をグラフにプロットする。

※準備するものは以下のURLを参照してください。
https://qiita.com/Cesaroshun/items/69c9fad0cd24322559b2

手順

  • 2次関数を取得する
  • 2次関数をグラフにプロット実行

まとめて結論

以下のように記述する。

math_traning.py
import matplotlib.pyplot as plt
import numpy as np

/* -10 < x < 10 */
x = np.arange(-10, 10, 0.1)

/* y = x^2 + 10x + 1*/
y = x**2 + 10*x + 1

/*グラフへのプロット実行*/
plt.plot(x, y)
plt.show()

実行すると、以下のグラフが出力される。
スクリーンショット 2018-01-02 23.49.42.png

9
6
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
9
6