前提・実現したいこと
x0=3.0 x1=4.0 のときに、x0について偏微分した場合、
その結果のmatplotlibでの表示方法が知りたいです。
現在のファイルの記述は以下の通りです。
以下のページで引数の二乗和を出力する記述を真似ました。
https://endoyuta.com/2017/01/09/python-matplotlib%E3%81%A73%E6%AC%A1%E5%85%83%E3%82%B0%E3%83%A9%E3%83%95%E3%82%92%E6%9B%B8%E3%81%8F/
python
1import numpy as np 2import matplotlib.pylab as plt 3from mpl_toolkits.mplot3d import Axes3D 4 5def function(x0, x1): 6 return x0**2 + x1**2 7 8x0 = np.arange(-3.0, 3.0, 0.25) 9x1 = np.arange(-3.0, 3.0, 0.25) 10X0, X1 = np.meshgrid(x0, x1) 11Y = partial_diff(X0) 12fig = plt.figure() 13ax = Axes3D(fig) 14ax.plot_wireframe(X0, X1, Y) 15plt.show()
試したこと
python
1def numerical_diff(f, x): 2 h = 1e-4 3 return (f(x+h) - f(x-h)) / (2*h) 4 5def function(x0): 6 return x0*x0 + 4.0**2.0 7 8print(numerical_diff(partial_diff, 3.0))
上記のコードで偏微分することはできていると思うのですが、
matplotlibにどのようにその値を適用させ、出力するのかがわかっていません。
数学に対する知識も鈍いので、初歩的なミスに陥っているのかもわかりませんが、
どうぞよろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。