SST Lab Dokuwiki Header header picture

ユーザ用ツール

サイト用ツール


lectures:numeric15

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
lectures:numeric15 [2023/01/24 22:57] – [例)多重積分] kimilectures:numeric15 [2023/01/24 23:40] (現在) – [数値積分] kimi
行 31: 行 31:
 $$ $$
  
 +<code python>
 +#@title Left Riemann sum
 +import matplotlib.pyplot as plt
 +import numpy as np
 +
 +def f(x):
 +  return 1 - 3*x**2/5
 +
 +xlist = np.arange(-0.2, 1.2, 0.01)
 +ylist = [f(x) for x in xlist]
 +xsample = [0.0, 0.5]
 +ysample = [f(x) for x in xsample]
 +xbar = [0.25, 0.75]
 +# plot
 +fig, ax = plt.subplots()
 +
 +
 +ax.plot(xlist, ylist, color="black")
 +ax.bar(xbar, ysample, width=0.5, edgecolor="white", alpha=.5, linewidth=0.7)
 +ax.scatter(xsample, ysample, s = 80, c = "red")
 +
 +ax.set(xlim=(-0.1, 1.1), ylim=(0, 1.1))
 +
 +plt.show()
 +
 +</code>
 +
 +{{:lectures:rsum01.png?400|}}
lectures/numeric15.1674568662.txt.gz · 最終更新: 2023/01/24 22:57 by kimi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki